-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
609 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
; @nlkguy | ||
; addition | ||
; NANDULAL KRISHNA | ||
; 20221097 | ||
; S5 CSB | ||
|
||
.model small | ||
.data | ||
msg1 db 13, 10, "num1 : $" | ||
msg2 db 13, 10, "num2 : $" | ||
sum db 13, 10, "sum : $" | ||
|
||
.code | ||
.stack | ||
|
||
start: | ||
|
||
mov ax, @data | ||
mov ds, ax | ||
|
||
lea dx, msg1 | ||
mov ah, 09h | ||
int 21h | ||
|
||
call input | ||
mov bh, dl | ||
|
||
|
||
lea dx, msg2 | ||
mov ah, 09h | ||
int 21h | ||
|
||
call input | ||
mov bl, dl | ||
|
||
|
||
; add | ||
mov ax, 0000h | ||
mov al, bl | ||
mov cx, 0000h | ||
mov cl, bh | ||
add ax, cx | ||
mov bx, ax | ||
|
||
|
||
mov ah, 09h | ||
lea dx, sum | ||
int 21h | ||
|
||
|
||
call output | ||
mov bh, bl | ||
call output | ||
|
||
|
||
mov ah, 4ch | ||
int 21h | ||
|
||
;----------------------------- | ||
input proc | ||
|
||
call inputnum ; get 1st digit | ||
mov cl, 04h ; cl = 4 | ||
rol dl, cl ; rotate DL 4 times left(shift first digit to left nibble) | ||
and dl, 00f0h ; clear lower nibble | ||
mov ch, dl ; move to CH | ||
|
||
|
||
call inputnum ; get 2nd digit to DL | ||
and dl, 000fh ; AND - | ||
add dl, ch ; add to DL | ||
|
||
ret | ||
input endp | ||
;----------------------------- | ||
inputnum proc | ||
mov ah, 01h | ||
int 21h | ||
|
||
cmp al, 'A' ; compare with character A | ||
jc inputnum_is_dec ; if lessthan A , it is decimal | ||
jmp inputnum_is_hex ; or hex | ||
inputnum_is_hex: | ||
sub al, 'A' | ||
add al, 0ah | ||
mov dl, al | ||
ret | ||
inputnum_is_dec: | ||
sub al, '0' | ||
mov dl, al | ||
ret | ||
inputnum endp | ||
;----------------------------- | ||
output proc | ||
mov al, bh | ||
and al, 00f0h | ||
mov cl, 04h | ||
ror al, cl | ||
mov dl, al | ||
call outputnum | ||
|
||
mov dl, bh | ||
and dl, 000fh | ||
call outputnum | ||
|
||
ret | ||
output endp | ||
;----------------------------- | ||
outputnum proc | ||
mov ah, 02h | ||
|
||
cmp dl, 0ah | ||
jc outputnum_is_dec | ||
jmp outputnum_is_hex | ||
outputnum_is_hex: | ||
add dl, 'A' | ||
sub dl, 0ah | ||
int 21h | ||
ret | ||
outputnum_is_dec: | ||
add dl, '0' | ||
int 21h | ||
ret | ||
outputnum endp | ||
;----------------------------- | ||
end start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
; @nlkguy | ||
; multiplication | ||
; NANDULAL KRISHNA | ||
; 20221097 | ||
; S5 CSB | ||
|
||
.model small | ||
.data | ||
ms1 db 13, 10, "num1 : $" | ||
ms2 db 13, 10, "num2 : $" | ||
prod db 13, 10, "product : $" | ||
|
||
.code | ||
.stack | ||
|
||
start: | ||
|
||
mov ax, @data | ||
mov ds, ax | ||
|
||
lea dx, ms1 | ||
mov ah, 09h | ||
int 21h | ||
|
||
call input | ||
mov bh, dl | ||
|
||
|
||
lea dx, ms2 | ||
mov ah, 09h | ||
int 21h | ||
|
||
call input | ||
mov bl, dl | ||
|
||
|
||
mov al, bl | ||
mul bh | ||
mov bx, ax | ||
|
||
|
||
mov ah, 09h | ||
lea dx, prod | ||
int 21h | ||
|
||
|
||
call output | ||
mov bh, bl | ||
call output | ||
|
||
|
||
mov ah, 4ch | ||
int 21h | ||
;--------------------------------- | ||
|
||
input proc | ||
|
||
call inputnum | ||
mov cl, 04h | ||
rol dl, cl | ||
and dl, 00f0h | ||
mov ch, dl | ||
|
||
|
||
call inputnum | ||
and dl, 000fh | ||
add dl, ch | ||
|
||
ret | ||
input endp | ||
;--------------------------------- | ||
inputnum proc | ||
mov ah, 01h | ||
int 21h | ||
|
||
cmp al, 'A' | ||
jc inputnum_is_dec | ||
jmp inputnum_is_hex | ||
inputnum_is_hex: | ||
sub al, 'A' | ||
add al, 0ah | ||
mov dl, al | ||
ret | ||
inputnum_is_dec: | ||
sub al, '0' | ||
mov dl, al | ||
ret | ||
inputnum endp | ||
|
||
;--------------------------------- | ||
output proc | ||
mov al, bh | ||
and al, 00f0h | ||
mov cl, 04h | ||
ror al, cl | ||
mov dl, al | ||
call outputnum | ||
|
||
mov dl, bh | ||
and dl, 000fh | ||
call outputnum | ||
|
||
ret | ||
output endp | ||
;--------------------------------- | ||
outputnum proc | ||
mov ah, 02h | ||
|
||
cmp dl, 0ah | ||
jc outputnum_is_dec | ||
jmp outputnum_is_hex | ||
outputnum_is_hex: | ||
add dl, 'A' | ||
sub dl, 0ah | ||
int 21h | ||
ret | ||
outputnum_is_dec: | ||
add dl, '0' | ||
int 21h | ||
ret | ||
outputnum endp | ||
;--------------------------------- | ||
|
||
end start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
|
||
; @nlkguy | ||
; string concat | ||
; NANDULAL KRISHNA | ||
; 20221097 | ||
; S5 CSB | ||
|
||
|
||
data segment | ||
str1 db 30 dup(" $") | ||
str2 db 30 dup("$") | ||
m1 db 13,10,"str 1 : $" | ||
m2 db 13,10,"str 1 : $" | ||
outp db 13,10,"str 1 : $" | ||
wel db 13,10,"string concat ---- $" | ||
data ends | ||
|
||
code segment | ||
assume cs:code , ds:data | ||
start: | ||
mov ax,data | ||
mov ds,ax | ||
mov cl,04 | ||
lea dx,wel | ||
mov ah,09h | ||
int 21h | ||
lea dx,m1 | ||
mov ah,09h | ||
int 21h | ||
loop0:mov ah,01h | ||
int 21h | ||
cmp al,13 | ||
je skip | ||
mov [si],al | ||
inc si | ||
jmp loop0 | ||
skip:mov ah,09h | ||
lea dx,m2 | ||
int 21h | ||
lea si,str2 | ||
loop1:mov ah,01h | ||
int 21h | ||
cmp al,13 | ||
je skip1 | ||
mov [si],al | ||
inc si | ||
jmp loop1 | ||
skip1:call concat | ||
mov ah,4ch | ||
int 21h | ||
concat proc | ||
lea si,str1 | ||
lea di,str2 | ||
mov al,"$" | ||
loop2: cmp al,[si] | ||
jz loop3 | ||
inc si | ||
jmp loop2 | ||
loop3: | ||
cmp al,[di] | ||
jz exit | ||
mov bl,[di] | ||
mov [si],bl | ||
inc si | ||
inc di | ||
jmp loop3 | ||
exit: mov [di],al | ||
lea dx,outp | ||
mov ah,09h | ||
int 21h | ||
lea dx,str1 | ||
mov ah,09h | ||
int 21h | ||
ret | ||
concat endp | ||
code ends | ||
end start | ||
|
Oops, something went wrong.