Created
October 8, 2015 13:05
-
-
Save gorakhargosh/a7f6b58e779d8f40e3e4 to your computer and use it in GitHub Desktop.
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
;printing a string | |
prints macro str | |
push ax | |
push bx | |
push cx | |
push dx | |
push si | |
mov ah,09h | |
lea dx,str | |
int 21h | |
pop si | |
pop dx | |
pop cx | |
pop bx | |
pop ax | |
endm prints | |
;accepting a number between 0 and 255 | |
readi macro no | |
local loop1 | |
push ax | |
push bx | |
push cx | |
push dx | |
push si | |
mov al,00 | |
mov dl,10 | |
mov bl,00 | |
loop1: mov cl,al | |
mov al,bl | |
mul dl | |
add al,cl | |
mov bl,al | |
mov ah,01h | |
int 21h | |
sub al,30h | |
cmp al,0ddh | |
jne loop1 | |
mov no,bl | |
pop si | |
pop dx | |
pop cx | |
pop bx | |
pop ax | |
endm readi | |
;printing a number from 0 to 255 | |
printi macro num | |
local divide,printing | |
push ax | |
push bx | |
push cx | |
push dx | |
push si | |
mov bl,10 | |
mov cx,0 | |
divide: mov ax,0 | |
mov al,num | |
div bl | |
mov dx,0 | |
mov dl,ah | |
add dl,30h | |
push dx | |
inc cx | |
mov num,al | |
cmp num,0 | |
jne divide | |
printing: pop dx | |
mov ah,02h | |
int 21h | |
loop printing | |
pop si | |
pop dx | |
pop cx | |
pop bx | |
pop ax | |
endm printi | |
;printing a number between 0 and 32768 from word | |
printw macro num | |
local divide | |
local printing | |
push ax | |
push bx | |
push cx | |
push dx | |
push si | |
mov bx,10 | |
mov cx,0 | |
divide: mov ax,num | |
mov dx,00 | |
div bx | |
add dl,30h | |
push dx | |
inc cx | |
mov num,ax | |
cmp num,0 | |
jne divide | |
printing: pop dx | |
mov ah,02h | |
int 21h | |
loop printing | |
pop si | |
pop dx | |
pop cx | |
pop bx | |
pop ax | |
endm printw | |
;reading a string | |
reads macro str | |
local loop1 | |
push ax | |
push bx | |
push cx | |
push dx | |
push si | |
mov ah,3fh | |
mov bx,00 | |
mov cx,40 | |
lea dx,str | |
int 21h | |
mov cx,00 | |
lea bx,str | |
loop1: mov ah,[bx] | |
inc bx | |
inc cx | |
cmp ah,13 | |
jne loop1 | |
dec bx | |
mov [bx],'$' | |
mov len,cx | |
pop si | |
pop dx | |
pop cx | |
pop bx | |
pop ax | |
endm reads | |
;exiting from program | |
exit macro | |
mov ah,4ch | |
int 21h | |
endm exit | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment