Siddartha_code
Siddartha_code
EC2003E
Computer Architecture and Processors
Monsoon 2024-25
Assignment Code
(8086 Assembly Language Programming)
Submitted by:
Kotike Siddartha
B230672EC
EC02
2|Page
CODE:
Question 1. 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?
.MODEL SMALL
.DATA
BYTE1 DB 0BH
BYTE2 DB 23H
BYTE3 DB 06H
BYTE4 DB 72H
BYTE5 DB 0ECH
.CODE
MOV AX, @DATA
MOV DS, AX
MOV AL, BYTE1
ADD AL, BYTE2
ADD AL, BYTE5
.EXIT
END
3|Page
Question 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.
.MODEL SMALL
.DATA
ROLL DB 1001H - 0H DUP(0), 0BH, 23H, 06H, 72H, 0ECH
.CODE
MOV AX, @DATA
MOV DS, AX
MOV CX, 4
MOV BL, 0ECH
MOV SI, 1001H
MOV DI, 1005H
L1:
MOV AL, [SI]
MOV [DI], AL
INC SI
INC DI
LOOP L1
MOV [DI], BL
.EXIT
END
4|Page
.MODEL SMALL
.DATA
ROLL DB 1001H - 0H DUP(0), 0BH, 23H, 06H, 72H, 0ECH
LRG DB ?
.CODE
MOV AX, @DATA
MOV DS, AX
MOV CX, 4
MOV SI, 1001H
MOV AL, [SI]
L1:
CMP AL, [SI+1]
JNC L2
MOV AL, [SI+1]
L2:
INC SI
LOOP L1
MOV LRG, AL
.EXIT
END
5|Page
Question 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.
.MODEL SMALL
.DATA
ARR1 DB 1001H - 0H DUP(0), 0BH, 23H, 06H, 72H, 0ECH
ARR2 DB 0BH,23H,11H,70H,0ECH
.CODE
MOV AX, @DATA
MOV DS, AX
MOV SI, 1001H
MOV DI, 1006H
MOV CX, 05H
LI:
MOV AL,[SI]
MOV AH,[DI]
MOV [SI],AH
MOV [DI],AL
INC SI
INC DI
DEC CX
JNZ LI
.EXIT
END
6|Page
Question 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
Question 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.
.MODEL SMALL
.DATA
BYTE4 DB 72H
.CODE
MOV AX, @DATA
MOV DS, AX
MOV AL,BYTE4
MOV CL,4
ROL AL,CL
.EXIT
END
7|Page
Question 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.
.MODEL SMALL
.DATA
NUMS DB 0H, 0BH, 2H, 3H, 0H, 6H, 7H, 2H,
0EH, 0CH
ODD DB ?
EVEN DB ?
.CODE
MOV AX, @DATA
MOV DS, AX
LEA SI, NUMS
MOV BX, 02H
MOV CX, 10
L1:
MOV AX, [SI]
DIV BX
OR DX, 00H
JNZ L2
ADD EVEN, 1
L2:
INC SI
LOOP L1
MOV AL, 10
SUB AL, EVEN
MOV ODD, AL
.EXIT
END