-
Notifications
You must be signed in to change notification settings - Fork 1
/
ProcTble.asm
executable file
·66 lines (56 loc) · 1.33 KB
/
ProcTble.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
TITLE Table of Procedure Offsets (ProcTble.asm)
; This progam contains a table with offsets of procedures.
; It uses the table to execute indirect procedure calls.
INCLUDE Irvine32.inc
.data
CaseTable BYTE 'A' ; lookup value
DWORD Process_A ; address of procedure
BYTE 'B'
DWORD Process_B
BYTE 'C'
DWORD Process_C
BYTE 'D'
DWORD Process_D
NumberOfEntries = 4
prompt BYTE "Press capital A,B,C,or D: ",0
msgA BYTE "Process_A",0
msgB BYTE "Process_B",0
msgC BYTE "Process_C",0
msgD BYTE "Process_D",0
.code
main PROC
mov edx,OFFSET prompt ; ask user for input
call WriteString
call ReadChar ; read one character
mov ebx,OFFSET CaseTable ; point EBX to the table
mov ecx,NumberOfEntries ; loop counter
L1:
cmp al,[ebx] ; match found?
jne L2 ; no: continue
call NEAR PTR [ebx + 1] ; yes: call the procedure
call WriteString ; display message
call Crlf
jmp L3 ; exit the search
L2:
add ebx,5 ; point to the next entry
loop L1 ; repeat until ECX = 0
L3:
exit
main ENDP
Process_A PROC
mov edx,OFFSET msgA
ret
Process_A ENDP
Process_B PROC
mov edx,OFFSET msgB
ret
Process_B ENDP
Process_C PROC
mov edx,OFFSET msgC
ret
Process_C ENDP
Process_D PROC
mov edx,OFFSET msgD
ret
Process_D ENDP
END main