Question & Answer: The code below uses the Space macro which simply displays the number of blank spaces specified by its argume…..

The code below uses the Space macro which simply displays the number of blank spaces specified by its argument. What is the first number printed to the screen after this code executes?

main PROC
push 3
push 15
call rcrsn
exit
main ENDP

rcrsn PROC
push ebp
mov ebp,esp
mov eax,[ebp + 12]
mov ebx,[ebp + 8]
cmp eax,ebx
jl recurse
jmp quit
recurse:
inc eax
push eax
push ebx
call rcrsn
mov eax,[ebp + 12]
call WriteDec
Space 2
quit:
pop ebp
ret 8
rcrsn ENDP

Expert Answer

 

Program screenshot:

Code to be copied:

Include Irvine32.inc

INCLUDE Macros.inc                         ;Include macros for space

.code

main proc

push 3                              ;Push 3 to the stack

push 15                             ;Push 15 to the stack

call rcrsn                           ;call the function

main endp                           ;end the main

rcrsn PROC                           ;define the function

push ebp                    ;push the ebp into stack

mov ebp,esp                 ;set ebp as frame pointer

mov eax,[ebp + 12]          ;This is for second parameter

mov ebx,[ebp + 8]           ;This is for first parameter

cmp eax,ebx                 ;compare the registers

jl recurse                  ;jump to another function

jmp quit                    ;call quit

recurse:                      ;Implement another function

inc eax                     ;increment count value

push eax                    ;push the eax value into stack

push ebx                    ;push ebx into stack

call rcrsn                  ;call above function

mov eax,[ebp + 12]          ;This is for second parameter

call WriteDec               ;write the value on the screen

mWritespace 2               ;Space macro print 2 spaces

 

quit:                         ;Implement quit function

pop ebp                     ;pop the pointer value from the stack

ret 8                      ;clean up the stack

rcrsn ENDP

end main

Still stressed from student homework?
Get quality assistance from academic writers!