diff --git a/interpreter/interp.rkt b/interpreter/interp.rkt index 466c4b0..02462fb 100644 --- a/interpreter/interp.rkt +++ b/interpreter/interp.rkt @@ -84,19 +84,23 @@ ;; call the external function (let* ([func (hash-ref runtime external-function)] [sp (hash-ref registers 'rsp)] - [result (func registers memory sp)] - [_ (unless (integer? result) - (raise-user-error 'step - "result of external function '~a' not an integer; got ~v" - external-function - result))] - [_ (unless (<= (integer-length result) (word-size-bits)) - (raise-user-error 'step - "integer result of external function '~a' too large; got ~v" - external-function - result))] - [new-registers (hash-set registers 'rax result)]) - (make-state #:with-registers new-registers))] + [result (func registers memory sp)]) + (cond + [(void? result) + (make-state)] + [(not (integer? result)) + (raise-user-error 'step + "result of external function '~a' not # or an integer; got ~v" + external-function + result)] + [(not (<= (integer-length result) (word-size-bits))) + (raise-user-error 'step + "integer result of external function '~a' too large; got ~v" + external-function + result)] + [else + (let ([new-registers (hash-set registers 'rax result)]) + (make-state #:with-registers new-registers))]))] [(Call dst) ;; Mem.push(ip + wordsize) ;; ip = dst