0% found this document useful (1 vote)
15 views

Assignment 1 COAL

The document outlines Assignment #1 for a Computer Organization and Assembly Language course, detailing instructions for students to convert their 4-digit ID into various hexadecimal representations and perform arithmetic operations while updating flags. It includes multiple questions that require calculations related to memory address space, segment registers, and data declarations, along with specific coding tasks. Students are advised against plagiarism and must replace highlighted data declarations with their own ID-related values.

Uploaded by

Mahnoor mehmood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
15 views

Assignment 1 COAL

The document outlines Assignment #1 for a Computer Organization and Assembly Language course, detailing instructions for students to convert their 4-digit ID into various hexadecimal representations and perform arithmetic operations while updating flags. It includes multiple questions that require calculations related to memory address space, segment registers, and data declarations, along with specific coding tasks. Students are advised against plagiarism and must replace highlighted data declarations with their own ID-related values.

Uploaded by

Mahnoor mehmood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

ASSIGNMENT #1

COMPUTER ORGANIZATION &


ASSEMBY LANGUAGE (EE-2003)
Course Instructors: Mr. Shahbaz Hassan, Miss Farheen Tabassum, Miss Ummarha Qassem

ID: NAME: SECTION:

Read the Instructions Carefully


❖ Assignments are designed for your learning. Copying will lead to plagiarism.
❖ Data Declarations highlighted in yellow must be replaced as instructed.

✓ Convert your 4-digit ID to two bytes IDB1 and IDB2 both should be in HEX. First two digits
of your ID will replace IDB1 and Last two will replace IDB2 in the assignment.
✓ Convert your 4-digit ID to two bytes IDB3 and IDB4 both should be in HEX. First and third
digits of your ID will replace IDB3 and second and fourth digit will replace IDB4 in the
assignment.
✓ Convert your 4-digit ID to a WORD in HEX and replace IDW in assignment with your 4-
digit ID in HEX.
✓ Concatenate your ID with your ID to create a 8-digit Double WORD in HEX and replace
IDD in assignment with 8-digit ID.
✓ F 1 F 2 F 3 F 4 in assignment must be replaced with first four character
your FIRST Name where FN1 is first character of your first name, FN2 is second character,
FN3 is third character and FN4 is fourth character.
✓ S 1 S 2 S 3 S 4 in assignment must be replaced with first four character
your Second Name where SN1 is first character of your second name, SN2 is second
character, SN3 is third character and SN4 is fourth character.
Assignment 1
Computer Organization and Assembly Language

Question # 01 Perform each of the following operations on these numbers and update the
answer and value of flags after performing the arithmetic. Perform all the steps in the
“calculation” box, only filling the answer will not get any credit.
1. AFFDh + <IDB2 +6, IDB3 +4, IDB4 +6, IDB1> d
Answer Calculation
Sign
Zero
Flags Carry
Overflow
Aux
Carry
Parity

2. 876Fh + <IDB2, IDB1, IDB4, IDB3+2 >h


Answer Calculation
Sign
Zero
Flags
Carry
Overflow
Aux
Carry
Parity

3. <IDB2, IDB3, IDB4, IDB1+3>d – 7E0Eh

Answer
Calculation
Sign
Zero
Flags
Carry
Overflow
Aux Carry
Parity

2|Page
Assignment 1
Computer Organization and Assembly Language

4. 4785d + <IDB2 +4, IDB1-1, IDB2+1, IDB3> h


Answer Calculation
Sign
Zero
Flags
Carry
Overflow
Aux Carry
Parity

5. 67EBh + <IDB1 +3, IDB2+2, IDB2, IDB1+5>h

Answer Calculation
Sign
Zero
Flags
Carry
Overflow
Aux Carry
Parity

6. EFB2h – <IDB1 +5, IDB1, IDB4+5, IDB3+6>h


Answer Calculation
Sign
Zero
Flags
Carry
Overflow
Aux Carry
Parity

7. 8100d + <IDB2, IDB1, IDB3+ 3, IDB3> d


Answer Calculation
Sign
Zero
Flags
Carry
Overflow
Aux Carry
Parity

3|Page
Assignment 1
Computer Organization and Assembly Language

8. FEEEh + <IDB1 +2, IDB4, IDB1, IDB3>h


Answer Calculation
Sign
Zero
Flags
Carry
Overflow
Aux Carry
Parity

4|Page
Assignment 1
Computer Organization and Assembly Language

Question#2: Calculate Memory Address Space

Given a main memory of IDB2 MB, compute the following:


