You are on page 1of 4

ASSIGNMENT NO 2

Computer Organization and Assembly Language (COAL)

Course Instructor:
Ayesha Inam

Due date: 8 Oct 2021

Fall 2021

Department of Computer Science


FAST–National University of Computer &
Emerging Sciences Chiniot – Faisalabad
Campus

Guidelines:
❖ A single violation of guideline will lead to Zero mark in your assignment.
❖ You will have maximum marks if you have done the entire task.
❖ Only ".doc (or) .docx" file should be uploaded on Google Classroom, Assignment would
not be accepted via email, Facebook, or USB flash drive etc.
❖ Do not zip your assignment it should be uploaded as individual file in following
format. "RollNo_Assignment_No.doc"
❖ write any result corresponding to the statements
❖ Deadlines should be kept in mind no extension in assignment dates
❖ This is an individual assignment. PLAGARISM IS NOT ACCEPTABLE!
❖ Follow the instructions as it is, otherwise, your assignment would not be
accepted at all.

Note: for each line of code in each question you are required to provide detail of each line of
code in your own words that will depict how much you have understanding of all of these.
At each line of code, you are required to provide 2,3 lines explanation of that code
line/instruction in the form of comment. Zero marks will be awarded for any copy case or
if annotations aren’t provided.

Each Question carries 5 marks. (60 Marks)

Question no 1:
Explain why each of the following MOV statements are invalid:
.data bVal BYTE
100 bVal2 BYTE
? wVal WORD
2
dVal DWORD 5
.code
mov 45,45
mov 45,ds
mov esi,wVal
mov eip,dVal mov
25,bVal
mov bVal2,bVal

Question no 2:
Write a program that rearranges the values of three doubleword values in the following array as:
3, 1, 2.

Using indexed Operand


Using In Direct Addressing

Question no 3:
We want to write a program that adds the following three bytes:
.data
myBytes BYTE 80h,66h,0A5h, 60

What is your evaluation of the following code?


mov al,myBytes add
al,[myBytes]
add al,[myBytes+4]
What is your evaluation of the following code?
mov ax,myBytes
add ax,[myBytes+1]
add ax,[myBytes+2]

Question no 4:
Correct the following code snippest?
movzx ax,myBytes
mov bl,[myBytes+1]
add ax,bx
mov bl,[myBytes+2]
add ax,bx
Question no 5:
Determine the status of registers after the execution of each instruction
.code mov
bx,0A69Bh
movzx eax,bx
movzx edx,bl
movzx cx,bl

Question no 6:
Determine the status of registers after the execution of each instruction
.code mov
bx,0D87Bh
movsx eax,bx
movsx edx,bl
mov bl,7Bh
movsx cx,bl

Question no 7:
Determine the status of registers after the execution of each instruction
.data
val1 DW 800h
val2 DW 500h
.code
mov ax,val1
xchg ax,val2 mov
val1,ax

Question no 8:
Determine the status of registers after the execution of each instruction
.data
arrayB DB 88h,20h,30h,40h,55h
.code
mov al,arrayB
mov al,[arrayB+1] mov
al,[arrayB+2]

Question no 9:
Determine the status of registers after the execution of each instruction
.data
arrayD DD 10000h,20000h
.code
mov eax,arrayD
mov eax,[arrayD+4]
mov eax,[arrayD+4]

Question no 10:
Translate the following expression into assembly language. Do not permit Xval, Yval, or Zval to
be modified:

Rval = (- Xval – (-(-Yval + Zval)) + Xval ) - Yval

Question no 11:

1) Declare an uninitialized array of 50 signed doublewords named dArray.

2) Declare a string variable containing the word “TEST” repeated 500 times.

3) Declare an array of 20 unsigned bytes named bArray and initialize all elements to zero

4) Converting from Big Endian to Little Endian (5 Points) Write a program that uses the
variables below and MOV instructions to copy the value from bigEndian to littleEndian,
reversing the order of the bytes. The number’s 32-bit value is understood to be 12345678
hexadecimal.
.data bigEndian BYTE 12h,34h,56h,78h littleEndian
DWORD?

You might also like