; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
include \masm32\include64\masm64rt.inc
.code
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
entry_point proc
; ---------------------------------------------
; test piece feeds numbers ranging from 1 to 6
; and rejects any other, return is the address
; of a string accessed by the number passed or
; if out of range, an error message is returned
; ---------------------------------------------
LOCAL pstr :QWORD
LOCAL cntr :QWORD
mov cntr, -1
@@:
add cntr, 1
mov pstr, rv(blockif,cntr)
conout str$(cntr),":",pstr,lf
cmp cntr, 7
jne @B
conout chr$(13,10)
waitkey "Press any key ...."
.exit
entry_point endp
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
; -----------------------------------------
; MACRO allows the initialised data section
; to be used without naming conflists as
; names are unique using MACRO locals
; -----------------------------------------
blkif@@@@ MACRO
LOCAL wd0,wd1,wd2,wd3,wd4,wd5,wd6,tabl,perr
cmp rcx, 6 ; anything from 7 to -1
cmova rcx, perr ; if rcx > 6, mov 0 to it
lea rdx, tabl ; load table address
mov rax, QWORD PTR [rdx+rcx*8] ; return table value
ret
.data
wd0 db " out of range",0
wd1 db " one",0
wd2 db " two",0
wd3 db " three",0
wd4 db " four",0
wd5 db " five",0
wd6 db " six",0
align 8
tabl dq wd0,wd1,wd2,wd3,wd4,wd5,wd6
perr dq 0
.code
ENDM
; -------------------------------------
; proc will accept numbers ranging from
; 1 to 6 amd will reject any other
; -------------------------------------
NOSTACKFRAME
blockif proc
blkif@@@@ ; macro contains the code
blockif endp
STACKFRAME
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
end