News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

mrip2rax MACRO

Started by habran, November 24, 2014, 07:14:30 AM

Previous topic - Next topic

habran

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

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:

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


Cod-Father