Skip to content

Commit 8bc7a49

Browse files
committed
Fixed stage 2 fail calls and removed additional asm label
1 parent 81f359d commit 8bc7a49

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

bios/boot_sector/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This executable needs to fit into the 512-byte boot sector, so we need to use al
99

1010
To run in QEMU:
1111

12-
- `qemu-system-x86_64 -drive format=raw,file=../../target/disk_image.bin`
12+
- `qemu-system-x86_64 -drive format=raw,file=../../target/disk_image.img`
1313

1414
To print the contents of the ELF file, e.g. for trying to bring the size down:
1515

bios/boot_sector/src/boot.s

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ check_int13h_extensions:
3636
mov bx, 0x55aa
3737
# dl contains drive number
3838
int 0x13
39-
jc fail_asm
39+
jnc .int13_pass
40+
call fail
41+
.int13_pass:
4042
pop ax # pop error code again
4143

4244
rust:
@@ -45,9 +47,6 @@ rust:
4547
call first_stage
4648
# Fail code if first stage returns
4749
push 'x'
48-
49-
# Call rust "fail" function that prints the character on the top of the stack
50-
fail_asm:
5150
call fail
5251

5352
spin:

bios/boot_sector/src/dap.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ impl DiskAddressPacket {
4242
"mov {1:x}, si", // backup the `si` register, whose contents are required by LLVM
4343
"mov si, {0:x}",
4444
"int 0x13",
45-
"jc fail_asm",
45+
"jnc 2f", // carry is set on fail
46+
"call fail",
47+
"2:",
4648
"pop si", // remove error code again
4749
"mov si, {1:x}", // restore the `si` register to its prior state
4850
in(reg) self_addr,

bios/stage-2/src/dap.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ impl DiskAddressPacket {
3838
pub unsafe fn perform_load(&self, disk_number: u16) {
3939
let self_addr = self as *const Self as u16;
4040
asm!(
41-
"push 0x7a", // error code `z`, passed to `fail` on error
41+
"push 'z'", // error code `z`, passed to `fail` on error
4242
"mov {1:x}, si",
4343
"mov si, {0:x}",
4444
"int 0x13",
45-
"jc fail",
45+
"jnc 2f", // carry is set on fail
46+
"call fail",
47+
"2:",
4648
"pop si", // remove error code again
4749
"mov si, {1:x}",
4850
in(reg) self_addr,

0 commit comments

Comments
 (0)