Question: Topics: assembly & integer representation Goal: Determine what a given piece of assembly code is doing, annotate every line in the file, and update the

Topics: assembly & integer representation Goal: Determine what a given piece of assembly code is doing, annotate every line in the file, and update the labels to fit some narrative. Then, translate the assembly code into a small C program.

%include "asm_io.inc" segment .data ; ; initialized data is put in the data segment here ; SIZE_1 equ 255 SIZE_2 equ 100

; TODO: rename these labels so the fit your narrative greeting db " Greetings user!", 0 prompt1 db "Enter number #1: ", 0 prompt2 db "Enter number #2: ", 0 prompt3 db "Enter number #3: ", 0 prompt4 db "Enter number #4: ", 0 ending db " Answer: ", 0

segment .bss ; ; uninitialized data is put in the bss segment ; total resd 1

segment .text global asm_main asm_main: enter 0,0 ; setup routine pusha

; TODO: annotate every line of assembly ; CODE START mov eax, greeting call print_string call print_nl call print_nl

mov eax, [prompt1] call print_string call read_int mov [total], eax

mov eax, prompt2 call print_string call read_int add [total], eax

mov eax, prompt3 call print_string call read_int mov cx, eax imul ecx, SIZE_1 add [total], ecx

mov eax, prompt4 call print_string call read_int mov ecx, eax imul ecx, SIZE_2 add [total], ecx

call print_nl mov eax, ending call print_string mov eax, total call print_int

; CODE END popa mov eax, 0 ; return back to C leave ret

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 Databases Questions!