Bona Fide OS Development
http://forums.osdever.net/

64-bit mode
http://forums.osdever.net/viewtopic.php?f=7&t=876
Page 1 of 1

Author:  losethos [ Sat Jan 08, 2011 11:38 pm ]
Post subject:  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]

Author:  brenden [ Thu Mar 17, 2011 5:02 pm ]
Post subject:  Re: 64-bit mode

Well that's good to know. A real gem for any 64bit OSdevers out there :)

Author:  losethos [ Sun Mar 20, 2011 2:08 am ]
Post subject:  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.

Author:  brenden [ Tue Aug 23, 2011 4:58 pm ]
Post subject:  Re: 64-bit mode

Sorry, what? I didn't ask for any help. I just said it looks great :)

Page 1 of 1 All times are UTC - 6 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/