c hello world: ok, I dont know how to debug this further
This commit is contained in:
@@ -252,6 +252,14 @@ Source: link:c_hello_world[]
|
||||
|
||||
Single stage, so still limited to 512 bytes of code + data!
|
||||
|
||||
To disassemble the generated C code, try:
|
||||
|
||||
....
|
||||
objdump -D -m i8086 main.elf
|
||||
....
|
||||
|
||||
TODO: I see several `eax` references still, why?
|
||||
|
||||
=== No linker script
|
||||
|
||||
Print `hello world` without using an explitic linker script:
|
||||
|
||||
1
c_hello_world/README.adoc
Normal file
1
c_hello_world/README.adoc
Normal file
@@ -0,0 +1 @@
|
||||
https://github.com/cirosantilli/x86-bare-metal-examples#c-hello-world
|
||||
@@ -2,5 +2,5 @@
|
||||
.text
|
||||
.global mystart
|
||||
mystart:
|
||||
mov %sp, __stack_top
|
||||
mov $__stack_top, %sp
|
||||
call main
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
void main(void) {
|
||||
int i;
|
||||
char s[] = "hello world";
|
||||
/* Add a bunch of debug prints to see if the control loop is correct. It is. */
|
||||
__asm__ ("mov $0x0E40, %ax; int $0x10");
|
||||
for (i = 0; i < sizeof(s); ++i) {
|
||||
__asm__ ("mov $0x0E41, %ax; int $0x10");
|
||||
__asm__ (
|
||||
"mov %0, %%ax; int $0x10"
|
||||
:
|
||||
@@ -9,6 +12,7 @@ void main(void) {
|
||||
: "%ax"
|
||||
);
|
||||
}
|
||||
__asm__ ("mov $0x0E40, %ax; int $0x10");
|
||||
while (1) {
|
||||
__asm__ ("hlt");
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user