Return from assembly

Show calling an assembly fn and returning a value
This commit is contained in:
greg
2015-11-10 02:46:54 -08:00
parent 532d84682c
commit 8dcbdc997c
2 changed files with 7 additions and 5 deletions

View File

@@ -5,7 +5,7 @@
extern crate rlibc;
extern {
fn asm_printchar();
fn asm_printchar() -> u32;
}
@@ -13,11 +13,12 @@ extern {
pub extern fn rust_main() {
clear();
checkerboard(vga_buffer::Color::Red);
unsafe {
asm_printchar();
let a = asm_printchar();
if a == 1 {
checkerboard(vga_buffer::Color::Blue);
}
}
loop {}

View File

@@ -50,6 +50,7 @@ setup_SSE:
asm_printchar:
mov rax, 0xf056
mov [0xb8000], rax
mov [0xb8000], ax
mov rax, 0x1
ret