1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
[bits 32]
VIDEO_MEM equ 0xb8000
WHITE_ON_BLACK equ 0x0f
;global data
STR_HEX_OUT_PM:
db "0x0000",0
; print [ebx] at ecx
print_string_pm:
pusha
mov edx, VIDEO_MEM
add edx,ecx
print_string_pm_loop:
mov al,[ebx]
mov ah, WHITE_ON_BLACK
cmp al,0
je print_string_pm_done
mov [edx],ax
add ebx,1
add edx,2
jmp print_string_pm_loop
print_string_pm_done:
popa
ret
;print_hex_pm routine (dx) at ecx
;will print the value of the bx register as hex to the screen
print_hex_pm:
pusha
;begin with last hex val (hex_out[5])
mov bx,STR_HEX_OUT_PM+5
;lets loop throuth all 4 'digits'
print_hex_pm_loop:
;get least significan hex digit to cx
mov cx,dx
and cx,0x000F
;check range (0-9 vs a-f)
cmp cx,10
jl print_hex_pm_setnum
;set hex a-f
mov al,'A'-10
add al,cl
jmp print_hex_pm_al
;set hex 0-9
print_hex_pm_setnum:
mov al,'0'
add al,cl
; set hex_out[bx] to al
print_hex_pm_al:
mov [bx],al
;proceed with the next significant hex 'digit'
dec bx
shr dx,4
;check if finished (otherwise loop)
cmp bx,STR_HEX_OUT_PM+1
jne print_hex_pm_loop
;output complete hex string and return to caller
popa
mov bx,STR_HEX_OUT_PM
call print_string_pm
ret
|