简体   繁体   中英

assembly using nasm “label or instruction expected at start of file”

I'm learning how to make a boot-sector and im following all the codes in notepad++ (wine used) and i tried to assemble the code:

{BITS 16}
{ORG 0x7C00}

jmp 0x0:Start

Start:
cli
mov AX,0x9000
mov SS,AX
mov SP,0xFB00
sti

mov AH,0Eh
mov AL,'E'
int 10h

cli
hlt

times 510 - ($ - $$) db 0
dw 0xAA55

i keep getting the error thats up above in the description, and i have no idea how to fix this...

(the code IS spaced properly i dont know why this site put them on the same line like that)

Directives in NASM have a user form (eg bits 16 ) and a lower level form (eg [bits 16] ). For a lot of cases they're the same (the user form just gets converted into the lower level form internally). For some cases they aren't the same and the user form does some extra book-keeping stuff that the lower level form doesn't do (eg section vs [section] ). In any case, neither of these involve curly braces and you should be using the user form (without square brackets) and not the lower level form (with square brackets).

I don't see any other problems that would cause the error.

I do see a few unrelated problems though (eg assuming the EBDA is a specific size, and the cli before the hlt that prevents "control+alt+delete").

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM