Skip to content

Commit

Permalink
Begin update of [Lea] to properly decode occurrences of [Plus]
Browse files Browse the repository at this point in the history
Part of #16.
  • Loading branch information
pdarragh committed Jul 25, 2024
1 parent 92dfa2e commit 8c1aeb0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions a86/emulate/step.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,19 @@
;; dst = src % when [Cmp a1 a2] unsets the carry flag.
(move-with-condition dst src flags-nc?)]

[(Lea dst l)
(let ([ea (hash-ref labels->addresses l)])
[(Lea dst src)
(let ([ea (let decode-loop ([x src])
(match x
[(? integer?)
x]
[(? symbol?)
(process-argument x #:as 'label)]
[(? offset?)
(process-argument x #:as 'offset)]
[(Plus e1 e2)
(let ([v1 (decode-loop e1)]
[v2 (decode-loop e2)])
(+ v1 v2))]))])
(cond
[(register? dst)
;; dst = address-of(l)
Expand All @@ -644,6 +655,7 @@
;; memory[dst] = address-of(l)
(memory-set! (address-from-offset dst) ea)
(make-step-state)]))]

[_
(raise-user-error 'step
"unrecognized instruction ~v at address ~a"
Expand Down

0 comments on commit 8c1aeb0

Please sign in to comment.