a): Convert your 4 digit ID into IDB1, IDB2, IDB3, IDB4 and IDW as per the rules above
b): Calculate the total number of addressable memory locations in bytes
c): Determine the minimum number of address lines required to address the full memory space
d): If the starting address of memory is IDW X 100H, calculate the starting and las address of main
memory

5|Page
Assignment 1
Computer Organization and Assembly Language

Question # 3:
A 16bit 8086 processor uses segment offset addressing to access memory. Each student must use their
4 digit ID to drive key value for segment registers and memory addressing.

Identifier Rule Applied Hex Value for ID


IDB1 First two digits =
IDB2 Last two digits =
IDB3 First and third digits =
IDB4 Second and fourth digits =
IDW Full 4 Digits ID =

You are given the following Segment Registers derived from your Student ID
Segment Base Address
Code Segment IDB1 IDB2 H
Data Segment IDB3 IDB4 H
Stack Segment IDW H
Extra Segment IDB2 IDB1 H

1. You are required to compute the physical address of each segment


2. If the stack Segment is set to IDW H , find the offset required to access Physical Address= 49250H
3. If the Extra Segment ES = IDB2 IDB1 H needs to access Physical Address = 503F0H, determine the
offset.
4. A program instruction is located at Physical address 24510H. If the code Segment (CS) = IDB1 IDB2
H, Compute the Instruction Pointer (IP)

6|Page
Assignment 1
Computer Organization and Assembly Language

Question#4: Calculate Memory Address Space

Given a main memory of IDB3 GB, compute the following:


a): Calculate the Start and Last address of the given memory.
b): Calculate the Start and Last Address of Code Segment
c): Calculate the Start and Last Address of Data Segment
d): Calculate the Start and Last Address of Stack Segment
c): Calculate the Start and Last Address of Extra Segment

7|Page
Assignment 1
Computer Organization and Assembly Language
Question#5: Memory Management
1. Consider the following Data declaration? Fill given Memory and register value? Look for
errors if any.

DATA
.data
list1 BYTE 4,idb1
list2 BYTE 3 DUP(2, IDb2)
list3 DB 2 DUP(o,1,’ FN1’)
list4 BYTE 2 DUP(‘FIRST NAME’)
list5 BYTE 3 D U P ('AB')

CODE REGISTER
.code
main Proc EDI
mov edi,Offset list1
mov al, List2+2 AL
mov bl, List3+4 BL
mov cl, List4+3
mov dl, List5+3 CL
DL
main ENDP
AH
E D main BH
CH
MEMORY

0 1 2 3 4 5 6 7 8 9 A B C D E F
4000
4010
4020
4030
4040
2. Consider the following Data declaration? Fill given Memory and register value? Look for
errors if any.

8|Page
Assignment 1
Computer Organization and Assembly Language

DATA
.data
word1 DW 1
word2 DW -1
word3 SWORD -1
word4 SWORD +1
word5 DW 'AB'
word6 DW 'ABC'
List1 WORD 01F2BH,01101011001011b, 45
list2 DW IDW,2
list3 WORD 3 DUP(0)
list4 WORD 2 DUP(0AB12H)
list5 DW 2 DUP(IDW)
list6 DW 3 DUP('AB')

CODE REGISTER
.code
main Proc EDI
mov edi,Offset list1
mov al, word1 AL
mov bx, List1+4 BX
mov cx, List2+1
mov dx, List4+2 CX
mov ax, List6+1 DX
mov bx, word6+2
mov cx, word5+2
AX
mov cx, word5+4 BX
Main E DP CX
E D main
DX
MEMORY

0 1 2 3 4 5 6 7 8 9 A B C D E F
4000
4010
4020
4030
4040

9|Page
Assignment 1
Computer Organization and Assembly Language

3. Consider the following Data declaration? Fill given Memory and register value? Look for
errors if any.

DATA
.data
dword1 DD 1
dword2 DD -1
dword3 DWORD -1
dword4 DWORD +1
dword5 DD 'AB'
dword6 DD 'ABCD'
List1 DWORD 012345678H,0011010011101011001011b,65
list4 DWORD 2 DUP(0AB123456H)
CODE REGISTER
.code
main Proc EDI
mov edi,Offset dword1
mov ebx, dword2 EAL
mov ecx, dword5 EBX
mov edx, dword6
mov eax, List1+4 ECX
mov ebx, list4+2 EDX
mov ecx, List1+8
mov ecx, word5+4
EAX
main E DP EBX
E D main ECX
EDX
MEMORY

0 1 2 3 4 5 6 7 8 9 A B C D E F
4000
4010
4020
4030

10 | P a g e
Assignment 1
Computer Organization and Assembly Language

4. Declare Data in following order and store it in memory?

Your Name in Capital Letters: As String


Your Name in Small Letters: As String
Your ID in HEX: using Declaration type as WORD
Your ID in HEX: using Declaration type as DWORD
Your ID in BIN: using Declaration type as WORD
Your ID in BIN: using Declaration type as DWORD
Your ID in DEC: using Declaration type as WORD
Your ID in DEC: using Declaration type as DWORD
Your Age in BIN: using Declaration type as BYTE
Your Age in DEC: using Declaration type as BYTE
Your Age in BIN: using Declaration type as BYTE
Your CNIC in HEX: using Declaration as QWORD (Ignore – in your ID CARD Number)

.data

11 | P a g e
Assignment 1
Computer Organization and Assembly Language

5. Consider the following Data declaration? Fill given Memory and register value? Look for
errors if any.

DATA
.data
bval1 BYTE 16
bv2 BYTE -16
wval WORD 0
CODE REGISTER
.code
main Proc BX
movsx bx,al
movsx cx,bv2 CX
movsx eax,bv2 EAX
movsx ebx,bval1
movzx ecx,bv2 EBX
movzx edx,bval1 ECX
main E DP EDX
E D main
MEMORY

0 1 2 3 4 5 6 7 8 9 A B C D E F
4000

6. Consider the following Data declaration? Fill given Memory and register value after the
code execution? Look for errors if any.

DATA
.data
bval1 BYTE 5
bval2 BYTE 7
wval1 WORD 0ABCDH
wval2 word 01234h

CODE REGISTER
12 | P a g e
Assignment 1
Computer Organization and Assembly Language

.code
main Proc EDI
mov ax,@data
mov ds,ax AH
mov al,bval1 BH
mov bl,bval2
xchg al,bl ; CX
mov bval1,bl DH
mov bval2,al
mov cx,wval1
DL
xchg cx,wval2 ESI
mov wval2,cx
main E DP
E D main
MEMORY

0 1 2 3 4 5 6 7 8 9 A B C D E F
4000

7. Consider the following Data declaration? Fill given Memory and register value? Look for
errors if any.

DATA
.data
bary BYTE 0ABh,045O,IDb2,25T,IDb1
wary WORD IDW,3456O,IDb2,IDb1,'cd'
Dary dd IDD,'ABcd','S 1S 2S 3S 4',0AB12CD34h
Qary dq 12345678abcdefh,'AbCd'
CODE
.code
AL
main Proc
mov al,bary BL
mov bl,bary+1 CL
mov cl,bary+2
mov dl,bary+3 DL
AX
mov ax,wary BX

13 | P a g e
Assignment 1
Computer Organization and Assembly Language

mov bx,wary+2 CX
mov cx,wary+6
mov dx,wary+12 DX
EAX
mov eax,dary+4
mov ebx,wary+8 EBX
mov ecx,wary+00CF ECX
mov edx,wary EDX

main E DP
E D main

8. Consider the following Data declaration? Fill given Memory and register value? Look for
errors if any.

DATA
.data
bary BYTE 0ABh,045O,IDb2,25T,IDb1
wary WORD IDW,3456O,IDb2,IDb1,'cd'
Dary dd IDD,'ABcd','S 1S 2S 3S 4',0AB12CD34h
Qary dq 12345678abcdefh,'AbCd'
CODE
.code
ESI
main Proc
mov esi, OFFSET bary EDI
mov edi, OFFSET pary ESI
mov esi, OFFSET wary
mov edi, OFFSET wary+2 EDI
mov esi, OFFSET qary ESI

main E DP
E D main

14 | P a g e
Assignment 1
Computer Organization and Assembly Language

9. Consider the following Data declaration? Fill the registers value? Look for errors if any.

DATA
.data
bval1 DB 034h, IDb1
wval2 DW IDW
dval3 DD IDD

CODE
.code
main Proc ESI
mov esi,OFFSET bval1
mov ax, WORD PTR bval1 AX
mov al, BYTE PTR wval2 AL
mov bx, WORD PTR dval3
mov cx, WORD PTR [dval3+2] BX
CX
main E DP
E D main

10. Consider the following Data declaration? Fill given registers value. Look for errors if any.

DATA
.data
bval1 DB ‘F 1’
wval2 DW 0ABCDH,’F 1’
dval3 DD IDD
qval4 QWORD 01243567812435678H
tval5 tbyte -1

CODE
.code
main Proc AL
mov al, TYPE bval1
mov bl, TYPE wval2 BL
mov cl, TYPE dval3 CL
mov dl, TYPE qval4
mov ah, TYPE tval5 DL
main E DP AH
E D main

11. Consider the following Data declaration? Fill given registers value. Look for errors if any.

15 | P a g e
Assignment 1
Computer Organization and Assembly Language

DATA
.data
bAry BYTE 010H,020h,030H
wAry WORD 5 DUP(o),0 ,0
string1 BYTE 0FFH,0FFH
dAry DWORD 2 DUP(3 DUP(0)),0
string2 BYTE 'ABCDEFGHIJKLM OflQRSTUVWXYZ',0
bAry2 BYTE 1,2,3,
4,5,6
BYte 4,5,6
r dq 2 dup(5),2 dup('abcd')
CODE
.code
main Proc BL
mov bl, LE GTHOF bAry
mov cl, LE GTHOF wAry CL
mov dl, LE GTHOF dAry DL
mov ah, LE GTHOF string2
mov al, LE GTHOF bAry2 AH
mov bl, LE GTHOF r AL
main E DP
E D main BL

12. Consider the following Data declaration? Fill given registers value. Look for errors if any.

DATA
.data
bAry BYTE 010H,020h,030H
wAry WORD 5 DUP(o),0 ,0
string1 BYTE 0FFH,0FFH
dAry DWORD 2 DUP(3 DUfl(0)),0
string2 BYTE 'ABCDEFGHIJKLM OflQRSTUVWXYZ',0
r dq 2 dup(5),2 dup('abcd')
CODE
.code
main Proc BL
mov bl, SIZEOF bAry
mov cl, SIZEOF wAry CL
mov dl, SIZEOF dAry DL
mov ah, SIZEOF string1
mov al, SIZEOF string2 AH
mov bl, SIZEOF r BH

16 | P a g e
Assignment 1
Computer Organization and Assembly Language

main E DP AL
E D main
BL
13. Consider the following Data declaration? Fill given registers value. Look for errors if any.

DATA
.data
valb LABEL DB
valw LABEL WORD
vald LABEL DWORD
valq LABEL QWORD
valt Tbyte 12345678abcdef123456h
CODE
.code
main Proc AL
mov al,valb
mov bx,valw BX
mov ecx,vald ECX
main E DP
E D main

14. Consider the following Data declaration? Fill given registers value. Look for errors if any.

DATA
.data
Ary1 BYTE F 1,2, IDb2
ary2 WORD S 1,05678h, IDW

CODE
.code
main Proc AL
mov ESI, OFFSET Ary1
mov al,[ESI] BL
add ESI,1 CL
mov bl,[ESI]
inc ESI AX
inc BYTE PTR [ESI] BX
mov cl,[ESI]
CX
mov ESI, OFFSET Ary2
mov ax,[ESI]

17 | P a g e
Assignment 1
Computer Organization and Assembly Language

add ESI,2
mov bx,[ESI]
inc ESI
inc ESI
inc WORD PTR [ESI]
mov cx,[ESI]
main E DP
E D main

15. Consider the following Data declaration? Fill given registers value. Look for errors if any.

DATA
.data
Ary1 BYTE F 1,2, IDb2,4
ary2 WORD S 1,05678h, IDW,567o
ary3 DWORD S 2,012345678h, IDD,567o

CODE
.code
main Proc AL
mov ESI,0
mov al,ary1[ESI] BL
mov ESI,1 * TYPE ary2 CL
mov bl,ary1[ESI]
mov ESI,2 * TYPE ary2 AX
mov cl,ary1[ESI] BX
mov ESI,0 CX
mov ax,ary2[ESI] EAX
mov ESI,1 * TYPE ary2
mov bx,ary2[ESI]
EBX
mov ESI,2 * TYPE ary2 ECX
mov cx,ary[ESI]

mov ESI,0
mov eax,ary3[ESI]
mov ESI,1 * TYPE ary3
mov ebx,ary3[ESI]
mov ESI,2 * TYPE ary3
mov ecx,ary3[ESI]
main E DP
E D main

18 | P a g e
Assignment 1
Computer Organization and Assembly Language

16. Consider the following Data declaration? Fill given registers value. Look for errors if any.

DATA
.data
ary2 WORD S 1,05678h, IDW,567o

CODE
.code
main Proc AX
mov ESI,0
mov ax,ary[ESI * TYPE ary2] BX
I C ESI CX
mov BX,ary[ESI * TYPE ary2]
I C ESI
mov CX,ary[ESI * TYPE ary2]
I C ESI

main E DP
E D main

19 | P a g e
Assignment 1
Computer Organization and Assembly Language

Question no 17: Convert the following C++ code into Assembly language

#include <iostream>

using namespace std;

int main() {
int a = 9, b = 15;
int max;

if (a > b)
max = a;
else
max = b;

cout << "Maximum: " << max << endl;


return 0;
}

Best of Luck

20 | P a g e

You might also like