Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

National University of Computer and Emerging Sciences

Laboratory Manual
for

Computer Organization and Assembly Language

Instructor Uzair Tahir


Semester Fall 2019

Department of Computer Science


Problem(s) / Assignment(s)
Discussion & Practice Estimated completion time: 1 hr, 30 mins

Example 3.1: Assemble the given program and give Estimated completion time:20 mins
answers the questions given below.

1. Arrange the contents of memory location of D_VAR3 (variable) in memory?

Sr. Physical Address Content


1 0x01334003 67
2 0x01334004 45
3 0x01334005 23
4 0x01334006 01

2. What does the value of NUM1 indicates?


MUM1 is a double word variable. Its size in bits is 32. “$” point the current location on memory. So
NUM1 store the current address. Its value is 01334000.
3. In instruction MOV DX, WORD PTR D_VAR3, why is there need of PTR operator?
The size of D_var3 is DD mean it is of 32 bits. While Dx is of 16 bits. So we use PTR to reduce the size
of D_var3 and store it in DX.

4. Find out the offset address of W_VAR2 and COUNT from memory1?
The offset address of W_var2 is 00AD4001. As count is symbolic constant so it occupy no
memory. Its offset is unable to compute.

Example 3.2: Assemble the given program and give Estimated completion time:20 mins
answers the questions given below.

1. What is the value of BX register after instruction MOV BX, WORD PTR D_ARRAY3+1 and
give a brief explanation?
The value of bx is 3456. The data directive of array3 is dd. When we add array3+1 it move
byte next and start point 56. Bx is of 16 bits(2 bytes). We use ptr with data
directive of word so it move 3456 to bx.

2. After the execution of whole program write down the updated value of array NUM2 and
NUM1?
value of num1 is 0330.
Value of num2 is 340010.

Problem 3.1: Arithmetic Expression Estimated completion time:15 mins

Write a program that implements the following arithmetic


expression.

EAX = -val3 + 7 – val2 + val1

Use the following data definition:

val1 SDWORD 8
val2 SDWORD -15
val3 SDWORD 20

In comments next to each instruction, write the hexadecimal


value of EAX. Insert a “call DumpRegs” statement at the end
of the program.

include irvine32.inc

.data
val1 sdword 8
val2 sdword -15
val3 sdword 20

.code

main PROC
neg val3
mov eax,val3 ;FFFFFFEC
add eax,7 ;FFFFFFF3
sub eax,val2 ;00000002
add eax,val1 ;0000000A
exit
main endp
end main

Problem 3.2: Array Manipulation Estimated completion time:20 mins

Insert the following variables in your program:

.data
x

Write instructions that moves the four values in Uarray to the


EAX, EBX, ECX, EDX registers. When you follow this with a
call DumpRegs statement, the following register values should
display:

EAX=00001000 EBX=00002000 ECX=00003000


EDX=00004000

Next, write instructions that moves the four values in Sarray to


the EAX, EBX, ECX, EDX registers. When you follow this
with a call DumpRegs statement, the following register values
should display:

EAX=FFFFFFFF EBX=FFFFFFFE ECX=FFFFFFFD


EDX=FFFFFFFC
include irvine32.inc

.data
uarray WORD 1000h, 2000h, 3000h, 4000h
sarray SWORD -1, -2, -3, -4

.code

main PROC
jmp asad
asad1:
mov ax,uarray
mov bx,uarray+2
mov cx,uarray+4
mov dx,uarray+6
mov eax,-1
mov ebx,-1
mov ecx,-1
mov edx,-1
mov ax,sarray
mov bx,sarray+2
mov cx,sarray+4
mov dx,sarray+6
exit
asad:
mov eax,0
mov ebx,0
mov ecx,0
mov edx,0
jmp asad1
main endp
end main

You might also like