Hello, been playing around with MASM64 macros, I basically wanna automate this for loop:
non macro:
xor rcx, rcx
lea rdx, vectorarray
lea r8, phrase
loop01:
mov r9, sizeof(Vector)
imul r9, rcx
mov [rdx + r9].Vector._name, r8
mov [rdx + r9].Vector.id, cl
inc rcx
cmp rcx, N
jl loop01
Here's what currenly have (I mean, its not that bad, but I rather remove the labels):
lea r8, phrase
lea rdx, vectorarray
xor rcx, rcx
@@:
forloop Vector
mov [rdx + r9].Vector._name, r8
mov [rdx + r9].Vector.id, cl
forloopend N
jl @B
desired macro:
lea r8, phrase
lea rdx, vectorarray
xor rcx, rcx
forloop Vector
mov [rdx + r9].Vector._name, r8
mov [rdx + r9].Vector.id, cl
forloopend N
I was not able to connect the loop labels between two separate macros so any idea how to use the same label?
Here are my current macros:
forloop macro type_:req
; local loopstart
; lea reg, vectorarray
; lea r8, phrase
; xor rcx, rcx
; loopstart:
mov r9, sizeof(type_)
imul r9, rcx
; exitm <loopstart>
endm
forloopend macro len:req
; local loop01
; mov [reg + r9].type_._name, r8
; mov [reg + r9].type_.id, cl
inc rcx
cmp rcx, len
; jl loopname
endm
Hi maxirdax,
Can you check this thread?
https://masm32.com/board/index.php?topic=9378.0 (https://masm32.com/board/index.php?topic=9378.0)
Amazing! Thanks! That's one hell of a macro!