Ae_Mc

Number to string

Dec 23rd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. org 0x100
  2. push 12345
  3. call num_to_str
  4. ; Вывод полученной строки
  5. while:
  6.         pop ax
  7.         cmp al, 0
  8.         jz while_end
  9.         mov ah, 0xE
  10.         int 0x10
  11.         jmp while
  12. while_end:
  13. ; Символ следущей строки, не обязательно, Dos
  14. ; автоматически переводит курсор на новую строку
  15. mov ax, 0xE00A
  16. int 0x10
  17. ret
  18.  
  19. num_to_str:
  20.         mov [num_to_str_register_storage + 2], bp
  21.         mov bp, sp
  22.         mov [num_to_str_register_storage + 4], ax
  23.         mov [num_to_str_register_storage + 6], cx
  24.         mov [num_to_str_register_storage + 8], dx
  25.         mov ax, [bp]
  26.         mov [num_to_str_register_storage], ax
  27.         mov ax, [bp + 2]
  28.         add sp, 4
  29.         push 0
  30.         mov cx, 10
  31.         num_to_str_while:
  32.                 mov dx, 0
  33.                 div cx
  34.                 add dl, '0'
  35.                 push dx
  36.                 cmp ax, 0
  37.                 jnz num_to_str_while
  38.         push word[num_to_str_register_storage]
  39.         mov bp, [num_to_str_register_storage + 2]
  40.         mov ax, [num_to_str_register_storage + 4]
  41.         mov cx, [num_to_str_register_storage + 6]
  42.         mov dx, [num_to_str_register_storage + 8]
  43.         ret
  44.         num_to_str_register_storage resw 5
Add Comment
Please, Sign In to add comment