Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1.  
  2. ; You may customize this and other start-up templates;
  3. ; The location of this template is c:\emu8086\inc\0_com_template.txt
  4.  
  5. org 100h
  6. inp DB 0Ah DUP (0)
  7.  
  8. PRINT
  9.  
  10. mov cx, 0Ah
  11. lea di, inp
  12.  
  13. input:
  14. ;cld useless
  15. mov ah, 0
  16. int 16h
  17. stosb
  18.  
  19. loop input
  20.  
  21. outp DB 0Ah DUP (0)
  22.  
  23. mov cx, 0Ah
  24. lea di, [outp]
  25.  
  26. input2:
  27. ;cld useless
  28. mov ah, 0
  29. int 16h
  30. stosb
  31. loop input2
  32.  
  33. ;std reverse for sum
  34. mov cx, 0Ah
  35. lea si, [inp+0Ah-1h] ;konec
  36. lea di, [outp+0Ah-1h] ; konec
  37. mov bl, 0
  38. jmp sum
  39.  
  40. add_1_to_next:
  41. dec bl
  42. inc al
  43. jmp added_1
  44.  
  45. overflow:
  46. sub al, 10h
  47. inc bl
  48. jmp afterflow
  49.  
  50. small_word:
  51. sub bl, 20h
  52. jmp ret3
  53.  
  54. f_word_to_hex:
  55. sub bl, 7h
  56. cmp bl, 0Fh
  57. jg small_word
  58. ret3:
  59. sub bh, 1
  60. jz to_ret2
  61. xor bh, bh
  62. push bx
  63. jmp ret1
  64. to_ret2:
  65. push bx
  66. jmp ret2
  67.  
  68. sum:
  69. std
  70. lodsb
  71. mov bp, cx
  72. mov dl, byte [outp-bp-1]
  73. sub al, 30h
  74. sub dl, 30h
  75.  
  76. cmp al, 9
  77. jle is_1digit
  78. push bx
  79. xor bx, bx
  80. mov bl, al
  81. jmp f_word_to_hex
  82. ret1:
  83. pop bx
  84. mov al, bl
  85. pop bx
  86.  
  87. is_1digit:
  88. cmp dl, 9
  89. jle is_2digit
  90. push bx
  91. xor bx, bx
  92. mov bl, dl
  93. mov bh, 1 ;ret2
  94. jmp f_word_to_hex
  95. ret2:
  96. pop bx
  97. mov dl, bl
  98. pop bx
  99.  
  100. is_2digit:
  101. add al, dl
  102. test bl, bl
  103. jnz add_1_to_next
  104. added_1:
  105. cmp al, 0Fh
  106. jg overflow
  107. afterflow:
  108. std
  109. stosb
  110. loop sum
  111.  
  112. test bl, bl
  113.  
  114. printed_first:
  115. lea si, outp
  116. mov cx, 0Ah
  117.  
  118. jmp output
  119.  
  120. isword:
  121. add al, 57h
  122. jmp nowgoodword
  123.  
  124. first_symbol:
  125. mov al, 31h
  126. mov ah, 0x0E
  127. int 10h
  128. jmp printed_first
  129.  
  130. output:
  131. cld
  132. mov ah, 0x0E
  133. lodsb
  134. ;mov al, 'a'
  135. cmp al, 09h
  136. jg isword
  137. add al, 30h
  138. nowgoodword:
  139. int 10h
  140. loop output
  141.  
  142. jmp $
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement