Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org 100h
- .stack 100h
- .data
- ;count db 0
- nl db 0dh, 0ah,'$'
- .code
- onem macro x
- push ax ; cz AX mirjafor! value chng kore dey -_-
- mov dx,x ;dl dile 8 bit er sthe 16 bit korte jabe! SO ERROR , tai amra eikhne DL na diye DX disi
- mov ah,2
- add dl,'0'
- int 21h
- pop ax
- endm onem
- nl macro
- mov ah, 9
- lea dx, nl
- int 21h
- endm nl
- main proc
- mov dx, @data
- mov ds, dx
- ;mov ax, 12345
- call inputAX
- nl
- mov ah,0
- mov al,res
- call printAX
- mov ah,4ch
- int 21h
- endp main
- inputAX proc
- mov AX,0
- mov bl, 10
- mov res,0
- inputloop:
- mov ah,1
- int 21h
- sub al, '0' ; aschii --> value
- mov dl, al ; new input
- cmp al,0dh
- je doneinput
- mov al, res ; a; = res
- mul bl ; al = res * 10
- mov res,al
- add res,dl ; al = res + new digit
- jmp inputloop
- doneinput:
- mov al, res
- ret
- endp inputAX
- printAX proc
- mov bx,10
- count db 0
- L1:
- mov bx,10
- xor dx, dx
- div bx ; DX = AX % 10, AX = AX/10
- push dx
- inc count
- cmp ax,0
- je L2
- jmp L1
- L2:
- dec count
- pop dx
- onem dx
- cmp count,0
- je done
- jmp L2
- done:
- ret
- endm printAX
- end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement