0

I am having an issue with this piece of code:

loop :              

    jmp loop        

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

It is giving me an error saying:

boot.asm:6: error: comma expected after operand 1

I don't know what is causing this. I just started trying os developing, so don't expect me to know that much.

Sep Roland
  • 33,889
  • 7
  • 43
  • 76
user6481546
  • 31
  • 1
  • 8
  • Have you tried adding a comma after operand 1 on line 6? – synchronizer Feb 08 '17 at 03:45
  • Where do I put the comma? – user6481546 Feb 08 '17 at 03:46
  • Actually that may not be the real problem. It's best to way for someone who knows more. My apologies. – synchronizer Feb 08 '17 at 03:50
  • 6
    Remove the space between `0` and `x` . What you want is `dw 0xaa55` . `0x` prefix means the `aa55` is seen as hexadecimal. You want 0xaa55 as the last word in the boot sector as it represents a boot signature that most BIOSes will check for. – Michael Petch Feb 08 '17 at 07:36
  • 3
    There are more redundant spaces there, like "`loop :`" - is this instruction `loop` with argument `:`, or is this label `loop` (and the colon is used to distinguish it from the instruction `loop`)? This may even introduce later unwanted bugs, use the colon rather with every label definition. The `510 -( $ - $$ ) db` is also hard to read for somebody aware of typographical rules... `510 - ($ - $$) db` is more proper style. BTW, if you don't even know the `0x` denotes hexadecimal formatting of value, you should start first with some x86 assembly tutorials, before doing OS. – Ped7g Feb 08 '17 at 09:41
  • Please see http://stackoverflow.com/questions/36052492/times-510-db-0-does-not-work – InfinitelyManic Feb 08 '17 at 15:53

1 Answers1

1

You need to remove the space after between the 0 and the x on line 6.

loop :              

    jmp loop        

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

0x indicates a hexadecimal number, and so it cannot be split up with spaces.

Alex Boxall
  • 541
  • 5
  • 13