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:
@@ -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 {}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user