0% found this document useful (0 votes)
57 views1 page

ADD/SUB - 8 ADD - 16 AVG - 16 Date Time

This document contains code segments for several programs: ADD_8, ADD_16, AVG_16, DATE, and TIME. Each code segment defines message prompts, reads input from the user, performs calculations, and displays output messages and results. The ADD_8 segment adds two numbers input by the user. The ADD_16 segment adds two 16-bit numbers. The AVG_16 segment calculates the average of numbers input by the user. The DATE segment displays the current date. The TIME segment displays the current time. Common elements across the segments include getting input, performing arithmetic operations, and displaying output.

Uploaded by

J HARSHA YADAV
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views1 page

ADD/SUB - 8 ADD - 16 AVG - 16 Date Time

This document contains code segments for several programs: ADD_8, ADD_16, AVG_16, DATE, and TIME. Each code segment defines message prompts, reads input from the user, performs calculations, and displays output messages and results. The ADD_8 segment adds two numbers input by the user. The ADD_16 segment adds two 16-bit numbers. The AVG_16 segment calculates the average of numbers input by the user. The DATE segment displays the current date. The TIME segment displays the current time. Common elements across the segments include getting input, performing arithmetic operations, and displaying output.

Uploaded by

J HARSHA YADAV
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

ADD/SUB_8 ADD_16 AVG_16 DATE TIME

data segment data segment data segment data segment data segment
mess1 db 0ah,0dh,'enter the first number:','$' mess1 db 0ah,0dh,"enter the first 16-bit numbr:",'$' mess1 db 0ah,0dh,"enter the limit:",'$' mess1 db 0dh,"date is:$" mess1 db 0dh,"time is:$"
mess2 db 0ah,0dh,'enter the second number:','$' mess2 db 0ah,0dh,"enter the second 16-bit number:",'$' mess2 db 0ah,0dh,"enter the numbers:",'$' ends ends
mess3 db 0ah,0dh,'sum of two numbers :','$' mess3 db 0ah,0dh,"the sum of two numvber is :",'$' mess3 db 0ah,0dh,"the avg is:",'$'
data ends data ends data ends code segment code segment
code segment start: start:
assume cs:code,ds:data code segment code segment mov ax,data mov ax,data
start:mov ax,data assume cs:code,ds:data assume cs:code,ds:data mov ds,ax mov ds,ax
mov ds,ax start: start: loop1:lea dx,mess1
mov ax,data mov ax,data lea dx,mess1 mov ah,09h
mov ds,ax mov ds,ax mov ah,09h int 21h
lea dx,mess1 int 21h mov ah,2ch
mov ah,09h lea dx,mess1 lea dx,mess1 int 21h
int 21h mov ah,09h mov ah,09h mov ah,2ah mov al,ch
call read int 21h int 21h int 21h call convert
mov bh,bl call read call read mov si,cx mov dl,":"
mov si,bx mov ch,dl mov bh,dl mov ah,02h
lea dx,mess2 mov al,dh int 21h
mov ah,09h lea dx,mess2 lea dx,mess2 call display
int 21h mov ah,09h mov ah,09h mov al,cl
call read int 21h int 21h mov dl,"/" call convert
call read mov dh,ch mov ah,02h mov dl,":"
lea dx,mess3 mov bx,0000h int 21h mov ah,02h
mov ah,09h lea dx,mess3 loop2:call read int 21h
int 21h mov ah,09h add bl,dl mov bh,dh mov al,dh
int 21h jnc loop1 call display call convert
add bh,bl inc bh mov dl,"/" mov ah,0bh
add bx,si loop1:mov dl,' ' mov ah,02h int 21h
jnc loop1 jnc loop1 mov ah,02h int 21h cmp al,00h
mov dl,31h mov dl,'1' int 21h je loop1
mov ah,06h mov ah,06h dec dh mov ax,si mov ax,4c00h
int 21h int 21h jnz loop2 mov dh,64h int 21h
loop1:call disp loop1:call disp div dh
mov ah,4ch mov ah,4ch lea dx,mess3 mov cx,ax convert proc near
int 21h int 21h mov ah,09h mov ah,00h
int 21h mov bh,cl mov bh,0ah
mov ax,bx call display div bh
div ch mov bh,ch call display
read proc near read proc near mov bh,al call display ret
mov al,00h mov ax,4c00h
mov cl,04h mov ch,02h div ch int 21h convert endp
mov ah,01h mov cl,04h mov bl,al
int 21h read1:mov ah,01h call disp display proc near
sub al,30h int 21h mov ax,4c00h display proc near mov bl,ah
cmp al,0ah sub al,30h int 21h call conv mov dl,al
jc read1 cmp al,0ah mov dl,bl add dl,30h
sub al,07h jc read2 read proc near add dl,30h mov ah,02h
read1:shl al,cl sub al,07h mov cl,04h mov ah,02h int 21h
mov bl,al read2:shl al,cl mov ah,01h int 21h mov dl,bl
mov ah,01h mov bl,al int 21h
int 21h mov ah,01h sub al,30h mov dl,bh add dl,30h
sub al,30h int 21h cmp al,0ah add dl,30h mov ah,02h
cmp al,0ah sub al,30h jc read1 mov ah,02h int 21h
jc read2 cmp al,0ah sub al,07h int 21h ret
sub al,07h jc read3 read1:shl al,cl ret display endp
read2:or bl,al sub al,07h mov dl,al
ret read3:or bl,al mov ah,01h display endp code ends
read endp dec ch int 21h end start
jz read4 sub al,30h conv proc near
disp proc near mov bh,bl cmp al,0ah
jmp read1 jc read2 mov ah,00h
mov cl,04h read4:ret sub al,07h mov al,bh
mov dl,bh read2:or dl,al mov bh,0ah
shr dl,cl read endp ret div bh
cmp dl,0ah mov bx,ax
jc disp1 read endp ret
add dl,07h disp proc near conv endp
disp1:add dl,30h
mov ah,06h mov cl,04h disp proc near
int 21h mov ch,02h code ends
mov dl,bh disp1:mov dl,bh mov ch,02h end start
and dl,0fh shr dl,cl mov cl,04h
cmp dl,0ah cmp dl,0ah disp4:mov dl,bh
jc disp2 jc disp2 shr dl,cl
add dl,07h add dl,07h cmp dl,0ah
disp2:add dl,30h disp2:add dl,30h jc disp1
mov ah,06h mov ah,06h add dl,07h
int 21h int 21h disp1:add dl,30h
ret mov dl,bh mov ah,02h
disp endp and dl,0fh int 21h
code ends cmp dl,0ah mov dl,bh
end start jc disp3 and dl,0fh
add dl,07h cmp dl,0ah
disp3:add dl,30h jc disp2
mov ah,06h add dl,07h
int 21h disp2:add dl,30h
dec ch mov ah,02h
jz disp4 int 21h
mov bh,bl dec ch
jmp disp1 jz disp3
disp4:ret mov dl,'.'
mov ah,06h
disp endp int 21h
mov bh,bl
code ends jmp disp4
end start disp3:ret

disp endp

code ends
end start

You might also like