Page 1 of 1
Why it doesn't work?
Posted: Sat Sep 13, 2008 8:24 am
by Karlosoft
I'm trying to write a boot-loader for my os, but it doesn't work... when i try to write in the video memory, the compiler give me an error, "operation size not specified".
Code: Select all
[BITS 16]
[ORG 0x7C00]
MOV AX,0x0003
INT 10
MOV AX, 0x0b800
MOV DS, AX
MOV [0x00], 'a'
MOV [0x01], 00000100b
JMP $
TIMES 510 - ($ - $$) db 0
DW 0xAA55
I'm using nasm... please help me
Re: Why it doesn't work?
Posted: Sat Sep 13, 2008 8:34 am
by AJ
Karlosoft wrote:[/code]
...
INT 10
...[/code]
D'oh!
Re: Why it doesn't work?
Posted: Sat Sep 13, 2008 8:38 am
by Karlosoft
INT 10 is wrong??? why?
Re: Why it doesn't work?
Posted: Sat Sep 13, 2008 8:45 am
by inflater
Because it should be int 10h or int 0x10. But its the assembler's choice on how it interprets numbers. For example, FASM interprets numbers as decimal, by default.
when i try to write in the video memory, the compiler give me an error, "operation size not specified"
Try this:
mov byte [ds:0],'a'
mov byte [ds:1],00000100b
Re: Why it doesn't work?
Posted: Sat Sep 13, 2008 8:46 am
by Brendan
Hi,
Karlosoft wrote:INT 10 is wrong??? why?
Because it's in decimal, not hexadecimal. You need "int 0x10" or "int 10h" or "int 16".
The "operation size not specified" error is different though. That's caused by things like "MOV [0x00], 'a'" because the assembler has no way of knowing if it's meant to be "MOV dword [0x00], 'a'", "MOV word [0x00], 'a'" or "MOV byte [0x00], 'a'".
It'd also be good if you setup a stack (instead of assuming the BIOS left a sane stack).
Lastly, there are some older Compaq machines that check if the first instruction is a JMP, and assume the sector isn't bootable if the first instruction isn't a JMP. This means it's a good idea to start with something like "JMP 0x0000:START".
Cheers,
Brendan
Re: Why it doesn't work?
Posted: Sat Sep 13, 2008 8:48 am
by Karlosoft
Ok now it's working!
Thanks!!!
Re: Why it doesn't work?
Posted: Sat Sep 13, 2008 4:07 pm
by AJ
Sorry I was obviously too cryptic in my reply - thought that hint should be enough
Re: Why it doesn't work?
Posted: Sat Sep 13, 2008 9:55 pm
by Brendan
Hi,
AJ wrote:Sorry I was obviously too cryptic in my reply - thought that hint should be enough
Your hint was enough - check the time stamps on our posts - I was one minute too late.
Cheers,
Brendan