Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model medium
- .stack 1024
- .data
- Spacja db " ", 0ah, 0dh, "$"
- komunikat1 db "Podaj liczbe octalnie: ", 0ah, 0dh, "$"
- .code
- ; Zczytanie liczby oktalnie
- ZczytajLiczbe6:
- mov ah, 10h
- int 16h
- cmp al, '0'
- jl ZczytajLiczbe
- cmp al, '1'
- jle PrzypiszLiczbe6
- jg ZczytajLiczbe
- ZczytajLiczbe:
- cmp cx, 6
- jge ZczytajLiczbe6
- mov ah, 10h
- int 16h
- cmp al, '0'
- jl ZczytajLiczbe
- cmp al, '7'
- jl PrzypiszLiczbe
- jg ZczytajLiczbe
- PrzypiszLiczbe:
- mov ah, 0eh
- int 10h
- sub al, 48
- shl bx, 1
- shl bx, 1
- shl bx, 1
- mov ah, 0
- add bx, ax
- loop ZczytajLiczbe
- retn
- PrzypiszLiczbe6:
- mov ah, 0eh
- int 10h
- sub al, 48
- shl bx, 1
- mov ah, 0
- add bx, ax
- loop ZczytajLiczbe
- retn
- ; Zamiana na dziesietny
- Dzielenie:
- cmp ax,bx
- jl wrzucMniejsze
- jge wrzucWieksze
- wrzucMniejsze:
- mov ah, 0
- add al, 48
- push ax
- inc cx
- jmp Wypisz
- wrzucWieksze:
- div bx
- inc cx
- add dl, 48
- mov dh, 0
- push dx
- jmp Dzielenie
- Wypisz:
- pop ax
- mov ah, 0eh
- int 10h
- loop Wypisz
- jmp koniec
- main proc
- mov ax, @data
- mov ds, ax
- mov ah, 9
- mov dx, offset komunikat1
- int 21h
- mov cx, 6
- call ZczytajLiczbe
- mov ah, 9
- mov dx, offset Spacja
- int 21h
- mov ax, bx
- mov bx, 10
- mov dx, 0
- call Dzielenie
- koniec:
- mov ax, 4c00h
- int 21h
- main endp
- end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement