You are on page 1of 2

COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE

ASSIGNMENT#2 (FALL 2023)


ID: i22-1154 NAME: Hania Aamer SECTION: F
Read the Instructions Carefully

 Understanding of the questions is also a part of this assignment.


 You are required to solve the assignment on this document and submit it on GCR (SoftCopy)
 You have to use your Roll No and consider it as decimal for the unique declaration purpose.
 Exclude the characters and the first two digits from your Roll number.
FOR EXAMPLE: If your number is 22i-7823, use 7823, where A0 assign the first digit of it.
Assign Digit 0 Assign Digit Assign Digit 2 Assign Digit 3
1
Short for Assigned Digit A0 A1 A2 A3

Write Assigned Number Digit By Digit 1 1 5 4


Assigned Byte 0 Assigned Byte 1
Short for Assigned BYTE B0 B1
Byte in DECIMAL 11 54
Convert byte to HEX B0H, B1H A1 36
Convert byte OCTAL B0Q, B1Q 13 66
Convert byte BINARY B0B, B1B 1011 110110
Assigned WORD
Short for Assigned WORD W
WORD in DECIMAL(W)
1154
Convert WORD to HEX (WH) 482
Convert WORD OCTAL (WQ) 2202
Convert byte BINARY (WB) 10010000010
Assigned double WORD in HEXA (DH)

EXAMPLE: Name is HAMZA DAUD


❖ If your name starts with MUHAMMAD kindly use your second name
ZERO FIRST SECOND THIRD FOURTH FIFTH SIXTH
CHARACTER CHARACTER CHARACTER CHARACTER CHARACTER CHARACTE CHARACTE
OF YOUR OF YOUR OF YOUR OF YOUR OF YOUR R OF YOUR R OF YOUR
NAME NAME NAME NAME NAME NAME NAME

Page 1 of 2
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE

ASSIGNMENT#2 (FALL 2023)


Short for
C0 C1 C2 C3 C4 C5 C6
CHARACTER
YOURNAME
CHARACTER BY
CHARACTER
H A N I A A A
1. Write equivalent Assembly instructions for the C++ code given below and also explain C++ code in given
space?

++ Code Assembly Code

#include <iostream> .data


using namespace std; a dd 4578
int main() { b dd 0
int a = 4578; rightmostBit dd 0
int n = 5; .code
for (int i = 1; i <= n; ++i) { mov ecx,5
int rightmostBit = a & 1; loop_strt:
a >>= 1; mov rightmostBit,a
a |= (rightmostBit << 7); and rightmostBit,1
} shr a,1
int b = a; shl rightmostBit,1
return 0; } or a, rightmostBit
loop loop_strt
mov eax,a
mov b,eax

Explanation:
It takes an integer, extracts its rightmost digit, and then shifts it one time to the right. After that, it uses a to
execute an OR of the extracted rightmost bit's seven left shifts, saving the result in a. After completing this five
times, it initializes b using eax.

Page 2 of 2

You might also like