0% found this document useful (0 votes)
50 views25 pages

Program 1 For Addition:-: Name:-Pratikesh Shinde

The document contains programs written by Pratikesh Shinde for 8 experiments involving arithmetic operations, number manipulation, and data transfer using assembly language. The experiments include addition and subtraction of 16-bit and 32-bit numbers, multiplication and division of unsigned numbers, finding the factorial of a number, generating the Fibonacci series, block data transfer, and finding the largest number in a block of data.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views25 pages

Program 1 For Addition:-: Name:-Pratikesh Shinde

The document contains programs written by Pratikesh Shinde for 8 experiments involving arithmetic operations, number manipulation, and data transfer using assembly language. The experiments include addition and subtraction of 16-bit and 32-bit numbers, multiplication and division of unsigned numbers, finding the factorial of a number, generating the Fibonacci series, block data transfer, and finding the largest number in a block of data.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 25

NAME :- PRATIKESH SHINDE

EXPERIMENT 1:- Addition and subtraction of two 16 bit numbers.

Program 1 for addition:-


data segment
a dw 0202h
b dw 0408h
c dw ?
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov ax,a
mov bx,b
add ax,bx
mov c,ax
int 3
code ends
end start

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.

Program 1 for addition:-


.model small
.data
a dw 4278H
b dw 1000H
.code
mov ax, @data
mov ds, ax
mov ax, a
mov bx, b
add ax, bx
mov ch, 04h
mov cl, 04h
mov bx, ax
l2: rol bx, cl
mov dl, bl
and dl, 0fH
cmp dl, 09h
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:-
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

mov bx, word ptr ans

jnz l1

mov ah, 4ch

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

mov ah, 4cH


int 21H
end

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"

putc macro char

push ax

mov al, char

mov ah, 0eh

int 10h

pop ax

endm

org 100h

jmp start

result dw ?

start:

mov dx, offset msg1

mov ah, 9

int 21h

jmp n1

msg1 db 0Dh,0Ah, 'enter the number: $'

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 dx, offset msg2

mov ah, 9

int 21h

jmp n2

msg2 db 0Dh,0Ah, 'factorial: $'

n2:

mov ax, result

call print_num_uns

jmp exit

overflow:

mov dx, offset msg3

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

SCAN_NUM PROC NEAR

PUSH DX

PUSH AX

PUSH SI

MOV CX, 0

MOV CS:make_minus, 0

next_digit:

MOV AH, 00h

INT 16h

MOV AH, 0Eh

INT 10h

JE set_minus

; check for ENTER key:

CMP AL, 0Dh

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:

CMP AL, '0'

JAE ok_AE_0

JMP remove_not_digit

ok_AE_0:

CMP AL, '9'

JBE ok_digit

remove_not_digit:

PUTC 8

PUTC ' '

PUTC 8

JMP next_digit

ok_digit:

MOV AX, CX

MUL CS:ten

MOV CX, AX

POP AX

CMP DX, 0

JNE too_big

SUB AL, 30h

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 ' '

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

PRINT_NUM PROC NEAR

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

PRINT_NUM_UNS PROC NEAR

PUSH AX

PUSH BX

PUSH CX

PUSH DX

MOV CX, 1

MOV BX, 10000

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

ADD AL, 30h

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

START: MOV AX,@DATA

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

START: MOV AX,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

mov cx, 04h


mov bl, 00h
LEA SI, STRING1
up:
mov al, [SI]

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 :-

You might also like