Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. .model medium
  2. .stack 1024
  3. .data
  4. Spacja db " ", 0ah, 0dh, "$"
  5. komunikat1 db "Podaj liczbe octalnie: ", 0ah, 0dh, "$"
  6.  
  7.  
  8. .code
  9.  
  10. ; Zczytanie liczby oktalnie
  11.  
  12. ZczytajLiczbe6:
  13. mov ah, 10h
  14. int 16h
  15.  
  16. cmp al, '0'
  17. jl ZczytajLiczbe
  18. cmp al, '1'
  19. jle PrzypiszLiczbe6
  20. jg ZczytajLiczbe
  21.  
  22. ZczytajLiczbe:
  23. cmp cx, 6
  24. jge ZczytajLiczbe6
  25.  
  26. mov ah, 10h
  27. int 16h
  28.  
  29. cmp al, '0'
  30. jl ZczytajLiczbe
  31. cmp al, '7'
  32. jl PrzypiszLiczbe
  33. jg ZczytajLiczbe
  34.  
  35.  
  36. PrzypiszLiczbe:
  37. mov ah, 0eh
  38. int 10h
  39.  
  40. sub al, 48
  41.  
  42. shl bx, 1
  43. shl bx, 1
  44. shl bx, 1
  45.  
  46. mov ah, 0
  47.  
  48. add bx, ax
  49. loop ZczytajLiczbe
  50. retn
  51.  
  52. PrzypiszLiczbe6:
  53. mov ah, 0eh
  54. int 10h
  55.  
  56. sub al, 48
  57.  
  58. shl bx, 1
  59.  
  60. mov ah, 0
  61.  
  62. add bx, ax
  63. loop ZczytajLiczbe
  64. retn
  65.  
  66. ; Zamiana na dziesietny
  67.  
  68. Dzielenie:
  69. cmp ax,bx
  70.  
  71. jl wrzucMniejsze
  72. jge wrzucWieksze
  73.  
  74. wrzucMniejsze:
  75. mov ah, 0
  76. add al, 48
  77. push ax
  78. inc cx
  79. jmp Wypisz
  80.  
  81. wrzucWieksze:
  82. div bx
  83. inc cx
  84. add dl, 48
  85. mov dh, 0
  86. push dx
  87. jmp Dzielenie
  88.  
  89. Wypisz:
  90. pop ax
  91. mov ah, 0eh
  92. int 10h
  93. loop Wypisz
  94. jmp koniec
  95.  
  96. main proc
  97.  
  98. mov ax, @data
  99. mov ds, ax
  100.  
  101. mov ah, 9
  102. mov dx, offset komunikat1
  103. int 21h
  104.  
  105. mov cx, 6
  106. call ZczytajLiczbe
  107.  
  108. mov ah, 9
  109. mov dx, offset Spacja
  110. int 21h
  111.  
  112. mov ax, bx
  113. mov bx, 10
  114. mov dx, 0
  115.  
  116. call Dzielenie
  117.  
  118.  
  119. koniec:
  120. mov ax, 4c00h
  121. int 21h
  122.  
  123. main endp
  124. end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement