2022-01-26 15:19:39 -05:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2022-01-26 17:43:18 -05:00
|
|
|
|
2022-01-26 15:19:39 -05:00
|
|
|
.code16
|
|
|
|
.global _start
|
|
|
|
.section .text
|
2022-01-26 18:16:14 -05:00
|
|
|
_start:
|
2022-01-26 20:46:04 -05:00
|
|
|
ljmp $0, $main
|
2022-01-26 17:43:18 -05:00
|
|
|
|
2022-01-26 19:30:53 -05:00
|
|
|
.align 2
|
2022-01-26 19:21:22 -05:00
|
|
|
size: .word _end - _start
|
|
|
|
|
2022-01-26 20:28:33 -05:00
|
|
|
hello2: .string "Hello from stage 2!\r\n"
|
|
|
|
hello3: .string "Hello from sector 3!\r\n"
|
2022-01-26 20:51:26 -05:00
|
|
|
hello4: .string "Hello from sector 4!\r\n"
|
2022-01-26 17:43:18 -05:00
|
|
|
|
2022-01-26 18:03:47 -05:00
|
|
|
main:
|
2022-01-26 20:46:04 -05:00
|
|
|
mov $hello2, %si
|
2022-01-26 17:43:18 -05:00
|
|
|
call print_str
|
2022-01-26 15:19:39 -05:00
|
|
|
|
2022-01-26 20:51:26 -05:00
|
|
|
mov $teststr3, %si
|
2022-01-26 20:06:12 -05:00
|
|
|
call print_str
|
|
|
|
|
2022-01-26 20:51:26 -05:00
|
|
|
mov $teststr4, %si
|
|
|
|
call print_str
|
|
|
|
|
|
|
|
ljmp $0, $sector3
|
2022-01-26 17:43:18 -05:00
|
|
|
|
|
|
|
do_ret:
|
|
|
|
ret
|
|
|
|
|
2022-01-26 19:26:54 -05:00
|
|
|
// AL - char
|
2022-01-26 17:43:18 -05:00
|
|
|
print_char:
|
|
|
|
mov $0x0E, %ah
|
|
|
|
mov $0x0001, %bx
|
|
|
|
int $0x10
|
2022-01-26 19:36:10 -05:00
|
|
|
ret
|
2022-01-26 17:43:18 -05:00
|
|
|
|
2022-01-26 19:26:54 -05:00
|
|
|
// SI - string pointer
|
2022-01-26 17:43:18 -05:00
|
|
|
print_str:
|
|
|
|
lodsb
|
|
|
|
test %al, %al
|
|
|
|
jz do_ret
|
|
|
|
call print_char
|
|
|
|
jmp print_str
|
2022-01-26 19:21:22 -05:00
|
|
|
|
2022-01-26 20:51:26 -05:00
|
|
|
.fill 512, 1, 0
|
2022-01-26 20:06:12 -05:00
|
|
|
|
2022-01-26 20:51:26 -05:00
|
|
|
teststr3: .string "Test string from sector 3\r\n"
|
2022-01-26 19:47:11 -05:00
|
|
|
|
2022-01-26 20:51:26 -05:00
|
|
|
sector3:
|
2022-01-26 20:46:04 -05:00
|
|
|
mov $hello3, %si
|
2022-01-26 20:28:33 -05:00
|
|
|
call print_str
|
|
|
|
|
2022-01-26 20:51:26 -05:00
|
|
|
ljmp $0, $sector4
|
|
|
|
|
|
|
|
.fill 512, 1, 0
|
|
|
|
|
|
|
|
teststr4: .string "Test string from sector 4\r\n"
|
|
|
|
|
|
|
|
sector4:
|
|
|
|
mov $hello4, %si
|
|
|
|
call print_str
|
|
|
|
|
2022-01-26 20:28:33 -05:00
|
|
|
hang:
|
|
|
|
cli
|
|
|
|
hlt
|
|
|
|
jmp hang
|
|
|
|
|
2022-01-26 19:21:22 -05:00
|
|
|
_end:
|