10000 Fixed "jc fail" instructions not working properly and updated README.md by spencer3035 · Pull Request #453 · rust-osdev/bootloader · GitHub
[go: up one dir, main page]

Skip to content

Fixed "jc fail" instructions not working properly and updated README.md #453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fixed stage 2 fail calls and removed additional asm label
  • Loading branch information
spencer3035 committed Aug 25, 2024
commit 8bc7a49fcf5f9ea9b1ba003cf45e2ffd6eccdb99
2 changes: 1 addition & 1 deletion bios/boot_sector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This executable needs to fit into the 512-byte boot sector, so we need to use al

To run in QEMU:

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

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

Expand Down
7 changes: 3 additions & 4 deletions bios/boot_sector/src/boot.s
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ check_int13h_extensions:
mov bx, 0x55aa
# dl contains drive number
int 0x13
jc fail_asm
jnc .int13_pass
call fail
.int13_pass:
pop ax # pop error code again

rust:
Expand All @@ -45,9 +47,6 @@ rust:
call first_stage
# Fail code if first stage returns
push 'x'

# Call rust "fail" function that prints the character on the top of the stack
fail_asm:
call fail

spin:
Expand Down
4 changes: 3 additions & 1 deletion bios/boot_sector/src/dap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ impl DiskAddressPacket {
"mov {1:x}, si", // backup the `si` register, whose contents are required by LLVM
"mov si, {0:x}",
"int 0x13",
"jc fail_asm",
"jnc 2f", // carry is set on fail
"call fail",
"2:",
"pop si", // remove error code again
"mov si, {1:x}", // restore the `si` register to its prior state
in(reg) self_addr,
Expand Down
6 changes: 4 additions & 2 deletions bios/stage-2/src/dap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ impl DiskAddressPacket {
pub unsafe fn perform_load(&self, disk_number: u16) {
let self_addr = self as *const Self as u16;
asm!(
"push 0x7a", // error code `z`, passed to `fail` on error
"push 'z'", // error code `z`, passed to `fail` on error
"mov {1:x}, si",
"mov si, {0:x}",
"int 0x13",
"jc fail",
"jnc 2f", // carry is set on fail
"call fail",
"2:",
"pop si", // remove error code again
"mov si, {1:x}",
in(reg) self_addr,
Expand Down
Loading
0