mirror of
https://github.com/tailix/loadwarka.git
synced 2024-11-11 13:50:54 -05:00
Split into sections
This commit is contained in:
parent
efd1feea42
commit
c185345dd3
6 changed files with 29 additions and 20 deletions
7
build.sh
7
build.sh
|
@ -8,9 +8,12 @@ CROSS="$BIN/i386-elf-"
|
|||
|
||||
./clean.sh
|
||||
|
||||
${CROSS}gcc -c $SRC/start.S -o $SRC/start.o
|
||||
${CROSS}gcc -c $SRC/stage1.S -o $SRC/stage1.o
|
||||
${CROSS}gcc -c $SRC/stage2.S -o $SRC/stage2.o
|
||||
${CROSS}ld -T$SRC/stage1.ld -o $SRC/stage1.bin $SRC/stage1.o
|
||||
${CROSS}ld -T$SRC/stage2.ld -o $SRC/stage2.bin $SRC/stage2.o
|
||||
|
||||
${CROSS}ld -T$SRC/stage1.ld -o $SRC/stage1.bin $SRC/start.o $SRC/stage1.o
|
||||
${CROSS}ld -T$SRC/stage2.ld -o $SRC/stage2.bin $SRC/start.o $SRC/stage2.o
|
||||
|
||||
./testyboot mbr mbr.bin $SRC/stage1.bin
|
||||
cat mbr.bin $SRC/stage2.bin > disk.img
|
||||
|
|
|
@ -4,18 +4,12 @@
|
|||
|
||||
#define STACK_BASE 0x2000
|
||||
#define STAGE2_BASE 0x7e00
|
||||
|
||||
#define DIST(x) (x - _start)
|
||||
|
||||
#define STAGE2_ADDR(x) (DIST(x) + STAGE2_BASE)
|
||||
#define STAGE2_SIZE 0x7e06
|
||||
|
||||
.code16
|
||||
.global _start
|
||||
|
||||
.section .text
|
||||
_start:
|
||||
ljmp $0, $main
|
||||
.global init
|
||||
|
||||
.section .init
|
||||
.align 2
|
||||
size: .word 0
|
||||
|
||||
|
@ -29,7 +23,7 @@ parenth: .string " ("
|
|||
of: .string " of "
|
||||
to_address: .string ") to address "
|
||||
|
||||
main:
|
||||
init:
|
||||
cli
|
||||
xor %ax, %ax
|
||||
mov %ax, %ss
|
||||
|
@ -58,14 +52,14 @@ main:
|
|||
mov $STAGE2_BASE, %bx // Address
|
||||
int $0x13
|
||||
|
||||
mov $STAGE2_ADDR(size), %bx
|
||||
mov $STAGE2_SIZE, %bx
|
||||
mov (%bx), %ax
|
||||
call print_stage2_size
|
||||
|
||||
// DX - dividend high (always zero)
|
||||
xor %dx, %dx
|
||||
// AX - dividend low
|
||||
mov $STAGE2_ADDR(size), %bx
|
||||
mov $STAGE2_SIZE, %bx
|
||||
mov (%bx), %ax
|
||||
// BX - divisor (always 512)
|
||||
mov $512, %bx
|
||||
|
|
|
@ -11,6 +11,8 @@ SECTIONS
|
|||
|
||||
.text :
|
||||
{
|
||||
*(.start);
|
||||
*(.init);
|
||||
*(.text);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,13 +3,10 @@
|
|||
#endif
|
||||
|
||||
.code16
|
||||
.global _start
|
||||
.global init
|
||||
.extern program_size
|
||||
|
||||
.section .text
|
||||
_start:
|
||||
ljmp $0, $main
|
||||
|
||||
.section .init
|
||||
.align 2
|
||||
size: .word program_size
|
||||
|
||||
|
@ -17,7 +14,7 @@ hello2: .string "Hello from stage 2!\r\n"
|
|||
hello3: .string "Hello from sector 3!\r\n"
|
||||
hello4: .string "Hello from sector 4!\r\n"
|
||||
|
||||
main:
|
||||
init:
|
||||
mov $hello2, %si
|
||||
call print_str
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ SECTIONS
|
|||
|
||||
.text :
|
||||
{
|
||||
*(.start);
|
||||
*(.init);
|
||||
*(.text);
|
||||
}
|
||||
|
||||
|
|
11
src/x86/start.S
Normal file
11
src/x86/start.S
Normal file
|
@ -0,0 +1,11 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
.code16
|
||||
.global _start
|
||||
.extern init
|
||||
|
||||
.section .start
|
||||
_start:
|
||||
ljmp $0, $init
|
Loading…
Reference in a new issue