So I'm writing my own 16-bit operating system kernel and i get this error: kernel.asm:60: error: comma, colon, decorator or end of line expected after operand and I don't know why. Here is the code:
; 16-bit registers: ax, bx, cx, dx, si, di, sp, bp
; BIOS interrupts: 0x10, 0x16, 0x13
; Hex numbers: 0A, 20, 3E, 5B, 5D
org 0x8000
BITS 16
%define LNE 0x0A
%define PROMPT db 'asdasdaOS >', 0
section .data
buffer resb 65 ; Reserve space for command buffer (+1 for null terminator)
help_cmd db 'Available commands:', LNE, 'help - display this help command', LNE, 'version - display OS version', LNE, 0
version_cmd db 'asdasdaOS version 0.0.1 alpha', LNE, 0
section .text
global _start
_start:
jmp main
puts:
; save registers we will modify
pusha
.loop:
lodsb ; Load next character from string into AL
or al, al ; Check if AL is null (end of string)
jz .done ; If zero, end of string
mov ah, 0x0E ; BIOS teletype output
mov bh, 0 ; Page number
int 0x10 ; Call video service BIOS interrupt
jmp .loop
.done:
; Restore registers
popa
ret
main:
; Set up data segments
mov ax, 0 ; DS and ES cannot be set directly in 16-bit mode
mov ds, ax
mov es, ax
; Set up stack
mov ss, ax
mov sp, 0x8000 ; Stack grows downwards from where we are loaded in memory
; Print welcome message
mov si, msg_hello
call puts
.get_command:
; Print prompt
mov si, PROMPT < this is where i get my error
call puts
; Clear buffer
xor di, di
mov cx, 64 ; Maximum command length
mov al, 0
rep stosb
; Read input command
mov ah, 0x00 ; BIOS keyboard interrupt
int 0x16 ; Wait for keypress
cmp al, 0x0D ; Check if Enter key was pressed
je .execute_command ; If Enter, execute command
mov [buffer + di], al ; Store character in buffer
inc di ; Move to next buffer position
call putchar ; Echo character to screen
jmp .get_command ; Repeat until Enter is pressed
.execute_command:
; Null-terminate buffer
mov byte [buffer + di], 0
; Compare buffer with commands
mov si, buffer
mov di, help_cmd
cld ; Clear direction flag for string operations
repe cmpsb ; Compare buffer with help command
je .print_help ; Jump if buffer matches help command
mov si, buffer
mov di, version_cmd
cld
repe cmpsb
je .print_version
; Unknown command, print error message
mov si, unknown_cmd_msg
call puts
jmp .get_command
.print_help:
; Print help command
mov si, help_cmd
call puts
jmp .next_line
.print_version:
; Print version command
mov si, version_cmd
call puts
jmp .next_line
.next_line:
; Print newline
mov al, LNE
call putchar
jmp .get_command ; Get next command
; Subroutine to print a single character
putchar:
mov ah, 0x0E ; BIOS teletype output
mov bh, 0 ; Page number
int 0x10 ; Call video service BIOS interrupt
ret
msg_hello: db 'asdasdaOS ver 0.0.1 alpha', LNE, 0
unknown_cmd_msg: db 'Unknown command', LNE, 0
I tried using nasm -f bin kernel.asm -o kernel.bin. The code doesn't work and if I change mov si, PROMPT with lea si, [PROMPT] I get this and the error mentioned: kernel.asm:60: error: expecting ] at end of memory operand