Author Topic: mrip2rax MACRO  (Read 1611 times)

habran

  • Member
  • *****
  • Posts: 1179
    • uasm
mrip2rax MACRO
« on: November 24, 2014, 07:14:30 AM »
I've been experimenting with JWasm to build in RIP register
It'l take me some time to find out the way how to do it
In the meantime you can use this macro to load rax register with a contents of location pointed by rip register
it is the same as you write code: mov rax,qword ptr[rip]
it is created from 2 bites of mod 3 bites of reg and 3 bites of r/m
 Mod   reg    rip
  00    000   101
Code: [Select]
mrip2rax MACRO
db 48h      ;REX prefix
db 8bh      ;OPCODE
db 05h      ;05 is for rax    00 000 101
db 00h      ;DISPLACEMENT of dword   00000000h
db 00h
db 00h
db 00h
ENDM
if you want to change which register to load change db 05h to different number
EG:
Code: [Select]
mrip2rcx MACRO
db 48h
db 8bh
db 0dh      ;0D for rcx  00 001 101
db 00h
db 00h
db 00h
db 00h
ENDM
here are the numbers of registers:
 05    0D   15   1D   25   2D   35  3D
RAX,RCX,RDX,RBX,RSP,RBP,RSI,RDI


« Last Edit: November 30, 2014, 08:34:29 PM by habran »
Cod-Father