From fa0fa9271012ae487288ecee206c68cf4d3df9bf Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Fri, 8 Jul 2022 22:22:42 +0200 Subject: Rewrite access in terms of get-byte - This changes happens to slow down the whole system a lot. Also add a test for the PC. --- bytepusher.scm | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/bytepusher.scm b/bytepusher.scm index 9c8b96b..7e08e2b 100644 --- a/bytepusher.scm +++ b/bytepusher.scm @@ -40,9 +40,7 @@ ;; memory ---- (define (get-pc) - (+ (ash (get-byte 4) 0) - (ash (get-byte 3) 8) - (ash (get-byte 2) 16))) + (get-addr 2)) (define (set-pc! value) (set-byte! 4 (ash value 0)) @@ -50,11 +48,12 @@ (set-byte! 2 (ash value -16))) (define (get-addr pos) - (+ (bytevector-u16-ref memory (+ 1 pos) (endianness big)) - (ash (bytevector-u8-ref memory pos) 16))) + (+ (ash (get-byte (+ 2 pos)) 0) + (ash (get-byte (+ 1 pos)) 8) + (ash (get-byte pos) 16))) (define (get-initial-pixel) - (ash (bytevector-u8-ref memory 5) 16)) + (ash (get-byte 5) 16)) (define (get-sample) (bytevector-u16-ref memory 6 (endianness big))) @@ -204,3 +203,14 @@ (sdl-quit)) ;; ---- main operation + + +;; tests ---- +(define (test-pc) + (for-each + (lambda (addr) + (set-pc! addr) + (when (not (= (get-pc) addr)) + (error "Error in set pc"))) + (iota #x1000000))) +;; ---- tests -- cgit v1.2.3