mirror of
https://github.com/tailix/loadwarka.git
synced 2024-11-11 13:50:54 -05:00
Move common defines to header
This commit is contained in:
parent
8d23cec33b
commit
dc5e6be490
3 changed files with 29 additions and 19 deletions
16
src/x86_common.h
Normal file
16
src/x86_common.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#define STACK_BASE 0x2000
|
||||
#define STAGE1_BASE 0x7c00
|
||||
#define STAGE2_BASE 0x7e00
|
||||
|
||||
#define DIST(x) (x - _start)
|
||||
|
||||
#define STAGE1_ADDR(x) (DIST(x) + STAGE1_BASE)
|
||||
#define STAGE2_ADDR(x) (DIST(x) + STAGE2_BASE)
|
||||
|
||||
#define STAGE1_START \
|
||||
_start: \
|
||||
ljmp $0, $STAGE1_ADDR(main)
|
||||
|
||||
#define STAGE2_START \
|
||||
_start: \
|
||||
ljmp $0, $STAGE2_ADDR(main)
|
|
@ -21,21 +21,16 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#define STACK_ADDR 0x2000
|
||||
#define STAGE1_ADDR 0x7c00
|
||||
#define STAGE2_ADDR 0x7e00
|
||||
|
||||
#define ADDRESS(x) (x - _start + STAGE1_ADDR)
|
||||
#include "x86_common.h"
|
||||
|
||||
.code16
|
||||
.global _start
|
||||
.section .text
|
||||
_start:
|
||||
ljmp $0, $ADDRESS(start)
|
||||
STAGE1_START
|
||||
|
||||
disk: .byte 0
|
||||
|
||||
start:
|
||||
main:
|
||||
cli
|
||||
xor %ax, %ax
|
||||
mov %ax, %ss
|
||||
|
@ -43,9 +38,9 @@ start:
|
|||
mov %ax, %es
|
||||
mov %ax, %fs
|
||||
mov %ax, %gs
|
||||
mov $STACK_ADDR, %sp
|
||||
mov $STACK_BASE, %sp
|
||||
|
||||
mov %dl, ADDRESS(disk)
|
||||
mov %dl, STAGE1_ADDR(disk)
|
||||
|
||||
mov $0x02, %ah
|
||||
mov $1, %al /* Sectors count */
|
||||
|
@ -53,10 +48,10 @@ start:
|
|||
mov $0, %ch /* Cylinder */
|
||||
mov $0, %dh /* Head */
|
||||
mov $2, %cl /* Cylinder and sector */
|
||||
mov $STAGE2_ADDR, %bx /* Address */
|
||||
mov $STAGE2_BASE, %bx /* Address */
|
||||
int $0x13
|
||||
|
||||
ljmp $0, $STAGE2_ADDR
|
||||
ljmp $0, $STAGE2_BASE
|
||||
|
||||
hang:
|
||||
cli
|
||||
|
|
|
@ -21,22 +21,21 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#define ADDRESS(x) (x - _start + 0x7e00)
|
||||
#include "x86_common.h"
|
||||
|
||||
.code16
|
||||
.global _start
|
||||
.section .text
|
||||
_start:
|
||||
ljmp $0, $ADDRESS(start)
|
||||
STAGE2_START
|
||||
|
||||
hello: .string "Hello, World!\r\n"
|
||||
|
||||
start:
|
||||
mov $ADDRESS(hello), %si
|
||||
main:
|
||||
mov $STAGE2_ADDR(hello), %si
|
||||
call print_str
|
||||
mov $ADDRESS(hello), %si
|
||||
mov $STAGE2_ADDR(hello), %si
|
||||
call print_str
|
||||
mov $ADDRESS(hello), %si
|
||||
mov $STAGE2_ADDR(hello), %si
|
||||
call print_str
|
||||
|
||||
hang:
|
||||
|
|
Loading…
Reference in a new issue