add get_ModRM

This commit is contained in:
andromeda
2026-03-11 20:14:13 +01:00
parent e6d7cb2f21
commit a84f2d7453

View File

@@ -320,6 +320,29 @@ get_tte_typed_metadata:
; ------------------------------------------------------------------------------
get_direct_addressing_ModRM:
mov dl, 11b
call get_ModRM
ret
; ------------------------------------------------------------------------------
; get_ModRM
;
; description:
; given 2 register tokens and the mod bits, returns the ModR/M byte
;
; parameters:
; di = token table entry `reg`
; si = token table entry `R/M`
; dl = lower 2 bits: mod bits. The rest is ignored
;
; returned:
; al = ModR/M byte; the rest of rax is zeroed
; ------------------------------------------------------------------------------
get_ModRM:
and dl, 11b ; mask for mod bits
shl dl, 6
; di = tte
call get_reg_bits
; al = reg bits
@@ -332,12 +355,12 @@ get_direct_addressing_ModRM:
call get_reg_bits
; al = reg bits
mov dl, al
mov cl, al
xor eax, eax
or al, 11b << 6 ; mod bits
or al, bl ; reg bits
or al, dl ; R/M bits
or al, dl ; mod bits
or al, bl ; reg bits
or al, cl ; R/M bits
and rax, 0xFF ; mask for byte
ret