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 #7template FOR the assignment
; Lab #7template (2024Matthew W.Phillips)
section .data
name db 'Student Name Here', 0xA ; TODO: Add your name inside the single quotes
len equ $ -name ; (don't delete)
section .bss
x resw 1; Used for atoi (don't delete)
temp resb 1; used for atoi (don't delete)
s3resb 3; used for itoa (don't delete)
; TODO: Add uninitialized data as needed
section .text
global _start
_start:
; TODO: Call print_name
; TODO: Get input buffer from keyboard (100-994); Call input
; TODO: Convert input buffer into integer value; Call atoi_3
; TODO: Add 5to the value in integer value; Call add_5
; TODO: Convert value into ASCII string for printing; Call itoa_3
; TODO: print the buffer...; Call print
; TODO: Exit program; Call exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DON'T CHANGE ANYTHING BELOW THIS
LINE! ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
add_5:
add eax, 5; Add 5to the value
ret ; return to caller
print_name:
mov ecx, name ; set output buffer
mov edx, len ; set length
call print ; call subroutine
ret ; return to caller
print:
mov eax, 4; sys_write
mov ebx, 1; stdout
int 0x80; system call
ret ; return to caller
input:
mov eax, 3; sys_read
mov ebx, 0; stdin
int 0x80; system call
ret ; return to caller
atoi_3:
mov ecx, eax ; transfer contents into a register we aren't otherwise using
(ecx)
xor eax, eax ; clear out previous bits
mov al,cl ; move 1st byte of input to al register
sub al,'0'; convert ASCII to integer digit
mov bx,100; We are going to multiply by 100
mul bx ; ax =ax(al)*bx
mov [x],ax ; Store first part of integer into memory
xor eax, eax ; clear out previous bits
mov al,ch ; move 2nd byte of input to al register
sub al,'0'; convert ASCII to integer digit
mov bx,10; Multiply by 10for 10's column
mul bx ; ax =ax(al)*bx
mov [temp],al ; 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 [x],eax ; Place back into "x"
xor eax, eax ; clear out previous bits
shr ecx, 16; shift 2-bytes to the right to reveal last two-bytes of
register...
mov al,cl ; move 3rd byte of input to al register
sub al,'0'; convert ASCII to integer digit
add eax, [x]; add x to this value...
ret ; return to caller
itoa_3:
xor dx,dx ; Clear dx register prior to div operation (always!)
mov bx,100; move divisor into bx for divisor
div bx ; ax =ax /bx
add ax,'0'; convert digit to ASCII
mov [s3],byte ax ; move byte to memory
mov ax,dx ; add remainder to ax...
xor dx,dx ; make sure to clear out the modulo register prior to repeat
use of div!
mov bx,10; set divisor as 10now...
div bx ; ax =ax /bx
add ax,'0'; convert to ASCII
mov [s3+1],byte ax ; move byte to memory
add dx,'0'; convert to ASCII
mov [s3+2],byte dx ; move byte to memory
xor eax, eax ; clear out the reg.
mov eax, [s3]; transfer for return value...
ret ; return to caller
exit:
mov eax,1; sys_exit
mov ebx,0; exit is normal
int 0x80; system call
Computer science THIS IS Lab # 7 template FOR the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!