Re: Uniform spacing of labels in MASM32



Nicolo,

If what you need is easy to produce and fast lookup tables in a
procedure that you just pass a number to to end up in the right place,
there is a tool specific to this task in the masm32 project called

It generates the following type of output quick and easily.

;
«««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

align 4

default proc value:DWORD

.data
align 4
deftbl \
dd l0,l1,l2,l3,l4,l5,l6,l7
.code


mov eax, value
cmp eax, 7
ja error
jmp DWORD PTR [deftbl+eax*4]

align 4
error:
mov eax, -1
jmp quit_default

align 4
l0:
mov eax, 0
; replace what you like here at label 0
jmp quit_default

align 4
l1:
mov eax, 1
; replace what you like here at label 1
jmp quit_default

align 4
l2:
mov eax, 2
; replace what you like here at label 2
jmp quit_default

align 4
l3:
mov eax, 3
; replace what you like here at label 3
jmp quit_default

align 4
l4:
mov eax, 4
; replace what you like here at label 4
jmp quit_default

align 4
l5:
mov eax, 5
; replace what you like here at label 5
jmp quit_default

align 4
l6:
mov eax, 6
; replace what you like here at label 6
jmp quit_default

align 4
l7:
mov eax, 7
; replace what you like here at label 7
jmp quit_default

quit_default:


ret

default endp

;
«««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

Regards,

hutch at movsd dot com


.



Relevant Pages