Problems reloading the GDT in long mode?
Re: Problems reloading the GDT in long mode?
The sections of the manual describing each instruction tells you exactly what each one does.
Re: Problems reloading the GDT in long mode?
...
Last edited by rpio on Tue Aug 13, 2024 12:21 pm, edited 1 time in total.
Re: Problems reloading the GDT in long mode?
That is false. However, the immediate form is not available. You can just do the jump indirectly:ngx wrote:Oh, if an inter segment jump is a far jump then I can't use it as I am in long mode where it is unavailable.
Code: Select all
reload: dq label
dw 8
[...]
jmp far qword [reload]
label:
The instruction is "RET (far)". The Q is there to set the operand size to qword. Not sure if that is even needed in 64-bit mode. In AT&T syntax, suffixes are already used like that normally, and apparently for instructions with implicit operands, Intel decided to adopt the syntax. It used to be "o64 ret" in NASM. I haven't followed those discussions as I tend to just use GAS, so I'm not quite sure when that became RETQ.ngx wrote:There is iretq in manual, but not retq or retfq
Carpe diem!
Re: Problems reloading the GDT in long mode?
...
Last edited by rpio on Tue Aug 13, 2024 12:20 pm, edited 1 time in total.
-
- Member
- Posts: 5758
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Problems reloading the GDT in long mode?
...But that will only work on Intel CPUs, not AMD. If your destination address fits in 32 bits, you can make it work for both:nullplan wrote:You can just do the jump indirectly:Code: Select all
reload: dq label dw 8 [...] jmp far qword [reload] label:
Code: Select all
reload: dd label
dw 8
[...]
jmp far dword [reload]
label:
Which NASM manual are you looking at? It's definitely there in the latest version. Intel doesn't mention it directly, since Intel uses slightly different syntax from NASM. NASM uses "n" and "f" suffixes to indicate near and far returns, and uses "w", "d", and "q" suffixes to indicate word, dword, or qword operand sizes. That means if you want to find information about RETFQ in the Intel manuals, you'll have to look for RET far, 64-bit operand size.ngx wrote:You told about retq, but what about retfq - as I understood with my tests it needs a segment pushed on to the stack for it to work so it is a far return(which like far jump needs a segment), but why is the retfq not described in intel or nasm manuals, and if it far jumps then retq doesn't or does it?
When the "n" or "f" suffix isn't specified, NASM defaults to a near return, so RETQ is a near return with 64-bit operand size.ngx wrote:And also why there needs to be a retq if it is not mentioned in intel manual(only ret and iretq)?
Re: Problems reloading the GDT in long mode?
...
Last edited by rpio on Tue Aug 13, 2024 12:20 pm, edited 1 time in total.
-
- Member
- Posts: 5758
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Problems reloading the GDT in long mode?
You can find that part in the Intel or AMD manuals. I've already explained where to look.
Re: Problems reloading the GDT in long mode?
...
Last edited by rpio on Tue Aug 13, 2024 12:19 pm, edited 1 time in total.
Re: Problems reloading the GDT in long mode?
Well, I wanted to complain about this, but then I had a more constructive idea: Is there a list of programmer-visible differences between Intel and AMD CPUs? If not, would someone be interested in starting one? Because reading the description of each instruction twice is not my idea of a fun afternoon. I can't, I have to go change my startup code.Octocontrabass wrote:...But that will only work on Intel CPUs, not AMD.
Carpe diem!
-
- Member
- Posts: 5758
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Problems reloading the GDT in long mode?
I don't know of any complete lists, but this reference covers most of the instructions that behave differently.nullplan wrote:Is there a list of programmer-visible differences between Intel and AMD CPUs?