Skip to content

Commit

Permalink
Make a Hello World! OS
Browse files Browse the repository at this point in the history
  • Loading branch information
rbgrouleff committed Feb 3, 2016
1 parent bc80065 commit 3b6a588
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@ extern crate rlibc;

#[no_mangle]
pub extern fn rust_main() {
let x = ["Hello", " ", "World", "!"];
let test = (0..3).flat_map(|x| 0..x).zip(0..);
let mut a = ("hello", 42);
a.1 += 1;
// ATTENTION: we have a very small stack and no guard page

let hello = b"Hello World!";
let color_byte = 0x1f; // white foreground, blue background

let mut hello_colored = [color_byte; 24];
for (i, char_byte) in hello.into_iter().enumerate() {
hello_colored[i*2] = *char_byte;
}

// write `Hello World!` to the center of the VGA text buffer
let buffer_ptr = (0xb8000 + 1988) as *mut _;
unsafe { *buffer_ptr = hello_colored };

loop{}
}

#[lang = "eh_personality"] extern fn eh_personality() {}
Expand Down

0 comments on commit 3b6a588

Please sign in to comment.