summaryrefslogtreecommitdiff
path: root/boot/print_string_16.asm
blob: 92b4ea04773227f1c31ac9fd0e29bfc34f83f950 (plain)
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
[bits 16]

;print_string routine ([bx])
;this routine will print a null terminated string at [bx] to the screen.
print_string:

    pusha			;push all registers
    mov ah,0x0e

    print_string_loop:

	;check if value at [bx] is "\0" (end of string)
	mov cl,[bx]
	cmp cl,0
	je print_string_finish

	;otherwise instruct BIOS to print the current char
	mov al,cl
	int 0x10

	;proceed with next char
        inc bx
	jmp print_string_loop

    print_string_finish:

    popa			;pop all registers
    ret				;return to caller

print_nextline:

    pusha

    mov ah,0x3
    mov bh,0	
    int 0x10

    mov ah,0x2
    mov bh,0	
    inc dh
    mov dl,0
    int 0x10
    popa
    ret


;print byte from al to screen
 print_hex_byte: 

 pusha

   mov [.temp],al
   shr al,4
   cmp al,10
   sbb al,69h
   das
 
   mov ah,0Eh
   int 10h
 
   mov al,[.temp]
   ror al,4
   shr al,4
   cmp al,10
   sbb al,69h
   das
 
   mov ah,0Eh
   int 10h

popa
 
   ret
 
 .temp db 0