Advertisement
atm959

print32Bit routine

Jul 12th, 2019
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;esi - Pointer to text
  2. ;ax - X Pos.
  3. ;bx - Y Pos.
  4. ;cl - Attrib.
  5. placeText:
  6.     mov [tempattrib], cl
  7.     mov [tempx], ax
  8.     mov ax, bx
  9.     mov bx, 160
  10.     mul bx
  11.     mov [tempy], ax
  12.     mov ax, [tempx]
  13.     mov bx, 2
  14.     mul bx
  15.     mov bx, ax
  16.     mov ax, [tempy]
  17.     add eax, ebx
  18.    
  19.     mov ecx, 0B8000h
  20.     add ecx, eax
  21. .placeTextLoop:
  22.     lodsb
  23.     cmp al, 00h
  24.     je .donePlacingText
  25.     mov [ecx], BYTE al
  26.     add ecx, 1h
  27.     mov dx, [tempattrib]
  28.     mov [ecx], dx
  29.     add ecx, 1h
  30.     jmp .placeTextLoop
  31. .donePlacingText:
  32.     ret
  33.  
  34. tempVal: dd 0
  35. andVal: dd 0
  36. shiftVal: db 0
  37. counter: dd 0
  38.  
  39. tempX: dw 0
  40. tempY: dw 0
  41.  
  42. hexString: db "00000000H", 0
  43.  
  44. ;ax - X Pos.
  45. ;bx - Y Pos.
  46. ;ecx - Value to print
  47. print32Bit:
  48.     mov [tempX], ax
  49.     mov [tempY], bx
  50.     mov [tempVal], ecx
  51.     mov [shiftVal], BYTE 28
  52.     mov [andVal], DWORD 0F0000000h
  53.     mov [counter], BYTE 00h
  54.  
  55. .copyToStringLoop:
  56.     mov eax, [tempVal]
  57.     and eax, [andVal]
  58.     mov cl, [shiftVal]
  59.     shr DWORD eax, cl
  60.  
  61.     mov ebx, hexTable
  62.     add ebx, eax
  63.  
  64.     mov ecx, hexString
  65.     mov edx, [counter]
  66.     add ecx, edx
  67.     mov dl, [ebx]
  68.     mov [ecx], dl
  69.  
  70.     sub [shiftVal], BYTE 4
  71.     shr DWORD [andVal], BYTE 4
  72.     add [counter], DWORD 1
  73.  
  74.     cmp [counter], DWORD 8
  75.     jne .copyToStringLoop
  76.    
  77.     mov ax, [tempX]
  78.     mov bx, [tempY]
  79.     mov cl, 0Fh
  80.     mov si, hexString
  81.     call placeText
  82.  
  83.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement