]> git.lizzy.rs Git - loadnothing.git/commitdiff
No arithmetic operators
authorHimbeerserverDE <himbeerserverde@gmail.com>
Sun, 18 Sep 2022 14:00:25 +0000 (16:00 +0200)
committerHimbeerserverDE <himbeerserverde@gmail.com>
Sun, 18 Sep 2022 14:00:25 +0000 (16:00 +0200)
stage2/src/main.rs

index 2c663a35d5cfd32c2dc8bfbd07b22fa07136b0f5..33e691cb47320141c986e02a2359f640fc8d6f36 100644 (file)
@@ -1,7 +1,10 @@
 #![no_std]
 #![no_main]
 
+#![warn(clippy::arithmetic)]
+
 use core::arch::asm;
+use core::ops::{Add, Mul};
 use core::panic::PanicInfo;
 
 static HELLO: &[u8] = b"Hello Stage2!";
@@ -19,16 +22,16 @@ pub extern "C" fn _start() -> ! {
     // Clear the screen
     for i in 0..vga_max {
         unsafe {
-            *vga_buffer.offset(i as isize * 2) = 0x00;
-            *vga_buffer.offset(i as isize * 2 + 1) = 0x07;
+            *vga_buffer.offset((i as isize).mul(2)) = 0x00;
+            *vga_buffer.offset((i as isize).mul(2).add(1)) = 0x07;
         }
     }
 
     // Print welcome message
     for (i, &byte) in HELLO.iter().enumerate() {
         unsafe {
-            *vga_buffer.offset(i as isize * 2) = byte;
-            *vga_buffer.offset(i as isize * 2 + 1) = 0x07;
+            *vga_buffer.offset((i as isize).mul(2)) = byte;
+            *vga_buffer.offset((i as isize).mul(2).add(1)) = 0x07;
         }
     }