Can anyone explain me this asm code?

This is the code. Please, someone help me!

[code]
.data
CaseTable BYTE "A"
DWORD Process_A
EntrySize = ($ - CaseTable)
BYTE "B"
DWORD Process_B
BYTE "C"
DWORD Process_C
BYTE "D"
DWORD Process_D
NOE = ($ - CaseTable)
p BYTE "Inserisci A, B, C o D: ", 0
msgA BYTE "A pressed", 0
msgB BYTE "B pressed", 0
msgC BYTE "C pressed", 0
msgD BYTE "D pressed", 0
.code
MAIN PROC
mov edx, offset p
call WriteString
call ReadChar
mov ebx, offset CaseTable
mov ecx, NOE
l1:
cmp al, [ebx]
jne l2
call NEAR PTR[ebx + 1]
call WriteString
call Crlf
l2:
add ebx, EntrySize
loop l1
l3:
exit
MAIN ENDP

Process_A PROC
mov edx, offset msgA
ret
PA ENDP

Process_B PROC
mov edx, offset msgB
ret
PB ENDP

Process_C PROC
mov edx, offset msgC
ret
PC ENDP

Process_D PROC
mov edx, offset msgD
ret
PD ENDP
END MAIN[/code]

Comments

  • [color=Blue]The code asks the user to press a character A,B,C, or bloody D. Then code uses a table to map that character to an address of a subroutine and then calls that subroutine by its address. Then subroutine prints its text, which is: "process A", "process B", etc.[/color]
  • Thank a lot.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories