diff options
author | Andy Wingo <wingo@pobox.com> | 2009-07-24 10:12:01 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2009-07-24 10:12:01 +0200 |
commit | ccf77d955c875ce95473098af96da9e1bec0b7eb (patch) | |
tree | 5099763a4862add99f8fecb4c999689bb2c29bc3 /module/language | |
parent | 476e35728136b2d504855f3e2e4922ed72a41101 (diff) | |
download | guile-ccf77d955c875ce95473098af96da9e1bec0b7eb.tar.gz |
nlocs is now 16 bits wide
* libguile/objcodes.h (struct scm_objcode): Remove the "unused" field --
the old "nexts" -- and expand nlocs to 16 bits.
* module/language/assembly/compile-bytecode.scm (write-bytecode): Write
the nlocs as a uint16.
* module/language/assembly/decompile-bytecode.scm (decode-load-program):
Decompile 16-bit nlocs. It seems this decompilation is little-endian
:-/
* test-suite/tests/asm-to-bytecode.test: Fix up to understand nlocs as a
little-endian value. The test does the right thing regarding
endianness.
Diffstat (limited to 'module/language')
-rw-r--r-- | module/language/assembly/compile-bytecode.scm | 7 | ||||
-rw-r--r-- | module/language/assembly/decompile-bytecode.scm | 4 |
2 files changed, 8 insertions, 3 deletions
diff --git a/module/language/assembly/compile-bytecode.scm b/module/language/assembly/compile-bytecode.scm index 0a1489845..d17e00f2f 100644 --- a/module/language/assembly/compile-bytecode.scm +++ b/module/language/assembly/compile-bytecode.scm @@ -81,6 +81,10 @@ (let ((inst (car asm)) (args (cdr asm)) + (write-uint16 (case byte-order + ((1234) write-uint16-le) + ((4321) write-uint16-be) + (else (error "unknown endianness" byte-order)))) (write-uint32 (case byte-order ((1234) write-uint32-le) ((4321) write-uint32-be) @@ -92,8 +96,7 @@ ((load-program ,nargs ,nrest ,nlocs ,labels ,length ,meta . ,code) (write-byte nargs) (write-byte nrest) - (write-byte nlocs) - (write-byte 0) ;; what used to be nexts + (write-uint16 nlocs) (write-uint32 length) (write-uint32 (if meta (1- (byte-length meta)) 0)) (letrec ((i 0) diff --git a/module/language/assembly/decompile-bytecode.scm b/module/language/assembly/decompile-bytecode.scm index 56f58f750..231205d08 100644 --- a/module/language/assembly/decompile-bytecode.scm +++ b/module/language/assembly/decompile-bytecode.scm @@ -48,8 +48,10 @@ x (- x (ash 1 16))))) +;; FIXME: this is a little-endian disassembly!!! (define (decode-load-program pop) - (let* ((nargs (pop)) (nrest (pop)) (nlocs (pop)) (unused (pop)) + (let* ((nargs (pop)) (nrest (pop)) (nlocs0 (pop)) (nlocs1 (pop)) + (nlocs (+ nlocs0 (ash nlocs1 8))) (a (pop)) (b (pop)) (c (pop)) (d (pop)) (e (pop)) (f (pop)) (g (pop)) (h (pop)) (len (+ a (ash b 8) (ash c 16) (ash d 24))) |