summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2015-03-25 23:35:27 -0700
committeriximeow <me@iximeow.net>2015-09-28 03:36:28 -0700
commitee0006e83551c2bd342d84dae6b48b4fe6043d46 (patch)
tree872624845f5924cc867cc377357df18a5e4d8b44 /src
parent706382780b5226bde3d0846054490fe3c205de4a (diff)
add hex printing...ish
Diffstat (limited to 'src')
-rw-r--r--src/kernel/main.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/kernel/main.c b/src/kernel/main.c
index ec18738..c1c6ab6 100644
--- a/src/kernel/main.c
+++ b/src/kernel/main.c
@@ -5,20 +5,44 @@ void vga_graphics_write(char);
void vga_graphics_write_with_attr(char, char);
void vga_graphics_write_str(char*);
+void vga_graphics_byte_hex(char);
+//void vga_graphics_short_hex(short);
+//void vga_graphics_int_hex(int);
+//void vga_graphics_long_hex(long);
+
+void clear();
+
static short CURSOR_LOC = 0;
+static char* HEX_CHARS = "0123456789abcdef";
+char foo[] = "hello how are you";
void _start() {
+ clear();
vga_graphics_write_with_attr('a', 1);
vga_graphics_write_with_attr('/', 2);
vga_graphics_write_with_attr('b', 3);
- char foo[] = "hello how are you";
vga_graphics_write_str(foo);
+ vga_graphics_write(':');
+ vga_graphics_write(' ');
+ vga_graphics_byte_hex(0x40);
while(1) { }
}
+void clear() {
+ int TERM_WIDTH = 80;
+ int TERM_HEIGHT = 25;
+
+ int i = 0;
+ while(i < TERM_WIDTH * TERM_HEIGHT) {
+ vga_graphics_write_with_attr(' ', 7);
+ i++;
+ }
+ CURSOR_LOC = 0;
+}
+
void vga_graphics_write_str(char* str) {
while(*str) {
- vga_graphics_write(*str++);
+ vga_graphics_write_with_attr(*str++, 7);
}
}
@@ -32,6 +56,13 @@ void vga_graphics_write(char value) {
CURSOR_LOC += 2;
}
+void vga_graphics_byte_hex(char value) {
+ char low = value & 0x0f;
+ char high = (value & 0xf0) >> 4;
+ vga_graphics_write(HEX_CHARS[high]);
+ vga_graphics_write(HEX_CHARS[low]);
+}
+
void vga_graphics_write_at_offset(char value, short offset) {
__asm__(
"mov %0, %%al \n"