Assignment 1
Name: Daksh Chauhan
Roll : C-69
1. Addition of two 8 bit numbers:
Program Code:
.model small
.stack 100h
.data
a db 09h
b db 03h
.code
mov
ax,@data
mov ds,ax
mov al,a
mov bl,b
add al,bl
mov cl,al
int 21h
mov
ah,4ch int
3h
end
2. Addition of two 16 bit numbers:
.model small
.stack 100h
.data
a dw 0009h
b dw 0003h
result dw 0000h
.code
mov ax, @data
mov ds, ax
mov ax, a
mov bx, b
add ax, bx
mov result, ax
mov ah, 4ch
int 21h
end
Output:
CX stores result as CH
3. Subtract 2 8-bit numbers:
Program Code:
.model small
.stack 100h
.data
n1 db 09h
n2 db 05h
result db 00h
.code
mov ax, @data
mov ds, ax
mov al, n1
mov bl, n2
sub al, bl
mov result, al
mov ah, 4ch
int 21h
end
`
4. Subtract 2 16-bit numbers:
.model small
.stack 100h
.data
n1 dw 0009h
n2 dw 0005h
result dw 0000h
.code
mov ax, @data
mov ds, ax
mov ax, n1
mov bx, n2
sub ax, bx
mov result, ax
mov ah, 4ch
int 21h
end
5. Multiplication of 2 8-bit numbers
Program code:
.model small
.stack 100h
.data
n1 db 07h
n2 db 02h
result dw 0000h
.code
mov ax, @data
mov ds, ax
mov al, n1
mov bl, n2
mul bl
mov result, ax
mov ah, 4ch
int 21h
end
=================================================
=====================
1. Multiplication of 2 16-bit numbers
.model small
.stack 100h
.data
n1 dw 0007h
n2 dw 0002h
result dw 0000h, 0000h
.code
mov ax, @data
mov ds, ax
mov ax, n1
mov bx, n2
mul bx
mov result, ax
mov result+2, dx
mov ah, 4ch
int 21h
end
CX displays the result of multiplication as 0EH
>>>>>>>>Division of 16-bit with 8-bit number:
.model small
.stack 100h
.data
n1 dw 0020h
n2 db 06h
result db 00h
remainder db 00h
.code
mov ax, @data
mov ds, ax
mov ax, n1
mov dx, 0
mov bl, n2
div bl
mov result, al
mov remainder, ah
mov ah, 4ch
int 21h
end
>>>>>Division of 32-bit with 16-bit number:
.model small
.stack 100h
.data
n1 dw 1234h, 5678h
n2 dw 0010h
result dw 0000h
remainder dw 0000h
.code
mov ax, @data
mov ds, ax
mov dx, 1234h
mov ax, 5678h
mov bx, n2
div bx
mov result, ax
mov remainder, dx
mov ah, 4ch
int 21h
end
AX stores the result of division as AL : 05H (Quotient) AH : 02H (Remainder)
Write an 8086 assembly language program to compare two numbers. After comparison
update the status of the flags.
.model small
.stack 100h
.data
num1 db 5
num2 db 7
.code
mov ax, @data
mov ds, ax
mov al, num1
mov bl, num2
cmp al, bl ; Compares AL - BL, updates flags only
mov ah, 4ch
int 21h
end
Notes:
CMP al, bl subtracts BL from AL without storing the result, but updates
the flags:
o ZF (Zero Flag) – Set if the numbers are equal.
o CF (Carry Flag) – Set if there's a borrow (i.e., if AL < BL).
o SF (Sign Flag) – Set if result is negative (i.e., MSB of result is 1).
o OF (Overflow Flag) – Set if signed overflow occurred.
You can later use conditional jumps like JE, JL, JG, etc., based on the flag
status.