Mercurial > lcfOS
changeset 360:42343d189e14
Bugfix in for loop
author | Windel Bouwman |
---|---|
date | Fri, 14 Mar 2014 16:11:32 +0100 |
parents | b4ac28efcdf4 |
children | 614a7f6d4d4d |
files | kernel/src/io.c3 kernel/src/kernel.c3 python/ppci/c3/codegenerator.py python/ppci/target/arm/instructions.py python/ppci/target/arm/selector.py |
diffstat | 5 files changed, 24 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- 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); +} +
--- 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();
--- 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:
--- 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
--- 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)