Why it doesn't work?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Karlosoft
Member
Member
Posts: 277
Joined: Thu Feb 14, 2008 10:46 am
Location: Italy
Contact:

Why it doesn't work?

Post 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 :D
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Why it doesn't work?

Post by AJ »

Karlosoft wrote:[/code]
...
INT 10
...[/code]
D'oh! :wink:
User avatar
Karlosoft
Member
Member
Posts: 277
Joined: Thu Feb 14, 2008 10:46 am
Location: Italy
Contact:

Re: Why it doesn't work?

Post by Karlosoft »

INT 10 is wrong??? why?
User avatar
inflater
Member
Member
Posts: 1309
Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:

Re: Why it doesn't work?

Post 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

;)
Last edited by inflater on Sat Sep 13, 2008 8:47 am, edited 1 time in total.
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English :P)
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Why it doesn't work?

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
Karlosoft
Member
Member
Posts: 277
Joined: Thu Feb 14, 2008 10:46 am
Location: Italy
Contact:

Re: Why it doesn't work?

Post by Karlosoft »

Ok now it's working!
Thanks!!!
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Why it doesn't work?

Post by AJ »

Sorry I was obviously too cryptic in my reply - thought that hint should be enough :oops:
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Why it doesn't work?

Post by Brendan »

Hi,
AJ wrote:Sorry I was obviously too cryptic in my reply - thought that hint should be enough :oops:
Your hint was enough - check the time stamps on our posts - I was one minute too late. :)


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Post Reply