In: Computer Science
Assembly language: please comment on every line of code explaining each part. include head comments describing what your program does.
Assignment 3A - A program that adds and subtracts 32-bit
numbers
After installing the assembler on the computer, enter the following
program, save it, assemble it and run it. Do not forget to add a
comment with your name in it.
You will hand in a listing (e.g., addsum.asm) that should include
your name
________________________________________
TITLE Add and Subtract (AddSum.asm)
;This program adds and subtracts 32-bit integers
; Jonathan Borda
INCLUDE Irvine32.inc
.code
main PROC
mov eax, 10000h ; EAX =
10000h
add eax, 40000h ; EAX =
50000h
sub eax, 20000h ; EAX =
30000h
call DumpRegs ; display
registers
exit
main ENDP
END main
I hope this what you want. I have explained everything. if you still have any doubt please let me know.
--------------------------------------------------------------------------------------------------------CODE----------------------------------------------------
TITLE Add and Subtract (AddSum.asm)
;This program adds and subtracts 32-bit integer
;------------------your Name-----------------------
INCLUDE Irvine32.inc ; include directives brings the necessary definition and macros into program for execution of program, from Irvine32.inc
.code ; This is code Segment. There are 3 segment 1)code 2) data
3) stack. Code segment contains instructions that are to be
executed.
main PROC ; beginning of a main procedure
MOV EAX,10000H ;EAX=10000H This statements moves the 10000h into EAX register over here EAX is destination register and 10000h is source operand
ADD EAX,40000H ;EAX=50000H This add instructions add the content of EAX register with 40000h source operand and result is stored in EAX register which is 50000H
SUB EAX,20000H ;EAX=30000H This subtract instruction subtract the value of Source operand from EAX register and stores the value in EAX register
CALL DumpRegs ; This instruction calls a procedure
(defines in Irvine32) DumpRegs which displays the value of CPU
Register
exit ; It is a macro defined in Irvine32. That
represents an end of a program.
main ENDP ; This ENDP represents end of procedure over here it
is main
END main ;END represents End of Program After word the main
represent a procedure name Entry point in the program from where
execution of program begins. This is optional part.