forked from AbleOS/ableos
making many tests work
This commit is contained in:
parent
bfeeff52cd
commit
56420ad5c5
|
@ -461,23 +461,22 @@ main := fn(): int {
|
||||||
height := 30
|
height := 30
|
||||||
x := 0
|
x := 0
|
||||||
y := 0
|
y := 0
|
||||||
t := 0
|
//t := 0
|
||||||
i := 0
|
i := 0
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if x < width {
|
if x < height {
|
||||||
t += set_pixel(x, y, width)
|
//t += set_pixel(x, y, height)
|
||||||
x += 1
|
x += 1
|
||||||
|
i += 1
|
||||||
} else {
|
} else {
|
||||||
x = 0
|
x = 0
|
||||||
y += 1
|
y += 1
|
||||||
if set_pixel(x, y, width) != i return 0
|
if set_pixel(x, y, height) != i return 0
|
||||||
|
if y == width break
|
||||||
}
|
}
|
||||||
|
|
||||||
i += 1
|
|
||||||
if y == width break
|
|
||||||
}
|
}
|
||||||
return t
|
return i
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -682,6 +681,8 @@ line := fn(buffer: Buffer, p0: Point, p1: Point, color: ColorBGRA, thickness: in
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if p0.y > p1.y {
|
if p0.y > p1.y {
|
||||||
|
// blah, test leading new line on directives
|
||||||
|
|
||||||
@inline(line_high, buffer, p1, p0, color)
|
@inline(line_high, buffer, p1, p0, color)
|
||||||
} else {
|
} else {
|
||||||
@inline(line_high, buffer, p0, p1, color)
|
@inline(line_high, buffer, p0, p1, color)
|
||||||
|
@ -791,21 +792,21 @@ main := fn(): int {
|
||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
|
|
||||||
//if state_change_in_break(0) != 0 {
|
if state_change_in_break(0) != 0 {
|
||||||
// return 3
|
return 3
|
||||||
//}
|
}
|
||||||
|
|
||||||
//if state_change_in_break(4) != 10 {
|
if state_change_in_break(4) != 10 {
|
||||||
// return 4
|
return 4
|
||||||
//}
|
}
|
||||||
|
|
||||||
//if continue_and_state_change(0) != 10 {
|
if continue_and_state_change(10) != 10 {
|
||||||
// return 5
|
return 5
|
||||||
//}
|
}
|
||||||
|
|
||||||
//if continue_and_state_change(3) != 0 {
|
if continue_and_state_change(3) != 0 {
|
||||||
// return 6
|
return 6
|
||||||
//}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -818,31 +819,31 @@ multiple_breaks := fn(arg: int): int {
|
||||||
return arg
|
return arg
|
||||||
}
|
}
|
||||||
|
|
||||||
//state_change_in_break := fn(arg: int): int {
|
state_change_in_break := fn(arg: int): int {
|
||||||
// loop if arg < 10 {
|
loop if arg < 10 {
|
||||||
// if arg == 3 {
|
if arg == 3 {
|
||||||
// arg = 0
|
arg = 0
|
||||||
// break
|
break
|
||||||
// }
|
}
|
||||||
// arg += 1
|
arg += 1
|
||||||
// } else break
|
} else break
|
||||||
// return arg
|
return arg
|
||||||
//}
|
}
|
||||||
|
|
||||||
//continue_and_state_change := fn(arg: int): int {
|
continue_and_state_change := fn(arg: int): int {
|
||||||
// loop if arg < 10 {
|
loop if arg < 10 {
|
||||||
// if arg == 2 {
|
if arg == 2 {
|
||||||
// arg = 4
|
arg = 4
|
||||||
// continue
|
continue
|
||||||
// }
|
}
|
||||||
// if arg == 3 {
|
if arg == 3 {
|
||||||
// arg = 0
|
arg = 0
|
||||||
// break
|
break
|
||||||
// }
|
}
|
||||||
// arg += 1
|
arg += 1
|
||||||
// } else break
|
} else break
|
||||||
// return arg
|
return arg
|
||||||
//}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### writing_into_string
|
#### writing_into_string
|
||||||
|
|
|
@ -1581,7 +1581,7 @@ impl Codegen {
|
||||||
let signed = ty.is_signed();
|
let signed = ty.is_signed();
|
||||||
|
|
||||||
if let Loc::Ct { value: CtValue(mut imm), derefed } = right.loc
|
if let Loc::Ct { value: CtValue(mut imm), derefed } = right.loc
|
||||||
&& let Some(oper) = op.imm_math_op(signed, size)
|
&& let Some(oper) = op.imm_binop(signed, size)
|
||||||
{
|
{
|
||||||
if derefed {
|
if derefed {
|
||||||
let mut dst = [0u8; 8];
|
let mut dst = [0u8; 8];
|
||||||
|
@ -1634,7 +1634,7 @@ impl Codegen {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(op) = op.math_op(signed, size) {
|
if let Some(op) = op.binop(signed, size) {
|
||||||
self.ci.emit(op(dst.get(), lhs.get(), rhs.get()));
|
self.ci.emit(op(dst.get(), lhs.get(), rhs.get()));
|
||||||
self.ci.regs.free(lhs);
|
self.ci.regs.free(lhs);
|
||||||
self.ci.regs.free(rhs);
|
self.ci.regs.free(rhs);
|
||||||
|
@ -1963,7 +1963,7 @@ impl Codegen {
|
||||||
let lhs = self.loc_to_reg(left, size);
|
let lhs = self.loc_to_reg(left, size);
|
||||||
|
|
||||||
if let Loc::Ct { value, derefed: false } = right
|
if let Loc::Ct { value, derefed: false } = right
|
||||||
&& let Some(op) = op.imm_math_op(signed, size)
|
&& let Some(op) = op.imm_binop(signed, size)
|
||||||
{
|
{
|
||||||
self.ci.emit(op(lhs.get(), lhs.get(), value.0));
|
self.ci.emit(op(lhs.get(), lhs.get(), value.0));
|
||||||
return Some(if let Some(value) = ctx.into_value() {
|
return Some(if let Some(value) = ctx.into_value() {
|
||||||
|
@ -1976,7 +1976,7 @@ impl Codegen {
|
||||||
|
|
||||||
let rhs = self.loc_to_reg(right, size);
|
let rhs = self.loc_to_reg(right, size);
|
||||||
|
|
||||||
if let Some(op) = op.math_op(signed, size) {
|
if let Some(op) = op.binop(signed, size) {
|
||||||
self.ci.emit(op(lhs.get(), lhs.get(), rhs.get()));
|
self.ci.emit(op(lhs.get(), lhs.get(), rhs.get()));
|
||||||
self.ci.regs.free(rhs);
|
self.ci.regs.free(rhs);
|
||||||
return if let Some(value) = ctx.into_value() {
|
return if let Some(value) = ctx.into_value() {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::instrs;
|
use crate::{instrs, EncodedInstr};
|
||||||
|
|
||||||
const fn ascii_mask(chars: &[u8]) -> u128 {
|
const fn ascii_mask(chars: &[u8]) -> u128 {
|
||||||
let mut eq = 0;
|
let mut eq = 0;
|
||||||
|
@ -171,10 +171,7 @@ pub enum TokenKind {
|
||||||
|
|
||||||
impl TokenKind {
|
impl TokenKind {
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
pub fn cond_op(
|
pub fn cond_op(self, signed: bool) -> Option<(fn(u8, u8, i16) -> EncodedInstr, bool)> {
|
||||||
self,
|
|
||||||
signed: bool,
|
|
||||||
) -> Option<(fn(u8, u8, i16) -> (usize, [u8; instrs::MAX_SIZE]), bool)> {
|
|
||||||
Some((
|
Some((
|
||||||
match self {
|
match self {
|
||||||
Self::Le if signed => instrs::jgts,
|
Self::Le if signed => instrs::jgts,
|
||||||
|
@ -193,12 +190,7 @@ impl TokenKind {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::type_complexity)]
|
pub fn binop(self, signed: bool, size: u32) -> Option<fn(u8, u8, u8) -> EncodedInstr> {
|
||||||
pub fn math_op(
|
|
||||||
self,
|
|
||||||
signed: bool,
|
|
||||||
size: u32,
|
|
||||||
) -> Option<fn(u8, u8, u8) -> (usize, [u8; instrs::MAX_SIZE])> {
|
|
||||||
use instrs::*;
|
use instrs::*;
|
||||||
|
|
||||||
macro_rules! div { ($($op:ident),*) => {[$(|a, b, c| $op(a, 0, b, c)),*]}; }
|
macro_rules! div { ($($op:ident),*) => {[$(|a, b, c| $op(a, 0, b, c)),*]}; }
|
||||||
|
@ -225,11 +217,7 @@ impl TokenKind {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
pub fn imm_math_op(
|
pub fn imm_binop(self, signed: bool, size: u32) -> Option<fn(u8, u8, u64) -> EncodedInstr> {
|
||||||
self,
|
|
||||||
signed: bool,
|
|
||||||
size: u32,
|
|
||||||
) -> Option<fn(u8, u8, u64) -> (usize, [u8; instrs::MAX_SIZE])> {
|
|
||||||
use instrs::*;
|
use instrs::*;
|
||||||
macro_rules! def_op {
|
macro_rules! def_op {
|
||||||
($name:ident |$a:ident, $b:ident, $c:ident| $($tt:tt)*) => {
|
($name:ident |$a:ident, $b:ident, $c:ident| $($tt:tt)*) => {
|
||||||
|
@ -275,15 +263,15 @@ impl TokenKind {
|
||||||
matches!(self, S::Eq | S::Ne | S::Bor | S::Xor | S::Band | S::Add | S::Mul)
|
matches!(self, S::Eq | S::Ne | S::Bor | S::Xor | S::Band | S::Add | S::Mul)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply(self, a: i64, b: i64) -> i64 {
|
pub fn apply_binop(self, a: i64, b: i64) -> i64 {
|
||||||
match self {
|
match self {
|
||||||
TokenKind::Add => a.wrapping_add(b),
|
Self::Add => a.wrapping_add(b),
|
||||||
TokenKind::Sub => a.wrapping_sub(b),
|
Self::Sub => a.wrapping_sub(b),
|
||||||
TokenKind::Mul => a.wrapping_mul(b),
|
Self::Mul => a.wrapping_mul(b),
|
||||||
TokenKind::Div => a.wrapping_div(b),
|
Self::Div => a.wrapping_div(b),
|
||||||
TokenKind::Shl => a.wrapping_shl(b as _),
|
Self::Shl => a.wrapping_shl(b as _),
|
||||||
TokenKind::Eq => (a == b) as i64,
|
Self::Eq => (a == b) as i64,
|
||||||
TokenKind::Band => a & b,
|
Self::Band => a & b,
|
||||||
s => todo!("{s}"),
|
s => todo!("{s}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,6 +281,20 @@ impl TokenKind {
|
||||||
&& self.precedence() != Self::Gt.precedence()
|
&& self.precedence() != Self::Gt.precedence()
|
||||||
&& self.precedence() != Self::Eof.precedence()
|
&& self.precedence() != Self::Eof.precedence()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn unop(&self) -> Option<fn(u8, u8) -> EncodedInstr> {
|
||||||
|
Some(match self {
|
||||||
|
Self::Sub => instrs::neg,
|
||||||
|
_ => return None,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn apply_unop(&self, value: i64) -> i64 {
|
||||||
|
match self {
|
||||||
|
Self::Sub => value.wrapping_neg(),
|
||||||
|
s => todo!("{s}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gen_token_kind! {
|
gen_token_kind! {
|
||||||
|
|
|
@ -251,6 +251,8 @@ mod ty {
|
||||||
let (oa, ob) = (Self(self.0.min(ob.0)), Self(self.0.max(ob.0)));
|
let (oa, ob) = (Self(self.0.min(ob.0)), Self(self.0.max(ob.0)));
|
||||||
let (a, b) = (oa.strip_pointer(), ob.strip_pointer());
|
let (a, b) = (oa.strip_pointer(), ob.strip_pointer());
|
||||||
Some(match () {
|
Some(match () {
|
||||||
|
_ if oa == Self::from(NEVER) => ob,
|
||||||
|
_ if ob == Self::from(NEVER) => oa,
|
||||||
_ if oa == ob => oa,
|
_ if oa == ob => oa,
|
||||||
_ if oa.is_pointer() && ob.is_pointer() => return None,
|
_ if oa.is_pointer() && ob.is_pointer() => return None,
|
||||||
_ if a.is_signed() && b.is_signed() || a.is_unsigned() && b.is_unsigned() => ob,
|
_ if a.is_signed() && b.is_signed() || a.is_unsigned() && b.is_unsigned() => ob,
|
||||||
|
@ -467,9 +469,14 @@ mod ty {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type EncodedInstr = (usize, [u8; instrs::MAX_SIZE]);
|
||||||
type Offset = u32;
|
type Offset = u32;
|
||||||
type Size = u32;
|
type Size = u32;
|
||||||
|
|
||||||
|
fn emit(out: &mut Vec<u8>, (len, instr): EncodedInstr) {
|
||||||
|
out.extend_from_slice(&instr[..len]);
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash)]
|
#[derive(PartialEq, Eq, Hash)]
|
||||||
struct SymKey {
|
struct SymKey {
|
||||||
file: u32,
|
file: u32,
|
||||||
|
@ -606,10 +613,6 @@ struct Types {
|
||||||
arrays: Vec<Array>,
|
arrays: Vec<Array>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn emit(out: &mut Vec<u8>, (len, instr): (usize, [u8; instrs::MAX_SIZE])) {
|
|
||||||
out.extend_from_slice(&instr[..len]);
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Types {
|
impl Types {
|
||||||
fn assemble(&mut self, to: &mut Vec<u8>) {
|
fn assemble(&mut self, to: &mut Vec<u8>) {
|
||||||
emit(to, instrs::jal(reg::RET_ADDR, reg::ZERO, 0));
|
emit(to, instrs::jal(reg::RET_ADDR, reg::ZERO, 0));
|
||||||
|
@ -1462,7 +1465,10 @@ fn test_run_vm(out: &[u8], output: &mut String) {
|
||||||
let mut stack = [0_u64; 1024 * 20];
|
let mut stack = [0_u64; 1024 * 20];
|
||||||
|
|
||||||
let mut vm = unsafe {
|
let mut vm = unsafe {
|
||||||
hbvm::Vm::<_, 0>::new(LoggedMem::default(), hbvm::mem::Address::new(out.as_ptr() as u64))
|
hbvm::Vm::<_, { 1024 * 100 }>::new(
|
||||||
|
LoggedMem::default(),
|
||||||
|
hbvm::mem::Address::new(out.as_ptr() as u64),
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
vm.write_reg(codegen::STACK_PTR, unsafe { stack.as_mut_ptr().add(stack.len()) } as u64);
|
vm.write_reg(codegen::STACK_PTR, unsafe { stack.as_mut_ptr().add(stack.len()) } as u64);
|
||||||
|
|
|
@ -281,7 +281,7 @@ impl<'a, 'b> Parser<'a, 'b> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
T::Directive => E::Directive {
|
T::Directive => E::Directive {
|
||||||
pos,
|
pos: pos - 1, // need to undo the directive shift
|
||||||
name: self.move_str(token),
|
name: self.move_str(token),
|
||||||
args: {
|
args: {
|
||||||
self.expect_advance(T::LParen);
|
self.expect_advance(T::LParen);
|
||||||
|
|
1332
hblang/src/son.rs
1332
hblang/src/son.rs
File diff suppressed because it is too large
Load diff
|
@ -1,10 +1,10 @@
|
||||||
main:
|
main:
|
||||||
ADDI64 r254, r254, -8d
|
ADDI64 r254, r254, -8d
|
||||||
ST r31, r254, 0a, 8h
|
ST r31, r254, 0a, 8h
|
||||||
LI64 r1, 1d
|
LI64 r1, 0d
|
||||||
LD r31, r254, 0a, 8h
|
LD r31, r254, 0a, 8h
|
||||||
ADDI64 r254, r254, 8d
|
ADDI64 r254, r254, 8d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 77
|
code size: 77
|
||||||
ret: 1
|
ret: 0
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
main:
|
main:
|
||||||
ADDI64 r254, r254, -24d
|
ADDI64 r254, r254, -16d
|
||||||
ST r31, r254, 0a, 24h
|
ST r31, r254, 0a, 16h
|
||||||
CP r32, r2
|
|
||||||
LI64 r1, 1d
|
LI64 r1, 1d
|
||||||
JNE r32, r1, :0
|
JNE r2, r1, :0
|
||||||
JMP :1
|
JMP :1
|
||||||
0: LI64 r33, 0d
|
0: LI64 r32, 0d
|
||||||
JNE r32, r33, :2
|
JNE r2, r32, :2
|
||||||
LI64 r1, 2d
|
LI64 r1, 2d
|
||||||
JMP :1
|
JMP :1
|
||||||
2: LI64 r1, 3d
|
2: LI64 r1, 3d
|
||||||
1: LD r31, r254, 0a, 24h
|
1: LD r31, r254, 0a, 16h
|
||||||
ADDI64 r254, r254, 24d
|
ADDI64 r254, r254, 16d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 130
|
code size: 127
|
||||||
ret: 2
|
ret: 2
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
main:
|
main:
|
||||||
ADDI64 r254, r254, -8d
|
ADDI64 r254, r254, -16d
|
||||||
ST r31, r254, 0a, 8h
|
ST r31, r254, 0a, 16h
|
||||||
JAL r31, r0, :foo
|
JAL r31, r0, :foo
|
||||||
|
CP r32, r1
|
||||||
LI64 r1, 0d
|
LI64 r1, 0d
|
||||||
LD r31, r254, 0a, 8h
|
LD r31, r254, 0a, 16h
|
||||||
ADDI64 r254, r254, 8d
|
ADDI64 r254, r254, 16d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
foo:
|
foo:
|
||||||
ADDI64 r254, r254, -8d
|
ADDI64 r254, r254, -8d
|
||||||
|
@ -12,6 +13,6 @@ foo:
|
||||||
LD r31, r254, 0a, 8h
|
LD r31, r254, 0a, 8h
|
||||||
ADDI64 r254, r254, 8d
|
ADDI64 r254, r254, 8d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 143
|
code size: 146
|
||||||
ret: 0
|
ret: 0
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -1,37 +1,103 @@
|
||||||
main:
|
main:
|
||||||
ADDI64 r254, r254, -24d
|
ADDI64 r254, r254, -88d
|
||||||
ST r31, r254, 0a, 24h
|
ST r31, r254, 0a, 88h
|
||||||
LI64 r2, 0d
|
LI64 r32, 0d
|
||||||
|
CP r2, r32
|
||||||
JAL r31, r0, :multiple_breaks
|
JAL r31, r0, :multiple_breaks
|
||||||
CP r32, r1
|
CP r33, r1
|
||||||
LI64 r32, 3d
|
LI64 r34, 3d
|
||||||
JEQ r32, r32, :0
|
JEQ r33, r34, :0
|
||||||
LI64 r1, 1d
|
LI64 r1, 1d
|
||||||
JMP :1
|
JMP :1
|
||||||
0: LI64 r2, 4d
|
0: LI64 r35, 4d
|
||||||
|
CP r2, r35
|
||||||
JAL r31, r0, :multiple_breaks
|
JAL r31, r0, :multiple_breaks
|
||||||
LI64 r33, 10d
|
CP r36, r1
|
||||||
JEQ r1, r33, :2
|
LI64 r37, 10d
|
||||||
|
JEQ r36, r37, :2
|
||||||
LI64 r1, 2d
|
LI64 r1, 2d
|
||||||
JMP :1
|
JMP :1
|
||||||
2: LI64 r1, 0d
|
2: CP r2, r32
|
||||||
1: LD r31, r254, 0a, 24h
|
JAL r31, r0, :state_change_in_break
|
||||||
|
CP r38, r1
|
||||||
|
JEQ r38, r32, :3
|
||||||
|
CP r1, r34
|
||||||
|
JMP :1
|
||||||
|
3: CP r2, r35
|
||||||
|
JAL r31, r0, :state_change_in_break
|
||||||
|
CP r39, r1
|
||||||
|
JEQ r39, r37, :4
|
||||||
|
CP r1, r35
|
||||||
|
JMP :1
|
||||||
|
4: CP r2, r37
|
||||||
|
JAL r31, r0, :continue_and_state_change
|
||||||
|
CP r40, r1
|
||||||
|
JEQ r40, r37, :5
|
||||||
|
LI64 r1, 5d
|
||||||
|
JMP :1
|
||||||
|
5: CP r2, r34
|
||||||
|
JAL r31, r0, :continue_and_state_change
|
||||||
|
CP r41, r1
|
||||||
|
JEQ r41, r32, :6
|
||||||
|
LI64 r1, 6d
|
||||||
|
JMP :1
|
||||||
|
6: CP r1, r32
|
||||||
|
1: LD r31, r254, 0a, 88h
|
||||||
|
ADDI64 r254, r254, 88d
|
||||||
|
JALA r0, r31, 0a
|
||||||
|
continue_and_state_change:
|
||||||
|
ADDI64 r254, r254, -40d
|
||||||
|
ST r31, r254, 0a, 40h
|
||||||
|
CP r1, r2
|
||||||
|
LI64 r32, 3d
|
||||||
|
LI64 r33, 4d
|
||||||
|
LI64 r34, 2d
|
||||||
|
LI64 r35, 10d
|
||||||
|
6: JLTU r1, r35, :0
|
||||||
|
JMP :1
|
||||||
|
0: JNE r1, r34, :2
|
||||||
|
CP r1, r33
|
||||||
|
JMP :3
|
||||||
|
2: JNE r1, r32, :4
|
||||||
|
LI64 r1, 0d
|
||||||
|
1: JMP :5
|
||||||
|
4: ADDI64 r33, r1, 1d
|
||||||
|
CP r1, r33
|
||||||
|
3: JMP :6
|
||||||
|
5: LD r31, r254, 0a, 40h
|
||||||
|
ADDI64 r254, r254, 40d
|
||||||
|
JALA r0, r31, 0a
|
||||||
|
state_change_in_break:
|
||||||
|
ADDI64 r254, r254, -24d
|
||||||
|
ST r31, r254, 0a, 24h
|
||||||
|
CP r1, r2
|
||||||
|
LI64 r32, 3d
|
||||||
|
LI64 r33, 10d
|
||||||
|
4: JLTU r1, r33, :0
|
||||||
|
JMP :1
|
||||||
|
0: JNE r1, r32, :2
|
||||||
|
LI64 r1, 0d
|
||||||
|
1: JMP :3
|
||||||
|
2: ADDI64 r1, r1, 1d
|
||||||
|
JMP :4
|
||||||
|
3: LD r31, r254, 0a, 24h
|
||||||
ADDI64 r254, r254, 24d
|
ADDI64 r254, r254, 24d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
multiple_breaks:
|
multiple_breaks:
|
||||||
ADDI64 r254, r254, -32d
|
ADDI64 r254, r254, -24d
|
||||||
ST r31, r254, 0a, 32h
|
ST r31, r254, 0a, 24h
|
||||||
CP r32, r2
|
CP r1, r2
|
||||||
CP r1, r32
|
LI64 r32, 3d
|
||||||
2: LI64 r33, 10d
|
LI64 r33, 10d
|
||||||
JLTS r1, r33, :0
|
4: JLTU r1, r33, :0
|
||||||
JMP :1
|
JMP :1
|
||||||
0: ADDI64 r34, r1, 1d
|
0: ADDI64 r1, r1, 1d
|
||||||
CP r1, r34
|
JNE r1, r32, :2
|
||||||
JMP :2
|
1: JMP :3
|
||||||
1: LD r31, r254, 0a, 32h
|
2: JMP :4
|
||||||
ADDI64 r254, r254, 32d
|
3: LD r31, r254, 0a, 24h
|
||||||
|
ADDI64 r254, r254, 24d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 278
|
code size: 704
|
||||||
ret: 0
|
ret: 0
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -1,48 +1,45 @@
|
||||||
main:
|
main:
|
||||||
ADDI64 r254, r254, -96d
|
ADDI64 r254, r254, -88d
|
||||||
ST r31, r254, 0a, 96h
|
ST r31, r254, 0a, 88h
|
||||||
JAL r31, r0, :check_platform
|
JAL r31, r0, :check_platform
|
||||||
LI64 r32, 0d
|
CP r32, r1
|
||||||
CP r33, r32
|
LI64 r33, 0d
|
||||||
LI64 r34, 30d
|
LI64 r34, 30d
|
||||||
CP r35, r34
|
LI64 r35, 100d
|
||||||
LI64 r36, 100d
|
CP r36, r33
|
||||||
CP r37, r36
|
CP r37, r33
|
||||||
CP r38, r33
|
CP r38, r33
|
||||||
CP r39, r37
|
5: JLTU r37, r34, :0
|
||||||
4: ADDI64 r40, r35, 1d
|
ADDI64 r36, r36, 1d
|
||||||
JGTS r33, r40, :0
|
|
||||||
CP r2, r33
|
CP r2, r33
|
||||||
CP r3, r33
|
CP r3, r36
|
||||||
CP r4, r37
|
CP r4, r34
|
||||||
JAL r31, r0, :set_pixel
|
JAL r31, r0, :set_pixel
|
||||||
CP r41, r37
|
CP r39, r1
|
||||||
ADDI64 r33, r33, 1d
|
JEQ r39, r38, :1
|
||||||
CP r42, r33
|
CP r1, r33
|
||||||
JMP :1
|
JMP :2
|
||||||
0: CP r2, r33
|
1: JNE r36, r35, :3
|
||||||
CP r3, r38
|
CP r1, r38
|
||||||
CP r4, r39
|
JMP :2
|
||||||
JAL r31, r0, :set_pixel
|
3: CP r37, r33
|
||||||
CP r41, r39
|
CP r40, r38
|
||||||
CP r33, r32
|
|
||||||
ADDI64 r42, r38, 1d
|
|
||||||
1: JNE r42, r41, :2
|
|
||||||
JMP :3
|
|
||||||
2: CP r35, r34
|
|
||||||
CP r37, r36
|
|
||||||
CP r38, r42
|
|
||||||
CP r39, r41
|
|
||||||
JMP :4
|
JMP :4
|
||||||
3: LD r31, r254, 0a, 96h
|
0: ADDI64 r40, r38, 1d
|
||||||
ADDI64 r254, r254, 96d
|
ADDI64 r41, r37, 1d
|
||||||
|
CP r37, r41
|
||||||
|
4: CP r38, r40
|
||||||
|
JMP :5
|
||||||
|
2: LD r31, r254, 0a, 88h
|
||||||
|
ADDI64 r254, r254, 88d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
set_pixel:
|
set_pixel:
|
||||||
ADDI64 r254, r254, -8d
|
ADDI64 r254, r254, -16d
|
||||||
ST r31, r254, 0a, 8h
|
ST r31, r254, 0a, 16h
|
||||||
LI64 r1, 0d
|
MUL64 r32, r4, r3
|
||||||
LD r31, r254, 0a, 8h
|
ADD64 r1, r32, r2
|
||||||
ADDI64 r254, r254, 8d
|
LD r31, r254, 0a, 16h
|
||||||
|
ADDI64 r254, r254, 16d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
check_platform:
|
check_platform:
|
||||||
ADDI64 r254, r254, -8d
|
ADDI64 r254, r254, -8d
|
||||||
|
@ -58,7 +55,6 @@ x86_fb_ptr:
|
||||||
LD r31, r254, 0a, 8h
|
LD r31, r254, 0a, 8h
|
||||||
ADDI64 r254, r254, 8d
|
ADDI64 r254, r254, 8d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
timed out
|
code size: 423
|
||||||
code size: 437
|
ret: 3000
|
||||||
ret: 0
|
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -1,33 +1,30 @@
|
||||||
main:
|
main:
|
||||||
ADDI64 r254, r254, -24d
|
ADDI64 r254, r254, -24d
|
||||||
ST r31, r254, 0a, 24h
|
ST r31, r254, 0a, 24h
|
||||||
LI64 r32, 10d
|
LI64 r2, 10d
|
||||||
CP r2, r32
|
|
||||||
JAL r31, r0, :add_one
|
JAL r31, r0, :add_one
|
||||||
CP r32, r1
|
CP r32, r1
|
||||||
LI64 r33, 20d
|
LI64 r2, 20d
|
||||||
CP r2, r33
|
|
||||||
JAL r31, r0, :add_two
|
JAL r31, r0, :add_two
|
||||||
ADD64 r1, r1, r32
|
CP r33, r1
|
||||||
|
ADD64 r1, r33, r32
|
||||||
LD r31, r254, 0a, 24h
|
LD r31, r254, 0a, 24h
|
||||||
ADDI64 r254, r254, 24d
|
ADDI64 r254, r254, 24d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
add_two:
|
add_two:
|
||||||
ADDI64 r254, r254, -8d
|
ADDI64 r254, r254, -8d
|
||||||
ST r31, r254, 0a, 8h
|
ST r31, r254, 0a, 8h
|
||||||
CP r1, r2
|
ADDI64 r1, r2, 2d
|
||||||
ADDI64 r1, r1, 2d
|
|
||||||
LD r31, r254, 0a, 8h
|
LD r31, r254, 0a, 8h
|
||||||
ADDI64 r254, r254, 8d
|
ADDI64 r254, r254, 8d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
add_one:
|
add_one:
|
||||||
ADDI64 r254, r254, -8d
|
ADDI64 r254, r254, -8d
|
||||||
ST r31, r254, 0a, 8h
|
ST r31, r254, 0a, 8h
|
||||||
CP r1, r2
|
ADDI64 r1, r2, 1d
|
||||||
ADDI64 r1, r1, 1d
|
|
||||||
LD r31, r254, 0a, 8h
|
LD r31, r254, 0a, 8h
|
||||||
ADDI64 r254, r254, 8d
|
ADDI64 r254, r254, 8d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 260
|
code size: 251
|
||||||
ret: 33
|
ret: 33
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -1,31 +1,29 @@
|
||||||
main:
|
main:
|
||||||
ADDI64 r254, r254, -16d
|
ADDI64 r254, r254, -8d
|
||||||
ST r31, r254, 0a, 16h
|
ST r31, r254, 0a, 8h
|
||||||
LI64 r32, 10d
|
LI64 r2, 10d
|
||||||
CP r2, r32
|
|
||||||
JAL r31, r0, :fib
|
JAL r31, r0, :fib
|
||||||
LD r31, r254, 0a, 16h
|
LD r31, r254, 0a, 8h
|
||||||
ADDI64 r254, r254, 16d
|
ADDI64 r254, r254, 8d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
fib:
|
fib:
|
||||||
ADDI64 r254, r254, -40d
|
ADDI64 r254, r254, -40d
|
||||||
ST r31, r254, 0a, 40h
|
ST r31, r254, 0a, 40h
|
||||||
CP r32, r2
|
CP r32, r2
|
||||||
LI64 r33, 2d
|
|
||||||
JGTS r32, r33, :0
|
|
||||||
LI64 r1, 1d
|
LI64 r1, 1d
|
||||||
|
LI64 r33, 2d
|
||||||
|
JGTU r32, r33, :0
|
||||||
JMP :1
|
JMP :1
|
||||||
0: ADDI64 r34, r32, -1d
|
0: SUB64 r2, r32, r1
|
||||||
CP r2, r34
|
|
||||||
JAL r31, r0, :fib
|
JAL r31, r0, :fib
|
||||||
CP r34, r1
|
CP r34, r1
|
||||||
SUB64 r35, r32, r33
|
SUB64 r2, r32, r33
|
||||||
CP r2, r35
|
|
||||||
JAL r31, r0, :fib
|
JAL r31, r0, :fib
|
||||||
ADD64 r1, r1, r34
|
CP r35, r1
|
||||||
|
ADD64 r1, r35, r34
|
||||||
1: LD r31, r254, 0a, 40h
|
1: LD r31, r254, 0a, 40h
|
||||||
ADDI64 r254, r254, 40d
|
ADDI64 r254, r254, 40d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 221
|
code size: 208
|
||||||
ret: 55
|
ret: 55
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -1,4 +1,28 @@
|
||||||
main:
|
main:
|
||||||
code size: 8
|
ADDI64 r254, r254, -8d
|
||||||
ret: 0
|
ST r31, r254, 0a, 8h
|
||||||
status: Err(Unreachable)
|
LI64 r2, 10d
|
||||||
|
JAL r31, r0, :fib
|
||||||
|
LD r31, r254, 0a, 8h
|
||||||
|
ADDI64 r254, r254, 8d
|
||||||
|
JALA r0, r31, 0a
|
||||||
|
fib:
|
||||||
|
ADDI64 r254, r254, -40d
|
||||||
|
ST r31, r254, 0a, 40h
|
||||||
|
LI64 r32, 1d
|
||||||
|
LI64 r33, 0d
|
||||||
|
CP r1, r33
|
||||||
|
CP r34, r32
|
||||||
|
2: JNE r2, r33, :0
|
||||||
|
JMP :1
|
||||||
|
0: ADD64 r35, r34, r1
|
||||||
|
SUB64 r2, r2, r32
|
||||||
|
CP r1, r34
|
||||||
|
CP r34, r35
|
||||||
|
JMP :2
|
||||||
|
1: LD r31, r254, 0a, 40h
|
||||||
|
ADDI64 r254, r254, 40d
|
||||||
|
JALA r0, r31, 0a
|
||||||
|
code size: 198
|
||||||
|
ret: 55
|
||||||
|
status: Ok(())
|
||||||
|
|
Loading…
Reference in a new issue