]> git.lizzy.rs Git - loadnothing.git/blob - stage2/src/main.rs
No arithmetic operators
[loadnothing.git] / stage2 / src / main.rs
1 #![no_std]
2 #![no_main]
3
4 #![warn(clippy::arithmetic)]
5
6 use core::arch::asm;
7 use core::ops::{Add, Mul};
8 use core::panic::PanicInfo;
9
10 static HELLO: &[u8] = b"Hello Stage2!";
11
12 #[panic_handler]
13 fn panic(_info: &PanicInfo) -> ! {
14     loop {}
15 }
16
17 #[no_mangle]
18 pub extern "C" fn _start() -> ! {
19     let vga_buffer = 0xb8000 as *mut u8;
20     let vga_max = 0xf9e;
21
22     // Clear the screen
23     for i in 0..vga_max {
24         unsafe {
25             *vga_buffer.offset((i as isize).mul(2)) = 0x00;
26             *vga_buffer.offset((i as isize).mul(2).add(1)) = 0x07;
27         }
28     }
29
30     // Print welcome message
31     for (i, &byte) in HELLO.iter().enumerate() {
32         unsafe {
33             *vga_buffer.offset((i as isize).mul(2)) = byte;
34             *vga_buffer.offset((i as isize).mul(2).add(1)) = 0x07;
35         }
36     }
37
38     unsafe {
39         loop {
40             asm!("hlt");
41         }
42     }
43 }