1 %define CURRENT_ADDR cs:di
4 pusha ; push all regs to stack
5 mov di, HEX_OUT+5 ; set destination index to last char in HEX_OUT
6 mov ax, dx ; copy argument to accumulator
7 and al, 00001111b ; extract the low nibble of the low half of the accumulator
8 call .compare ; fill in the string with correct value
9 dec di ; decrement destination index
10 mov ax, dx ; copy argument to accumulator
11 and al, 11110000b ; extract high nibble of low half of accumulator
12 shr al, 4 ; shift high nibble to low nibble
13 call .compare ; fill in string with correct value
15 mov al, ah ; copy high portion of accumulator to low
23 jmp .write ; write string
26 popa ; get back our arguments
29 pusha ; save registers
30 mov al, 1 ; update cursor
31 mov bh, 0 ; page number
32 mov bl, 00000111b ; colors
33 mov cx, 6 ; length of string
34 push cs ; push code segment address
35 pop es ; pop to extra segment address
36 mov bp, HEX_OUT ; offset to extra segment of string
37 mov ah, 13h ; write string
38 int 10h ; BIOS interrupt
43 cmp al, 0 ; compare al with 0
44 jne .one ; if not equal, compare with 1
45 mov byte [CURRENT_ADDR], '0' ; set character to ASCII 0
50 mov byte [CURRENT_ADDR], '1'
55 mov byte [CURRENT_ADDR], '2'
60 mov byte [CURRENT_ADDR], '3'
65 mov byte [CURRENT_ADDR], '4'
70 mov byte [CURRENT_ADDR], '5'
75 mov byte [CURRENT_ADDR], '6'
80 mov byte [CURRENT_ADDR], '7'
85 mov byte [CURRENT_ADDR], '8'
90 mov byte [CURRENT_ADDR], '9'
95 mov byte [CURRENT_ADDR], 'A'
100 mov byte [CURRENT_ADDR], 'B'
105 mov byte [CURRENT_ADDR], 'C'
110 mov byte [CURRENT_ADDR], 'D'
115 mov byte [CURRENT_ADDR], 'E'
118 mov byte [CURRENT_ADDR], 'F'