From a5bf7692be2697170877d6ba92f6fa076818fb6b Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Tue, 26 May 2009 15:49:49 -0400 Subject: [PATCH] A couple of minor changes. --- cfg.scm | 14 +++++++------- cte.scm | 20 ++++++++++---------- pic18.scm | 2 +- six-comp.scm | 2 ++ tests/picobit/picobit-vm-sixpic.c | 17 +++++++++-------- 5 files changed, 29 insertions(+), 26 deletions(-) diff --git a/cfg.scm b/cfg.scm index 9e22bf6..770f70f 100644 --- a/cfg.scm +++ b/cfg.scm @@ -623,7 +623,7 @@ (routine-call (string->symbol ; mul8_8, mul8_16, etc ;; for now, only unsigned multiplications are supported - (string-append "mul" + (string-append "__mul" (number->string (* lx 8)) "_" (number->string (* ly 8)))) (list x y) @@ -678,7 +678,7 @@ (loop (+ i 1) x)))))) (routine-call (string->symbol - (string-append "sh" + (string-append "__sh" (case id ((x<>y) "r")) (number->string (* 8 (length bytes1))))) (list x y) @@ -958,7 +958,7 @@ (emit (new-instr 'tblrd x0 x1 #f)) (move (get-register TABLAT) z0))) - ((mul8_8) + ((__mul8_8) (let ((x (car params)) (y (cadr params)) (z (value-bytes value))) @@ -966,7 +966,7 @@ (emit (new-instr 'mul (car (get-bytes x)) (car (get-bytes y)) #f)) (move (get-register PRODL) (car z)))) ; lsb - ((mul16_8) + ((__mul16_8) (let* ((x (get-bytes (car params))) (x0 (car x)) ; lsb (x1 (cadr x)) @@ -982,7 +982,7 @@ (move (get-register PRODL) z0) (emit (new-instr 'add (get-register PRODH) z1 z1)))) - ((mul16_16) + ((__mul16_16) (let* ((x (get-bytes (car params))) (x0 (car x)) (x1 (cadr x)) @@ -1003,7 +1003,7 @@ (emit (new-instr 'mul x1 y0 #f)) (emit (new-instr 'add (get-register PRODL) z1 z1)))) - ((mul32_16) + ((__mul32_16) (let* ((x (get-bytes (car params))) (x0 (car x)) (x1 (cadr x)) @@ -1046,7 +1046,7 @@ (emit (new-instr 'mul x3 y0 #f)) (emit (new-instr 'add (get-register PRODL) z3 z3)))) - ((shl8 shr8 shl16 shr16 shl32 shr32) + ((__shl8 __shr8 __shl16 __shr16 __shl32 __shr32) (let* ((id (symbol->string id)) (left-shift? (eq? (string-ref id 2) #\l)) (x (def-variable-value (car params))) diff --git a/cte.scm b/cte.scm index 1d401a4..52471d1 100644 --- a/cte.scm +++ b/cte.scm @@ -70,17 +70,17 @@ ;; TODO have the equivalent of FSR variabes pour TBLPTR (predefine-routine 'rom_get 'int8 '(int16)) ;; TODO actually, 21 bits of address - (predefine-routine 'mul8_8 'int8 '(int8 int8)) - (predefine-routine 'mul16_8 'int16 '(int16 int8)) ;; TODO since multiplication arguments are not padded, these asymetric operations are used, they are more efficient, but padding would mean fewer necessary routines - (predefine-routine 'mul16_16 'int16 '(int16 int16)) - (predefine-routine 'mul32_16 'int32 '(int32 int16)) + (predefine-routine '__mul8_8 'int8 '(int8 int8)) + (predefine-routine '__mul16_8 'int16 '(int16 int8)) ;; TODO since multiplication arguments are not padded, these asymetric operations are used, they are more efficient, but padding would mean fewer necessary routines + (predefine-routine '__mul16_16 'int16 '(int16 int16)) + (predefine-routine '__mul32_16 'int32 '(int32 int16)) - (predefine-routine 'shl8 'int8 '(int8 int8)) - (predefine-routine 'shl16 'int16 '(int16 int8)) - (predefine-routine 'shl32 'int32 '(int32 int8)) - (predefine-routine 'shr8 'int8 '(int8 int8)) - (predefine-routine 'shr16 'int16 '(int16 int8)) - (predefine-routine 'shr32 'int32 '(int32 int8)) + (predefine-routine '__shl8 'int8 '(int8 int8)) + (predefine-routine '__shl16 'int16 '(int16 int8)) + (predefine-routine '__shl32 'int32 '(int32 int8)) + (predefine-routine '__shr8 'int8 '(int8 int8)) + (predefine-routine '__shr16 'int16 '(int16 int8)) + (predefine-routine '__shr32 'int32 '(int32 int8)) )) (define (cte-extend cte bindings) diff --git a/pic18.scm b/pic18.scm index cc0aa96..727d5f7 100644 --- a/pic18.scm +++ b/pic18.scm @@ -586,7 +586,7 @@ (lambda () (make-listing mnemonic1 (label-text l))) ;; TODO should show mnemonic1 when it's used, or mnemonic2 (lambda () - (asm-at-assembly ;; TODO seems to mix up generation of call vs rcall, see the rom_get example FOO + (asm-at-assembly ;; TODO seems to mix up generation of call vs rcall, see the rom_get example (lambda (self) (let ((dist (- (label-pos l) (+ self 2)))) (if (and (>= dist -2048) diff --git a/six-comp.scm b/six-comp.scm index aa32b4b..40a3693 100755 --- a/six-comp.scm +++ b/six-comp.scm @@ -98,10 +98,12 @@ #t)))) (define (picobit prog #!optional (recompile? #f)) + (set! trace-instr #f) (if recompile? (main "tests/picobit/picobit-vm-sixpic.c" prog) (simulate (list "tests/picobit/picobit-vm-sixpic.c.hex" prog) "tests/picobit/picobit-vm-sixpic.c.map"))) + (define (simulate hexs map-file) (set! symbol-table (with-input-from-file map-file (lambda () (list->table (read))))) diff --git a/tests/picobit/picobit-vm-sixpic.c b/tests/picobit/picobit-vm-sixpic.c index 86ad3a4..54b1b3b 100644 --- a/tests/picobit/picobit-vm-sixpic.c +++ b/tests/picobit/picobit-vm-sixpic.c @@ -68,7 +68,7 @@ void halt_with_error (){ /* int8 rom_get_field3 (int16 o); */ int8 ram_get_gc_tags (int16 o) { int16 t2 = o - 512; - return (*(((t2 << 2))+#x200) & #x60); + return (*(((t2 << 2))+#x200) & #x60); // TODO not sure these shifts really save on code space, maybe multiplications (which would be 2 additions) would be better } int8 ram_get_gc_tag0 (int16 o) { int16 t2 = o - 512; @@ -79,16 +79,16 @@ int8 ram_get_gc_tag1 (int16 o) { return (*(((t2 << 2))+#x200) & #x40); } void ram_set_gc_tags (int16 o, int8 tags) { - int16 t2 = o - 512; - (*(((t2 << 2) + (0))+#x200) = ((*(((t2 << 2) + (0))+#x200) & #x9f) | (tags))); + int16 t2 = (o - 512) << 2; // TODO optimized a couple of things + (*((t2)+#x200) = ((*((t2)+#x200) & #x9f) | (tags))); // TODO if we could use bst and bcf, would be better } void ram_set_gc_tag0 (int16 o, int8 tag) { - int16 t2 = o - 512; - *(((t2 << 2) + (0))+#x200) = ((*(((t2 << 2) + (0))+#x200) & #xdf) | (tag)); + int16 t2 = (o - 512) << 2; // TODO same here + *(t2+#x200) = ((*(t2+#x200) & #xdf) | (tag)); } void ram_set_gc_tag1 (int16 o, int8 tag) { - int16 t2 = o - 512; - *(((t2 << 2) + (0))+#x200) = ((*(((t2 << 2) + (0))+#x200) & #xbf) | (tag)); + int16 t2 = (o - 512) << 2; // TODO same here + *(t2+#x200) = ((*(t2+#x200) & #xbf) | (tag)); } int8 ram_get_field0 (int16 o) { int16 t2 = o - 512; return *(((t2 << 2) + (0))+#x200); } int8 ram_get_field1 (int16 o) { int16 t2 = o - 512; return *(((t2 << 2) + (1))+#x200); } @@ -1751,7 +1751,8 @@ void init_ram_heap () { free_list = 0; - while (o > (512 + (glovars + 1) >> 1)) { + int16 tmp = (512 + (glovars + 1) >> 1); // TODO optimization + while (o > tmp) { ram_set_gc_tags (o, (0<<5)); -- 2.11.4.GIT