Program 1 For Addition:-: Name:-Pratikesh Shinde
Program 1 For Addition:-: Name:-Pratikesh Shinde
Output:-
Program 2 for subtraction:-
.model small
.data
a dw 0230H
b dw 0100H
.code
mov ax, @data
mov ds, ax
mov ax, a
mov bx, b
sub ax, bx
mov ch, 04h
mov cl, 04h
mov bx, ax
l2: rol bx, cl
mov dl, bl
and dl, 0fH
cmp dl, 09
jbe l4
add dl, 07
l4: add dl, 30H
mov ah, 02
int 21H
dec ch
jnz l2
mov ah, 4cH
int 21H
end
Output:-
NAME :- PRATIKESH SHINDE
EXPERIMENT 2:- Addition and subtraction of two 32 bit numbers.
Output:-
Program 2 for subtraction:-
.model small
.data
op1 dd 12345678h
op2 dd 11111111h
ans dd ?
.code
mov ax, @data
mov ds, ax
mov ax, word ptr op1
mov bx, word ptr op1+2
mov cx, word ptr op2
mov dx, word ptr op2+2
sub ax, cx
mov word ptr ans, ax
mov word ptr ans+2, bx
mov bx, word ptr ans+2
mov dh, 2
l1: mov ch, 04h
mov cl, 04h
l2: rol bx, cl
mov dl, bl
and dl, 0fH
cmp dl, 09
jbe l4
add dl, 07
l4: add dl, 30H
mov ah, 02
int21H
dec ch
jnz l2
dec dh
cmp dh, 0
jnz l1
int 21h
end
Output:-
NAME :- PRATIKESH SHINDE
EXPERIMENT 3:- 16 bit multiplication of unsigned numbers.
Program:-
.model small
.data
a dw 1234H
b dw 0100H
.code
mov ax, @data
mov ds, ax
mov ax, a
mov bx, b
mul bx
mov si, ax
mov bx, dx
mov dh, 2
l1: mov ch, 04h
mov cl, 04h
l2: rol bx, cl
mov dl, bl
and dl, 0fH
cmp dl, 09
jbe l4
add dl, 07
l4: add dl, 30H
mov ah, 02
int21H
dec ch
jnz l2
dec dh
cmp dh, 0
mov bx, si
jnz l1
Output:-
NAME :- PRATIKESH SHINDE
EXPERIMENT 4 :- 8 bit division of unsigned numbers.
Program:-
data segment
a db 28h
b db 02h
c dw ?
data ends
code segment
assume cs:code, ds:data
start:
mov ax,data
mov ds,ax
mov ax,0000h
mov bx,0000h
mov al,a
mov bl,b
div b
mov c,ax
int 3
code ends
end start
NAME :- PRATIKESH SHINDE
EXPERIMENT 5 :- Find factorial of number.
PROGRAM:-
name "fact"
push ax
int 10h
pop ax
endm
org 100h
jmp start
result dw ?
start:
mov ah, 9
int 21h
jmp n1
n1:
call scan_num
mov ax, 1
cmp cx, 0
je print_result
mov bx, cx
mov ax, 1
mov bx, 1
calc_it:
mul bx
cmp dx, 0
jne overflow
inc bx
loop calc_it
mov result, ax
print_result:
mov ah, 9
int 21h
jmp n2
n2:
call print_num_uns
jmp exit
overflow:
mov ah, 9
int 21h
jmp n3
msg3 db 0Dh,0Ah, 'the result is too big!', 0Dh,0Ah, 'use values from 0 to 8.$'
n3:
jmp start
exit:
mov ah, 0
int 16h
ret
PUSH DX
PUSH AX
PUSH SI
MOV CX, 0
MOV CS:make_minus, 0
next_digit:
INT 16h
INT 10h
JE set_minus
JNE not_cr
JMP stop_input
not_cr:
CMP AL, 8
JNE backspace_checked
MOV DX, 0
MOV AX, CX
DIV CS:ten
MOV CX, AX
PUTC ' '
PUTC 8
JMP next_digit
backspace_checked:
JAE ok_AE_0
JMP remove_not_digit
ok_AE_0:
JBE ok_digit
remove_not_digit:
PUTC 8
PUTC 8
JMP next_digit
ok_digit:
MOV AX, CX
MUL CS:ten
MOV CX, AX
POP AX
CMP DX, 0
JNE too_big
MOV AH, 0
MOV DX, CX
ADD CX, AX
JC too_big2
JMP next_digit
set_minus:
MOV CS:make_minus, 1
JMP next_digit
too_big2:
MOV CX, DX
MOV DX, 0
too_big:
MOV AX, CX
DIV CS:ten
MOV CX, AX
PUTC 8
PUTC 8
JMP next_digit
stop_input:
CMP CS:make_minus, 0
JE not_minus
NEG CX
not_minus:
POP SI
POP AX
POP DX
make_minus DB ?
SCAN_NUM ENDP
PUSH DX
PUSH AX
CMP AX, 0
JNZ not_zero
PUTC '0'
JMP printed
not_zero:
CMP AX, 0
JNS positive
NEG AX
PUTC '-'
positive:
CALL PRINT_NUM_UNS
printed:
POP AX
POP DX
RET
PRINT_NUM ENDP
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV CX, 1
CMP AX, 0
JZ print_zero
begin_print:
CMP BX,0
JZ end_print
CMP CX, 0
JE calc
CMP AX, BX
JB skip
MOV CX, 0
MOV DX, 0
DIV BX
PUTC AL
MOV AX, DX
skip:
PUSH AX
MOV DX, 0
MOV AX, BX
DIV CS:ten
MOV BX, AX
POP AX
JMP begin_print
print_zero:
PUTC '0'
end_print:
POP DX
POP CX
POP BX
POP AX
RET
PRINT_NUM_UNS ENDP
ten DW 10
OUTPUT :-
NAME :- PRATIKESH SHINDE
EXPERIMENT 6:- Generating Fibonacci series.
PROGRAM :-
.MODEL SMALL
.DATA
RES DB ?
CNT DB 0AH
.CODE
MOV DS,AX
LEA SI,RES
MOV CL,CNT
MOV AX,00H
MOV BX,01H
L1:ADD AX,BX
MOV [SI],AX
MOV AX,BX
MOV BX,[SI]
INC SI
LOOP L1
INT 3H
END START
OUTPUT :-
NAME :- PRATIKESH SHINDE
EXPERIMENT 7 :- Program for block transfer.
PROGRAM :-
DATA SEGMENT
STRING1 DB 01H,02H,03H,04H,05H
STRING2 DB 4 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
MOV DS,AX
MOV ES,AX
LEA SI,STRING1
LEA DI,STRING2
MOV CX,05H
CLD
REP MOVSB
INT 3
CODE ENDS
END START
OUTPUT :-
NAME :- PRATIKESH SHINDE
EXPERIMENT 8 :- Program to Find Largest number in a Block of data.
PROGRAM :-
data segment
STRING1 DB 08h,14h,05h,0Fh,09h
res db ?
data ends
code segment
assume cs:code, ds:data
start: mov ax, data
mov ds, ax
cmp al, bl
jl nxt
mov bl, al
nxt:
inc si
dec cx
jnz up
mov res,bl
int 3
code ends
end start
OUTPUT :-