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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
| TI_GDT equ 0 RPL0 equ 0 SELECTOR_VIDEO equ (0x0003<<3) + TI_GDT + RPL0
[bits 32] section .text
global put_char put_char: pushad mov ax, SELECTOR_VIDEO mov gs, ax
mov dx, 0x03d4 mov al, 0x0e out dx, al mov dx, 0x03d5 in al, dx mov ah, al
mov dx, 0x03d4 mov al, 0x0f out dx, al mov dx, 0x03d5 in al, dx
mov bx, ax mov ecx, [esp + 36] cmp cl, 0xd jz .is_carriage_return cmp cl, 0xa jz .is_line_feed
cmp cl, 0x8 jz .is_backspace jmp .put_other
.is_backspace:
dec bx shl bx,1 mov byte [gs:bx], 0x20 inc bx mov byte [gs:bx], 0x07 shr bx,1 jmp .set_cursor
.put_other: shl bx, 1 mov [gs:bx], cl inc bx mov byte [gs:bx],0x07 shr bx, 1 inc bx cmp bx, 2000 jl .set_cursor .is_line_feed: .is_carriage_return: xor dx, dx mov ax, bx mov si, 80 div si sub bx, dx
.is_carriage_return_end: add bx, 80 cmp bx, 2000 .is_line_feed_end: jl .set_cursor
.roll_screen: cld mov ecx, 960 mov esi, 0xc00b80a0 mov edi, 0xc00b8000 rep movsd
mov ebx, 3840 mov ecx, 80 .cls: mov word [gs:ebx], 0x0720 add ebx, 2 loop .cls mov bx,1920
.set_cursor:
mov dx, 0x03d4 mov al, 0x0e out dx, al mov dx, 0x03d5 mov al, bh out dx, al
mov dx, 0x03d4 mov al, 0x0f out dx, al mov dx, 0x03d5 mov al, bl out dx, al .put_char_done: popad ret
|