Description
Computer Organization and
Programming
Lab Work 7
Dr. Zulkar Nine mnine@gsu.edu
Learning Objective
• Data Transfer,
• Arithmetic instructions with variables
Disclaimer
Attendance!
Lab Work 7 Instructions
Plan early …
• You have one week time to submit the lab
• Start early
• If you have issues
• Start working at the last moment is not a good idea.
• Appendix shows how to create a new project.
Implementing Arithmetic Expressions
• HLL compilers translate mathematical expressions into assembly language.
• You can do it also.
• For example: Do not permit Xval, Yval, or Zval to be modified
Rval = -Xval + (Yval – Zval)
.data
Rval SDWORD ?
Xval SDWORD 26
Yval SDWORD 30
Zval SDWORD 40 .code mov eax,Xval neg eax mov ebx,Yval
sub ebx,Zval add eax,ebx mov Rval,eax
7 ; EAX = -26
; EBX = -10
; -36
Implementing Arithmetic Expressions
• Translate the following expression into assembly language.
o Do not permit Xval, Yval, or Zval to be modified:
Previous Example:
Rval = -Xval + (Yval – Zval)
Rval = Xval – (-Yval + Zval)
o Assume that all values are signed doublewords.
mov ebx,Yval
.data
Rval SDWORD ?
Xval SDWORD 26
Yval SDWORD 30
Zval SDWORD 40 neg ebx add ebx,Zval
mov eax,Xval
sub eax,ebx
mov Rval,eax
8
Lab 7(a)
Expression evaluation
Submission
Submission Instruction
• Create a new application to run the following program.
• The data segment is provided:
.data
Val1 SWORD 23
Val2 SWORD -35
Val3 SDWORD 4
• Evaluate the following expression :
EBX = (-Val1 + val2) + (val3*3)
You can only use Mov, Movsz, Movzx, Add, Sub instructions.
• Build and run the program using the debugger
• Examine the content of the registers
Appendix
Create a Project
Step 1: Create a project (1)
(1) Start Visual Studio
(2) Click Create a new Project
Create a project (2)
(1) Select C++ as language
(2) Select Empty Project
(3) Click Next
Create a project (3)
(1) You can change the project name as you like
(1) Also, you can change the project location
(2) Click Next
Create a project (4)
Delete the
Following folders:
Header files
Resources Files, and
Source Files
Create a project (5)
To delete : Select the folders
Right click on it
Select delete
Create a project (6)
Select Project Name on solution explorer
Right click on it
Go to Build Dependencies
Click on Build Customizations
Create a project (7)
Select masm(.target, .props)
Click ok
Create a project (8)
Right click on the Project name in the solution explorer
Click properties
Create a project (9)
Expand the ‘Linker’
Select ’System’
Select Windows(/SUBSYSTEM:WINDOWS)
Click OK
Create a project (10)
Select Project name on solution explorer
Right click on it
Expand Add
Choose New Item
Create a project (11)
Select C++ File(.cpp)
Name: main.asm
Click Add
Create a project (12)
Select main.asm
Add your code
In the main.asm File.




Reviews
There are no reviews yet.