diff --git a/Makefile b/Makefile index dbdb766010..b8e2b8fe6f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -LD=i386-elf-ld +LD=ld RUSTC=rustc NASM=nasm QEMU=qemu-system-i386 @@ -10,7 +10,7 @@ all: floppy.img .PHONY: clean run .rs.o: - $(RUSTC) -O --target i386-intel-linux --crate-type lib -o $@ --emit obj $< + $(RUSTC) -O --target i686-unknown-linux-gnu --crate-type lib -o $@ --emit obj $< .asm.o: $(NASM) -f elf32 -o $@ $< diff --git a/main.rs b/main.rs index a4db0a9d2e..3b50c6752e 100644 --- a/main.rs +++ b/main.rs @@ -1,6 +1,16 @@ #![no_std] #![allow(ctypes)] +#![feature(lang_items)] +#[lang="sized"] +trait Sized {} + +#[lang="copy"] +trait Copy {} + +impl Copy for Color { +} + enum Color { Black = 0, Blue = 1, @@ -34,9 +44,9 @@ impl IntRange { fn next(&mut self) -> Option { if self.cur < self.max { self.cur += 1; - Some(self.cur - 1) + Option::Some(self.cur - 1) } else { - None + Option::None } } } @@ -46,15 +56,21 @@ fn range(lo: int, hi: int) -> IntRange { } fn clear_screen(background: Color) { - for i in range(0, 80 * 25) { - unsafe { - *((0xb8000 + i * 2) as *mut u16) = (background as u16) << 12; - } - } + let mut r = range(0, 80 * 25); + loop { + match r.next() { + Option::Some(x) => { + unsafe { + *((0xb8000 + x * 2) as *mut u16) = (background as u16) << 12; + } + }, + Option::None =>{break} + } + } } #[no_mangle] #[no_split_stack] pub fn main() { - clear_screen(LightRed); + clear_screen(Color::LightRed); }