((U8_L24 label)
(record-label-reference asm label)
(emit asm opcode))
- ((U8_R24 rest)
- (emit asm (pack-u8-u24 opcode (list rest)))
- (for-each (lambda (x) (emit asm x)) rest))
((U8_U8_I16 a imm)
(emit asm (pack-u8-u8-u16 opcode a (object-address imm))))
((U8_U12_U12 a b)
((U8_L24 a label)
(record-label-reference asm label)
(emit asm a))
- ((U8_R24 rest)
- (emit asm (pack-u8-u24 a (length rest)))
- (for-each (lambda (x) (emit asm x)) rest))
((U8_U8_I16 a b imm)
(emit asm (pack-u8-u8-u16 a b (object-address imm))))
((U8_U12_U12 a b)
(emit asm (pack-u8-u24 0 a)))
((X8_U12_U12 a b)
(emit asm (pack-u8-u12-u12 0 a b)))
- ((X8_R24 rest)
- (emit asm (pack-u8-u24 0 (length rest)))
- (for-each (lambda (x) (emit asm x)) rest))
((X8_L24 label)
(record-label-reference asm label)
(emit asm 0))
#'((ash word -8)))
((U8_L24)
#'((unpack-s24 (ash word -8))))
- ((U8_R24)
- #'(#:rest (ash word -8)))
((U8_U8_I16)
#'((logand (ash word -8) #xff)
(ash word -16)))
((U8_L24)
#'((logand word #xff)
(unpack-s24 (ash word -8))))
- ((U8_R24)
- #'((logand word #xff)
- #:rest (ash word -8)))
((U8_U8_I16)
#'((logand word #xff)
(logand (ash word -8) #xff)
((X8_U12_U12)
#'((logand (ash word -8) #xfff)
(ash word -20)))
- ((X8_R24)
- #'(#:rest (ash word -8)))
((X8_L24)
#'((unpack-s24 (ash word -8))))
((B1_X7_L24)
;; -> len list
(define (disassemble-one buf offset)
(let ((first (u32-ref buf offset)))
- (call-with-values
- (lambda ()
- ((vector-ref disassemblers (logand first #xff)) buf offset first))
- (lambda (len list)
- (match list
- ((head ... #:rest rest)
- (let lp ((n 0) (rhead (reverse head)))
- (if (= n rest)
- (values (+ len n) (reverse rhead))
- (lp (1+ n)
- (cons (u32-ref buf (+ offset len n)) rhead)))))
- (_ (values len list)))))))
+ ((vector-ref disassemblers (logand first #xff)) buf offset first)))
(define (u32-offset->addr offset context)
"Given an offset into an image in 32-bit units, return the absolute