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!
|
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
|
=== No linker script
|
||||||
|
|
||||||
Print `hello world` without using an explitic 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
|
.text
|
||||||
.global mystart
|
.global mystart
|
||||||
mystart:
|
mystart:
|
||||||
mov %sp, __stack_top
|
mov $__stack_top, %sp
|
||||||
call main
|
call main
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
void main(void) {
|
void main(void) {
|
||||||
int i;
|
int i;
|
||||||
char s[] = "hello world";
|
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) {
|
for (i = 0; i < sizeof(s); ++i) {
|
||||||
|
__asm__ ("mov $0x0E41, %ax; int $0x10");
|
||||||
__asm__ (
|
__asm__ (
|
||||||
"mov %0, %%ax; int $0x10"
|
"mov %0, %%ax; int $0x10"
|
||||||
:
|
:
|
||||||
@@ -9,6 +12,7 @@ void main(void) {
|
|||||||
: "%ax"
|
: "%ax"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
__asm__ ("mov $0x0E40, %ax; int $0x10");
|
||||||
while (1) {
|
while (1) {
|
||||||
__asm__ ("hlt");
|
__asm__ ("hlt");
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user