c hello world: ok, I dont know how to debug this further

This commit is contained in:
Ciro Santilli
2018-12-03 00:39:26 +00:00
parent d996a9764f
commit 589240ebd1
4 changed files with 14 additions and 1 deletions

View File

@@ -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:

View File

@@ -0,0 +1 @@
https://github.com/cirosantilli/x86-bare-metal-examples#c-hello-world

View File

@@ -2,5 +2,5 @@
.text
.global mystart
mystart:
mov %sp, __stack_top
mov $__stack_top, %sp
call main

View File

@@ -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");
};