forked from PoliEcho-holding-org/kern
After C Switch
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
[bits 32]
|
||||
[global _start]
|
||||
|
||||
[extern main]
|
||||
|
||||
_start:
|
||||
call main
|
||||
cli
|
||||
hlt
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "screen.h"
|
||||
|
||||
void main() {
|
||||
print("Hello, World!", 0x0f);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#include "screen.h"
|
||||
|
||||
unsigned int cursor = 0;
|
||||
|
||||
void putc(char c, char attr) {
|
||||
int mem = VIDMEM + cursor * 2;
|
||||
*(char*)(mem) = c;
|
||||
*(char*)(mem+1) = attr;
|
||||
|
||||
cursor++;
|
||||
}
|
||||
|
||||
void print(char* s, char attr) {
|
||||
int i = 0;
|
||||
char c = *s;
|
||||
while (c != '\0') {
|
||||
putc(c, attr);
|
||||
c = *(s + ++i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef SCREEN_H
|
||||
#define SCREEN_H
|
||||
|
||||
#define VIDMEM 0xb8000
|
||||
|
||||
void putc(char c, char attr);
|
||||
void print(char* s, char attr);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user