Question: Computer science Custom subroutine example # 4 section . bss temp resb 1 ; used by atoi _ 2 res resb 2 ; used by
Computer science
Custom subroutine example #
section bss
temp resb ; used by atoi
res resb ; used by itoa
val resb
section text
global start
start:
mov eax, ; place input into eax register
call atoi; call the subroutine
mov val eax; place return value into "val"
mov eax, val
call printitoa
call exit
atoi:
xor ecx, ecx ; zero out reg.
mov ecx, eax ; Transfer to a register not being used
xor eax, eax ; Zero out the eax reg.
mov al cl ; place st character into bit register
sub al ; remove ASCII offset to reveal integer digit
mov bx; place into bx for future multiplication
mul bx ; ax ax bx recall that al is lowest bits of ax so they hold the same value in this case
mov temp ax ; store total so far into temp
xor eax, eax; zero out reg.
mov al ch ; place nd character into bit register
sub al; remove ASCII offset again...
add eax, temp; add the temp. reg. value
ret ; return to caller
printitoa:
mov bx
div bx
add ax
mov res byte ax
add dx
mov res byte dx
xor eax, eax
xor edx, edx
mov ecx, res
mov edx,
call print
ret
print:
mov eax,
mov ebx,
int x
ret
exit:
mov eax,
mov ebx,
int x
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
