0% found this document useful (0 votes)
4 views

Computer architecture processor assignment vidyadhari _b231051ec

The document outlines an assignment on computer architecture and processors, specifically focusing on 8086 assembly programming tasks. It includes instructions for manipulating bytes from a roll number, transferring data, finding the largest value in an array, swapping roll numbers, and analyzing flags after specific operations. Additionally, it covers counting odd and even numbers and performing bitwise operations, along with expected outputs for each task.

Uploaded by

physizzmva
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Computer architecture processor assignment vidyadhari _b231051ec

The document outlines an assignment on computer architecture and processors, specifically focusing on 8086 assembly programming tasks. It includes instructions for manipulating bytes from a roll number, transferring data, finding the largest value in an array, swapping roll numbers, and analyzing flags after specific operations. Additionally, it covers counting odd and even numbers and performing bitwise operations, along with expected outputs for each task.

Uploaded by

physizzmva
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

COMPUTER ARCHITECTURE AND

PROCESSORS ASSIGNMENT
M.VIDYADHARI
B231051EC
CODE AND EXPLANATION:

1. Take your roll number, and break it up into pairs/byte as shown below. What will be the result
of the addition of byte_1, byte_2, and byte_5? What will be the state of the status flags at each
instruction while addition?

This program adds three bytes (byte_1, byte_2, and byte_5) from the roll number stored in memory.

Flags will be updated during each addition:

Carry Flag (CF): Set if there’s a carry from MSB during addition.
Zero Flag (ZF): Set if the result is zero.

Sign Flag (SF): Set if the result is negative.

Auxiliary Flag (AF): Used for BCD operations.

During first ADD

CF=0

ZF=0

SF=0

AF=0

During second ADD

CF=1

ZF=0

AF=1

OF=1

2. Assume that 5 bytes of your roll number data are initially stored starting at memory location
1001H. Write a program to transfer these 5 bytes of data to a new location, beginning at address
1005H.

This 8086 assembly program transfers 5 bytes of data from a source memory location (starting at
1001H) to a destination memory location (starting at 1006H). The program initializes the data and
code segments, sets the source index (SI) to 1001H, the destination index (DI) to 1006H, and the
counter register (CX) to 5 (indicating the number of bytes to transfer). Inside the loop, it loads each
byte from the source address into the AL register using MOV AL, [SI], stores it at the destination
address using MOV [DI], AL, and increments both SI and DI to process the next byte. The loop
continues until all 5 bytes are transferred, with the LOOP instruction decrementing CX after each
iteration. Finally, the program terminates using the DOS interrupt INT 21H.

3. Consider an array of 5 bytes of data of your roll number stored starting at memory location
1001H. Write a program to find the largest value in this array.

This 8086 assembly program finds the largest byte from a set of data stored in memory. The program
begins by initializing the data segment and setting the source index (SI) to 1001H, where the data
array starts, and CX to 5 (indicating the number of bytes to compare). The first byte from the array is
loaded into the AL register and is treated as the largest value initially. Inside the loop, the CMP
instruction compares AL with the next byte in memory at [SI]. If the current byte in AL is larger, the
program skips updating AL; otherwise, it updates AL with the new value. SI is incremented in each
iteration to point to the next byte. The loop continues until all bytes are compared, using LOOP
LARGER to decrement CX and repeat until zero. Finally, the largest byte is stored in the variable LRG
and the program terminates using INT 21H.

4.Consider an array of 5 bytes of your roll number and one of your classmate roll number which
are stored starting at memory location 1001H. Write a program to exchange your roll numbers.
This assembly code, written for the 8086 microprocessor, demonstrates swapping data between two
arrays (ROLL1 and ROLL2) defined in the .DATA segment. Each array contains a sequence of
hexadecimal values. The program begins by initializing the data and extra segment registers (DS and
ES) using the address of the .DATA segment. It sets up pointers SI and DI to the starting addresses of
ROLL1 and ROLL2, respectively. The CX register is loaded with a value (05H), which represents the
number of elements to be swapped. Inside the SWAP loop, elements from ROLL1 (pointed to by SI)
and ROLL2 (pointed to by DI) are swapped using the AL and BL registers as temporary storage. After
each swap, the pointers SI and DI are incremented, and the loop iterates until all elements are
swapped. The program ends with an interrupt (INT 21H) to terminate execution.

5. What will be the values of the Flag register after executing the following instructions MOV AL,
byte_4 MOV AH, byte_3 INC AX
This assembly code, written for the 8086 microprocessor, demonstrates basic data manipulation. It
defines a small memory model and declares a .DATA segment containing five bytes (BYTE1 to BYTE5)
initialized with hexadecimal values. In the .CODE segment, the program initializes the data segment
by loading the address of the data (DATA) into the AX register and transferring it to the DS register.
Then, it loads the values of BYTE4 and BYTE3 into the AL (low byte) and AH (high byte) parts of the
AX register, respectively. Afterward, it increments the value of AX using the INC instruction. The
program concludes with the ENDS and END directives. This is a basic demonstration of moving data,
using registers, and performing arithmetic operations in assembly language.

6. Given AX = {byte_1}{byte_2} and BX = {byte_3}{byte_4}, what will be the value of CF, ZF, AF after
the following instruction? XOR AX, BX

This code initializes two registers, AX and BX, with the hexadecimal values 0B23H and 1051H,
respectively, and then performs a bitwise XOR operation between them. The result of the XOR is
stored in the AX register, replacing its original value. The XOR operation sets each bit in the result to
1 if the corresponding bits in AX and BX are different, and to 0 if they are the same. This operation
can be useful for tasks such as encryption, toggling bits, or clearing a register (when XORing a value
with itself). The BX register remains unchanged throughout the code.

7. Take each digit in your roll number as a number. Write a program to count the number of odd
and even numbers in this set.
This assembly code categorizes an array of numbers into even and odd sums. It defines a .DATA
section containing an array called ROLL with values and two variables, EVEN and ODD, initialized to 0.
In the .CODE section, the program initializes the data segment, sets up registers for processing the
array, and uses a loop to iterate through its elements. For each number, it clears the DX register,
loads the current value into AX, performs a division by 2 (using DIV BX), and checks the remainder
(DX). If the remainder is 1, the number is odd, and it is added to ODD; otherwise, it is even and
added to EVEN. After processing all numbers, the results are stored in EVEN and ODD. The LOOP
instruction handles iteration, and SI is incremented to access the next array element. The program
ends after processing the entire array.

8. Take byte 4 of your roll number and store it in a memory location. Write a program to reverse
this byte using the 8086-instruction set.
This assembly code is written for an 8086 microprocessor and performs a left rotate operation on a
single byte value. The program begins with the .MODEL SMALL directive, which specifies a small
memory model where code and data segments do not overlap. In the .DATA segment, the variable
BYTE4 is initialized with the hexadecimal value 51H. In the .CODE segment, the data segment register
is loaded with the segment address of the data, and then the value of BYTE4 is loaded into the AL
register. The CL register is loaded with the value 4, indicating the number of positions to rotate. The
ROL instruction is then executed, performing a 4-bit left circular rotation on the contents of AL.
Finally, the program terminates with the .EXIT directive and ends execution.
COMPUTER ARCHITECTURE AND
PROCESSORS ASSIGNMENT
M.VIDYADHARI
B231051EC
ECO2

RESULTS:

0UTPUT 1

OUTPUT2
OUTPUT 3

OUTPUT 4
OUTPUT 5

OUTPUT 6
OUTPUT 7

OUTPUT 8

You might also like