Bona Fide OS Developer
View unanswered posts | View active topics It is currently Thu Mar 28, 2024 1:47 pm



Post new topic Reply to topic  [ 5 posts ] 
 dd eax not working 
Author Message

Joined: Thu Dec 23, 2010 1:12 pm
Posts: 9
Post dd eax not working
When I try to write the value of eax to ram using
Code:
dd eax
nasm gives me an error message saying:
Code:
error: operand 1: expression is not simple or relocatable
I don't see how I'm doing it wrong because the code looks fine to me.


Wed Mar 23, 2011 4:36 pm
Profile

Joined: Fri Aug 20, 2010 10:04 pm
Posts: 41
Post Re: dd eax not working
"dd" is "define double". Puts a constant in a spot. It is not an instruction.

You want to use the "mov" instruction.

Code:
    mov [01000h],eax


Something like that. You better start with a book on asm, honestly.


Thu Mar 24, 2011 1:38 am
Profile

Joined: Thu Dec 23, 2010 1:12 pm
Posts: 9
Post Re: dd eax not working
So
Code:
example: resd 1
mov [example], eax
should work? I'll try it.


Thu Mar 24, 2011 10:13 am
Profile
Site Admin

Joined: Fri Jul 24, 2009 10:02 pm
Posts: 247
Location: Las Vegas, NV, US
Post Re: dd eax not working
Yep, losethos is right, you need to use the `mov` command and they way you are using it now should move the value in `eax` and move it intomemory at the address labeled `example`. But what is the `resd` opcode? I've never seen that and can't find any reference to it in the intel x86 opcode list.


Tue Aug 23, 2011 1:14 am
Profile

Joined: Thu Dec 23, 2010 1:12 pm
Posts: 9
Post Re: dd eax not working
Resd reserves a double word(the 1 means only reserve one) but I have now found out that it can only be used in the bss section. I understand now that DD actually puts the value in that place in the executable which ends up in ram.


Wed Aug 31, 2011 4:12 pm
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 


Who is online

Users browsing this forum: No registered users and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin and tweaked by the BF Team.