Guest User

Untitled

a guest
May 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. org 100h
  2. use16
  3.  
  4. mov ax, 65535
  5. call ConvertHexToString
  6. mov si, bx
  7. call print
  8. mov ah, 0x0
  9. int 0x16
  10. ret
  11.  
  12.  
  13.  
  14.  
  15. print:
  16. lodsb
  17. cmp al, 0
  18. je endP
  19. mov ah, 0xe
  20. int 10h
  21. jmp print
  22. endP:
  23. ret
  24.  
  25.  
  26. WordBuffer: times 7 db 0
  27. base dw 0x0010
  28.  
  29. ConvertHexToString:
  30. mov cx, 0 ;bug fix, cx equalled a big number threw address calculation off
  31. mov bx, WordBuffer+6 ;;address to end
  32. mov [bx], BYTE 0 ;null last letter
  33. loopCHTS:
  34.  
  35. cmp ax, 0
  36. je doneCHTS
  37.  
  38. xor dx,dx
  39. div WORD [base]
  40.  
  41. dec bx ;move down buffer
  42.  
  43.  
  44. mov [bx], BYTE dl
  45. cmp dl, 10 ;equal or above ten is a letter
  46.  
  47. jge ProcessToLetter
  48.  
  49. add [bx], BYTE '0' ;its number 0x30 + our number, say 0, is 0x30 plus 0, which is 0x30 or 0 in decimal
  50. jmp loopCHTS
  51.  
  52. ProcessToLetter:
  53. sub [bx], BYTE 10
  54. add [bx], BYTE 'A'
  55. jmp loopCHTS
  56.  
  57. doneCHTS:
  58. sub bx, 0x2
  59. mov [bx], WORD '0x'
  60. ;bx contains beginning of string
  61. ret
Add Comment
Please, Sign In to add comment