add print subroutine (lol im actually doing stack frame thingy here)
This commit is contained in:
parent
d8ab00c7cd
commit
3aca81ddd4
3 changed files with 46 additions and 10 deletions
5
Makefile
5
Makefile
|
|
@ -97,7 +97,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.s
|
|||
$(AS) $(ASFLAGS) -o $@ $<
|
||||
$(OBJCOPY) --remove-section .note.gnu.property $@
|
||||
|
||||
MBR_TEST_OBJ = obj/mbr_test.o
|
||||
MBR_TEST_OBJ = obj/mbr_test.o obj/print.o
|
||||
|
||||
mbr_test: $(MBR_TEST_OBJ) $(DISK)
|
||||
$(LD) -T src/mbr_test.ld -o $(BIN_DIR)/mbr_test.bin $(MBR_TEST_OBJ)
|
||||
|
|
@ -106,6 +106,9 @@ mbr_test_clean:
|
|||
rm $(BIN_DIR)/mbr_test.bin
|
||||
rm $(OBJ_DIR)/mbr_test.o
|
||||
|
||||
mbr_test_objdump:
|
||||
objdump -b binary -mi386 -Maddr16,data16 -D $(BIN_DIR)/mbr_test.bin
|
||||
|
||||
mbr_test_qemu: mbr_test
|
||||
$(QEMU) -accel tcg,thread=single \
|
||||
-cpu core2duo \
|
||||
|
|
|
|||
|
|
@ -24,17 +24,15 @@
|
|||
# far jump to new memory region
|
||||
jmp $0x0050,$.bootloader
|
||||
.bootloader:
|
||||
# initialize stack
|
||||
mov $0x07DF, %ax
|
||||
mov %ax, %ss
|
||||
xor %sp, %sp
|
||||
|
||||
mov $msg, %si
|
||||
.putc_loop:
|
||||
lodsb
|
||||
or %al, %al
|
||||
jz .halt
|
||||
.entry:
|
||||
push $msg
|
||||
call print
|
||||
|
||||
mov $0x0E, %ah
|
||||
mov $0x00, %bh
|
||||
int $0x10
|
||||
jmp .putc_loop
|
||||
.halt:
|
||||
jmp .halt
|
||||
|
||||
|
|
|
|||
35
src/print.s
Normal file
35
src/print.s
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
.section .text
|
||||
.code16
|
||||
|
||||
.globl print
|
||||
|
||||
# (%bp) - old bp
|
||||
# 2(%bp) - ret addr
|
||||
# 4(%bp) - arg 1
|
||||
|
||||
# arg 1 - string addr
|
||||
print:
|
||||
push %bp
|
||||
mov %sp, %bp
|
||||
|
||||
push %bx
|
||||
push %si
|
||||
|
||||
mov 4(%bp), %si
|
||||
cld
|
||||
.putc:
|
||||
lodsb
|
||||
or %al, %al
|
||||
jz .end
|
||||
|
||||
mov $0x0E, %ah
|
||||
xor %bh, %bh
|
||||
int $0x10
|
||||
jmp .putc
|
||||
.end:
|
||||
|
||||
pop %si
|
||||
pop %bx
|
||||
|
||||
pop %bp
|
||||
ret
|
||||
Loading…
Add table
Reference in a new issue