Bona Fide OS Developer
View unanswered posts | View active topics It is currently Tue Nov 12, 2024 10:55 am



Post new topic Reply to topic  [ 4 posts ] 
 64-bit mode 
Author Message

Joined: Fri Aug 20, 2010 10:04 pm
Posts: 41
Post 64-bit mode
Many people are new to 64-bit mode.

Code:
XOR EAX,EAX


clears all 64-bits

Code:
MOV EAX,123


puts 123 in low 32 and clears upper 32.

Code:
PUSH EAX


pushes 64-bits

Displacement mode is RIP relative.

Code:
MOV RAX,[123]


That is a relative addressed memory location that must be within 2 Gig of the RIP.


Segment registers FS and GS are set with a model specific registers. I use them to point to the current task record and the current cpu core record. they are tricky to use because of the RIP relative addressing mode.

You cannot do this:

Code:
MOV RAX, FS:[TASK_DATA]


Instead...
Code:
XOR EAX,EAX
MOV RAX,FS:TASK_DATA[RAX]



I put the self address of the task record at offset zero in my task struct, so my compiler can use it easier.

Code:
XOR EAX,EAX
MOV RAX,FS:[RAX] ;self address of task record
MOV RAX,TASK_DATA[RAX]


Sat Jan 08, 2011 11:38 pm
Profile
Site Admin

Joined: Fri Jul 24, 2009 10:02 pm
Posts: 247
Location: Las Vegas, NV, US
Post Re: 64-bit mode
Well that's good to know. A real gem for any 64bit OSdevers out there :)


Thu Mar 17, 2011 5:02 pm
Profile

Joined: Fri Aug 20, 2010 10:04 pm
Posts: 41
Post Re: 64-bit mode
I can't really help you. I wrote my own compiler/assembler. My boot-loader loads my kernel and jmps to it in real mode (16-bit.) My kernel calls various BIOS config routines and then switches to 32 and then 64 bit mode.


Sun Mar 20, 2011 2:08 am
Profile
Site Admin

Joined: Fri Jul 24, 2009 10:02 pm
Posts: 247
Location: Las Vegas, NV, US
Post Re: 64-bit mode
Sorry, what? I didn't ask for any help. I just said it looks great :)


Tue Aug 23, 2011 4:58 pm
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


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.