diff --git a/src/ikarus.boot b/src/ikarus.boot index a7d216b..bf7f8ac 100644 Binary files a/src/ikarus.boot and b/src/ikarus.boot differ diff --git a/src/ikarus.compiler.ss b/src/ikarus.compiler.ss index 81f29ac..665bd4c 100644 --- a/src/ikarus.compiler.ss +++ b/src/ikarus.compiler.ss @@ -130,7 +130,8 @@ [bytevector? 1 pred] [$make-bytevector 1 value] [$bytevector-length 1 value] - [$bytevector-ref 2 value] + [$bytevector-u8-ref 2 value] + [$bytevector-s8-ref 2 value] [$bytevector-set! 3 effect] ;;; symbols [$make-symbol 1 value] @@ -1922,7 +1923,7 @@ void base-rtd $unbound-object? code? $forward-ptr? bwp-object? pointer-value top-level-value car cdr list* list $record port? input-port? output-port? $bytevector-set! - $bytevector-length + $bytevector-length $bytevector-u8-ref $bytevector-s8-ref $make-bytevector $bytevector-ref bytevector? $make-port/input $make-port/output $make-port/both $port-handler @@ -3785,6 +3786,22 @@ (movb (mem (fx- disp-code-data vector-tag) ebx) ah) (sarl (int (fx- 8 fx-shift)) eax) ac)] + [($bytevector-s8-ref) + (list* (movl (Simple (cadr arg*)) ebx) + (sarl (int fx-shift) ebx) + (addl (Simple (car arg*)) ebx) + (movb (mem (fx- disp-bytevector-data bytevector-tag) ebx) al) + (sall (int (* (sub1 wordsize) 8)) eax) + (sarl (int (- (* (sub1 wordsize) 8) fx-shift)) eax) + ac)] + [($bytevector-u8-ref) + (list* (movl (Simple (cadr arg*)) ebx) + (sarl (int fx-shift) ebx) + (addl (Simple (car arg*)) ebx) + (movl (int 0) eax) + (movb (mem (fx- disp-bytevector-data bytevector-tag) ebx) al) + (sall (int fx-shift) eax) + ac)] [($string-ref) (list* (movl (Simple (cadr arg*)) ebx) (sarl (int fx-shift) ebx) @@ -4125,6 +4142,7 @@ (sarl (int fx-shift) eax) (addl (Simple (car arg*)) eax) (movl (Simple (caddr arg*)) ebx) + (sall (int (- 8 fx-shift)) ebx) (movb bh (mem (fx- disp-bytevector-data bytevector-tag) eax)) ac)] [($set-car!) diff --git a/src/makefile.ss b/src/makefile.ss index c40da63..22f5e25 100755 --- a/src/makefile.ss +++ b/src/makefile.ss @@ -273,6 +273,8 @@ [vector->list i r] [make-bytevector i] [bytevector-length i] + [bytevector-s8-ref i] + [bytevector-u8-ref i] [for-each i r] [map i r] @@ -479,8 +481,8 @@ [$make-bytevector $bytes] [$bytevector-length $bytes] - [$bytevector-ref $bytes] [$bytevector-s8-ref $bytes] + [$bytevector-u8-ref $bytes] [$bytevector-set! $bytes] diff --git a/src/tests/bytevectors.ss b/src/tests/bytevectors.ss index fe686bc..7455997 100644 --- a/src/tests/bytevectors.ss +++ b/src/tests/bytevectors.ss @@ -17,6 +17,14 @@ [not-bytevector? '#(2837 2398 239)] [zero? (bytevector-length (make-bytevector 0))] [(lambda (x) (= x 100)) (bytevector-length (make-bytevector 100 -30))] + [(lambda (x) (equal? x '(-127 129 -1 255))) + (let ([b1 (make-bytevector 16 -127)] + [b2 (make-bytevector 16 255)]) + (list + (bytevector-s8-ref b1 0) + (bytevector-u8-ref b1 0) + (bytevector-s8-ref b2 0) + (bytevector-u8-ref b2 0)))] ))