flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Feryno 28 Jan 2008, 12:41
I prefer IRETQ
Code: movzx eax,word [target_SS] ; you can use mov eax,selector if you know where it points into GDT push rax mov rax,qword [target_RSP] push rax push target_RFLAGS ; (usually 202h - interrupts enabled !!! else you may hang) movzx eax,word [target_CS] push rax mov rax,qword [target_RIP] push rax iretq ; db 48h, 0CFh - note that iret (db 0CFh without 48h REX prefix) switches CPU into 32-bit compactibility submode of long mode where instructions are decoded as 32 bit - so don't forget to do IRETQ to keep 64-bit submode of long mode (I wasted a few hours to figure out the reasons of exceptions after iret instead of correct iretq, and note, FASM 1.66 didn't know iretq, you had to add manually db 48h as prefix, but newest FASM versions support IRETQ correctly) the instruction you described should be: Code: jmp fword [target] ; this is translated to RIP-relative addressing, you don't need to waste instructions by lea rax,[target] jmp fword [rax] target: dd target_EIP ; yes, only 32-bit limit = EIP, no 64-bit RIP anymore... dw target_CS because of 32-bit limitation, I prefer IRETQ and I don't like jmp far (I have never used/tested JMP instruction) you can save 1 byte using perhaps 66h prefix and even limit the target to 16-bit IP jmp far dword [target] target: dw target_IP dw target_CS |
|||
![]() |
|
edfed 28 Jan 2008, 13:20
one possibility of fasm:
Code:
farptr64 dt segment16:offset64
try all these possibilities, to know what works and what not. Code: mov rax,farptr jmp far [rax] jmp far [farptr] call far [farptr] |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.