summaryrefslogtreecommitdiff
path: root/module/language/assembly
diff options
context:
space:
mode:
Diffstat (limited to 'module/language/assembly')
-rw-r--r--module/language/assembly/compile-bytecode.scm7
-rw-r--r--module/language/assembly/decompile-bytecode.scm4
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)))