Question: Computer science THIS IS Lab # 7 template FOR the assignment ; Lab # 7 template ( 2 0 2 4 Matthew W . Phillips
Computer science
THIS IS Lab #template FOR the assignment
; Lab #template Matthew WPhillips
section data
name db 'Student Name Here', xA ; TODO: Add your name inside the single quotes
len equ $ name ; dont delete
section bss
x resw ; Used for atoi dont delete
temp resb ; used for atoi dont delete
sresb ; used for itoa dont delete
; TODO: Add uninitialized data as needed
section text
global start
start:
; TODO: Call printname
; TODO: Get input buffer from keyboard ; Call input
; TODO: Convert input buffer into integer value; Call atoi
; TODO: Add to the value in integer value; Call add
; TODO: Convert value into ASCII string for printing; Call itoa
; TODO: print the buffer...; Call print
; TODO: Exit program; Call exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DON'T CHANGE ANYTHING BELOW THIS
LINE! ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
add:
add eax, ; Add to the value
ret ; return to caller
printname:
mov ecx, name ; set output buffer
mov edx, len ; set length
call print ; call subroutine
ret ; return to caller
print:
mov eax, ; syswrite
mov ebx, ; stdout
int x; system call
ret ; return to caller
input:
mov eax, ; sysread
mov ebx, ; stdin
int x; system call
ret ; return to caller
atoi:
mov ecx, eax ; transfer contents into a register we aren't otherwise using
ecx
xor eax, eax ; clear out previous bits
mov alcl ; move st byte of input to al register
sub al; convert ASCII to integer digit
mov bx; We are going to multiply by
mul bx ; ax axalbx
mov xax ; Store first part of integer into memory
xor eax, eax ; clear out previous bits
mov alch ; move nd byte of input to al register
sub al; convert ASCII to integer digit
mov bx; Multiply by for s column
mul bx ; ax axalbx
mov tempal ; Place al into temporary storage...
xor eax, eax ; clear out previous bits
mov eax, x; Place old value into eax to build on
add eax, temp; Add temporary value to this...
mov xeax ; Place back into x
xor eax, eax ; clear out previous bits
shr ecx, ; shift bytes to the right to reveal last twobytes of
register...
mov alcl ; move rd byte of input to al register
sub al; convert ASCII to integer digit
add eax, x; add x to this value...
ret ; return to caller
itoa:
xor dxdx ; Clear dx register prior to div operation always
mov bx; move divisor into bx for divisor
div bx ; ax ax bx
add ax; convert digit to ASCII
mov sbyte ax ; move byte to memory
mov axdx ; add remainder to ax
xor dxdx ; make sure to clear out the modulo register prior to repeat
use of div!
mov bx; set divisor as now
div bx ; ax ax bx
add ax; convert to ASCII
mov sbyte ax ; move byte to memory
add dx; convert to ASCII
mov sbyte dx ; move byte to memory
xor eax, eax ; clear out the reg.
mov eax, s; transfer for return value...
ret ; return to caller
exit:
mov eax,; sysexit
mov ebx,; exit is normal
int x; system call
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
