# HG changeset patch # User Windel Bouwman # Date 1394809892 -3600 # Node ID 42343d189e14e241d016b0ed5c3a575de49fcbd0 # Parent b4ac28efcdf4dd3666e33166b71d4c7632662529 Bugfix in for loop diff -r b4ac28efcdf4 -r 42343d189e14 kernel/src/io.c3 --- a/kernel/src/io.c3 Fri Mar 14 15:41:55 2014 +0100 +++ b/kernel/src/io.c3 Fri Mar 14 16:11:32 2014 +0100 @@ -27,15 +27,10 @@ // int txt[20]; var int b; var int c; - var int d; - d = 12; - for (b = 28; b > 0; b = b - 4) + for (b=28; b >= 0; b = b - 4) { - //c = 7; // (i >> b) & 0xF; - d = b; - c = (i >> d) & 0xF; - // c = (i >> b) & 0xF; + c = (i >> b) & 0xF; if (c < 10) { arch.putc( 48 + c ); @@ -44,10 +39,14 @@ { arch.putc( 65 - 10 + c ); } - // arch.putc( 65 ); - } - println(""); + arch.putc(10); // Newline! } +function void print2(string label, int value) +{ + print(label); + print_int(value); +} + diff -r b4ac28efcdf4 -r 42343d189e14 kernel/src/kernel.c3 --- a/kernel/src/kernel.c3 Fri Mar 14 15:41:55 2014 +0100 +++ b/kernel/src/kernel.c3 Fri Mar 14 16:11:32 2014 +0100 @@ -10,10 +10,16 @@ function void start() { arch.init(); + io.println("Welcome to lcfos!"); + io.print_int(0x1337); + io.print_int(0x1338); + io.print2("Test: ", 0x13); - io.println("Welcome to lcfos!"); - - // io.print_int(0x1337); + var int a; + for (a = 0; a < 10; a = a + 1) + { + io.print2("a = ", a); + } // process.init(); //memory:init(); diff -r b4ac28efcdf4 -r 42343d189e14 python/ppci/c3/codegenerator.py --- a/python/ppci/c3/codegenerator.py Fri Mar 14 15:41:55 2014 +0100 +++ b/python/ppci/c3/codegenerator.py Fri Mar 14 16:11:32 2014 +0100 @@ -156,6 +156,7 @@ self.gen_cond_code(code.condition, bbdo, te) self.setBlock(bbdo) self.genCode(code.statement) + self.genCode(code.final) self.emit(ir.Jump(bbtest)) self.setBlock(te) else: diff -r b4ac28efcdf4 -r 42343d189e14 python/ppci/target/arm/instructions.py --- a/python/ppci/target/arm/instructions.py Fri Mar 14 15:41:55 2014 +0100 +++ b/python/ppci/target/arm/instructions.py Fri Mar 14 16:11:32 2014 +0100 @@ -339,6 +339,9 @@ class Bgt(BranchBase): cond = GT +class Bge(BranchBase): + cond = GE + class Ble(BranchBase): cond = LE diff -r b4ac28efcdf4 -r 42343d189e14 python/ppci/target/arm/selector.py --- a/python/ppci/target/arm/selector.py Fri Mar 14 15:41:55 2014 +0100 +++ b/python/ppci/target/arm/selector.py Fri Mar 14 16:11:32 2014 +0100 @@ -2,7 +2,7 @@ from ppci.irmach import AbstractInstruction as makeIns from ppci.ir2tree import makeTree from .instructions import Str1, Mov2 -from .instructions import B, Bl, Blt, Bgt, Beq, Bne, Cmp2 +from .instructions import B, Bl, Blt, Bgt, Beq, Bne, Cmp2, Ble, Bge import pyburg from ..basetarget import Nop from ..instructionselector import InstructionSelector @@ -79,7 +79,7 @@ ntgt = self.targets[s.lab_no] ytgt = self.targets[s.lab_yes] jmp_ins = makeIns(B(ir.label_name(s.lab_no)), jumps=[ntgt]) - opnames = {'<': Blt, '>':Bgt, '==':Beq, '!=':Bne} + opnames = {'<': Blt, '>':Bgt, '==':Beq, '!=':Bne, '>=':Bge} op = opnames[s.cond](ir.label_name(s.lab_yes)) self.emit(op, jumps=[ytgt, jmp_ins]) # Explicitely add fallthrough self.emit2(jmp_ins)