Assembly Language Homework, programming homework help

Hello, I need someone to help finish this homework. please, before begin with my homework, I want you to read my homework very well especially the three red stars. And, if you would like use comment in the program or word program to insert table with three rows ( what is the command ) , ( what is the register ) , ( what is in the memory) and all of them need to be fill for each command. the program that we use it for our book was visual studio in 32-bit.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

I uploaded with my homework, the picture of the book and the pictures of the pages 40 and 41.

please, if you have any question before beginning in my homework, ask me. Thanks

Modify the sample program located on page 40 to add two numbers stored in memory at number1 and
number2. (Hint: Copy number1 to EAX and then use add eax, number2 to add the second number.)
Continue to store the total in memory at sum. Assemble, link and execute the program. Explain the
changes that are displayed in registers and memory after execution of each instruction. THIS MUST BE A
DETAILED EXPLAINATION. IT IS WORTH 5 OF THE 10 POINTS.
tate-
can
nger
Add the following comments to the beginning of the program.
Name:
Your Name
Class and Section: CS 245 02
Assignment:
Program Assignment 01
Due Date:
See above
Date Turned in:
Program Description: You write a short description of what the program will do
e is
nts
cu-
nt
When you complete the program, do the following.
1. Create a folder with the following name: Assignment01
2. Copy and paste your program into Notepad or Notepad++ and save it to the folder with a .txt
extension.
3. Copy the folder to your folder in the I:\kopp\inbox\CS 245 02 folder
4. Print a copy of the source code and turn it in.
V
Extra Credit – 5 points
Modify the program above to subtract 1000 from the value you have after adding number1 and
number2. (Hint: you need to do this after you store the total into sum so you don’t lose that value
before you subtract.) Store this new value in memory at diff. Assemble, link and execute the program.
Explain the changes that are displayed in registers and memory after execution of each instruction. THIS
MUST BE A DETAILED EXPLAINATION.
r
a
te
tel
anc
tell:
the
te comments or explaination in table: –
For example!
Command
Register
MOV
nubet, number Sun
memory
stor
1
a da
11
mem
1-16
0000
ΤΙ
instru
and til
assem
names
sauti main on the PROC and END directives
peuttuure. In the console32 environment (described in Section 3.2), you must
call your procedure main.
I LIIC
INTRODUCTION TO
8
80×86
Assembly Language
and Computer
Architecture
THIRD EDITION
-1101010101010010100T
01010110110111101001101001000101010
1000110100101010100001010110111001010010101110001000
01001010111011001000010110011110111001110111
J100111001001011010010010000100001001111001010011011000010100101010
00101011011100101001010111000100010100101010110001000101010001111001010
111000101000110110 mag 1001000111100100011001100111111000001110100
101010011100100101
1100101001101100001010010101011010001IONS
QT00010100101010110100011010010101010000 UTO!
000010101101110.
2010gigolo10101010101001011101100700011100016
11010010101010000
11100101001010 tri
di 1109010001010011101011
Teor10010010007
10000101011)
SU 020101101000
120101101001
3 00010101
10100
ondon
000001070UM200 Biuro Horo
OTTOBOT01010012
11000 TO ROODT TOTS
00011
4101010
RICHARD C. DETMER
40
CHAPTER 3 | Elements of Assembly Language
com
3.1 Assembly Language Statements
An assembly language source code file consists of a collection of statements. Most state-
ments fit easily on an 80-character line, a good limit to observe so that source code can
easily be printed or displayed in a window. However, the assembler allows much longer
statements; these can be extended over more than one physical line using backslash (1)
characters at the end of each line except the last.
Figure 3.1 shows a short but complete assembly language program. This example is
used here and in the next section of this chapter to illustrate basic assembly statements
and the mechanics of editing, assembling, linking, and executing a program with execu-
tion under the control of the debugger.
Because assembly language programs are far from self-documenting, it is important
to use an adequate number of comments. A comment can be used on any line. A semi-
colon (;) begins the comment, and the comment then extends until the end of the line.
An entire line is a comment if the semicolon is in column 1, or a comment can follow
; Example assembly language program
; adds 158 to number in memory
; Author: R. Detmer
; Date: 6/2013
.586
.MODEL FLAT
.STACK 4096
; reserve 4096-byte stack
DATA
i reserve storage for data
number DWORD
-105
sum
DWORD
?
. CODE
; start of main program code
main
PROC
mov
eax, number
add
; first number to EAX
; add 158
eax, 158
mov
sum, eax
; sum to memory
mov
eax, 0
; exit with return code 0
ret
main
ENDP
END
Figure 3.1
Example assembly language program
3.1 Assembly Language Statements
41
te-
can
ser
working parts of a statement. Our example has comments on most lines. As important as
they are for the human reader, comments are ignored by the assembler.
There are three types of functional assembly language statements: instructions, direc-
tives, and macros. An instruction is translated by the assembler into 1 or more bytes of
object code (machine code) that is executed at run time. Each instruction corresponds to
one of the operations that the 80×86 CPU can perform. Our program has five instruc-
tions:
(1)
is
its
mov
eax, number
add
eax, 158
mov
sum,
eax
at
i-
mov
eax, O
ret
e.
The first of these instructions copies the doubleword in memory at the location iden-
tified by number to the EAX register in the CPU. The second adds a doubleword rep-
resentation of 158 to the current doubleword in the EAX register. The third copies the
doubleword in the EAX register to the doubleword in memory identified by sum. The
last two instructions exit to the operating system. Much of this text describes the formats
and uses of 80×86 instructions.
A directive tells the assembler to take some action. Such an action generally does not
result in machine instructions and may or may not cause object code to be generated. In
our example program, the directive
.586
tells the assembler to recognize 80×86 instructions that use 32-bit operands. The directive
. MODEL FLAT
tells the assembler to generate code for flat memory model execution. These directives
and many others start with a period, but others do not.
Our example program contains several other directives. The directive .STACK 4096
tells the assembler to generate a request to the operating system to reserve 4096 bytes for
the system stack. The system stack is used at execution time for procedure calls and local
storage. A stack containing 4096 bytes is large enough for most programs.
The .DATA directive tells the assembler that data items are about to be defined in
a data segment. Each DWORD directive tells the assembler to reserve a doubleword of
memory for data, the first identified with the label number and initialized to FFFFFF97
(-10510), the second identified with the label sum and given the default initial value of
00000000. Section 3.3 provides additional information about data definition directives.
The .CODE directive tells the assembler that the next statements are executable
instructions in a code section. The PROC directive marks the beginning of a procedure
and the ENDP directive the end of a procedure. The END directive on the last line tells the
assembler to stop assembling statements. The label main on the PROC and END directives
names the procedure. In the console32 environment (described in Section 3.2), you must
call
your procedure main.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper
Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER