Call assembly from rust

All this does is print a V to the screen, but it means caling asm from
rust works. Remember that if this were in boot.asm, it'd be now-invalid
32 bit code and calling it would cause a page fault.
This commit is contained in:
greg
2015-11-10 02:23:56 -08:00
parent 5b84cc1457
commit 532d84682c
2 changed files with 18 additions and 0 deletions

View File

@@ -4,10 +4,21 @@
extern crate rlibc;
extern {
fn asm_printchar();
}
#[no_mangle]
pub extern fn rust_main() {
clear();
checkerboard(vga_buffer::Color::Red);
unsafe {
asm_printchar();
}
loop {}
}

View File

@@ -1,4 +1,5 @@
global long_mode_start
global asm_printchar
section .text
bits 64
@@ -46,3 +47,9 @@ setup_SSE:
.no_SSE:
mov al, "a"
jmp error
asm_printchar:
mov rax, 0xf056
mov [0xb8000], rax
ret