Question: Using Assembly to compute the following expression: ans = 4*((x-1)+2*(y-t)) - 3*(z-10) (Do not change the data section) ;;; describe what the program does here
Using Assembly to compute the following expression:
ans = 4*((x-1)+2*(y-t)) - 3*(z-10)
(Do not change the data section)
;;; describe what the program does here ;;; explain how to assemble and run it here extern _printDec extern _printInt extern _printString extern _println extern _getInput section .data prompt db "> " promptLen equ $-prompt ansStr db "ans = " ansStrLen equ $-ansStr ;;; declare 5 16-bit short ints x dw 0 y dw 0 z dw 0 t dw 0 ans dw 0 section .text global _start _start: ;; display prompt mov ecx, prompt mov edx, promptLen call _printString ;; get x call _getInput mov word[x], ax ;; display prompt mov ecx, prompt mov edx, promptLen call _printString ;; get y call _getInput mov word[y], ax ;; display prompt mov ecx, prompt mov edx, promptLen call _printString ;; get z call _getInput mov word[z], ax ;; display prompt mov ecx, prompt mov edx, promptLen call _printString ;; get t call _getInput mov word[t], ax ;; ----------------------------------- ;; computation: ans = 4*((x-1)+2*(y-t)) - 3*(x-10) ;; ----------------------------------- ; CODE GOES HERE... ;; ----------------------------------- ;; display "ans = " ;; ----------------------------------- mov ecx, ansStr mov edx, ansStrLen call _printString ;; ----------------------------------- ;; display ans variable ;; ----------------------------------- mov eax, 0 mov ax, word[ans] call _printInt call _println call _println ;;; exit mov ebx, 0 mov eax, 1 int 0x80
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
