Make FIX-LABEL-ADDRESSES-IN-INSTRUCTION-LIST add PROGRAM_END label

This commit is contained in:
John Lorentzson 2025-05-08 22:17:36 +02:00
parent 9d2d0dea6b
commit 010cc5dd87

View file

@ -101,11 +101,17 @@
(defun fix-label-addresses-in-instruction-list (instruction-list origin) (defun fix-label-addresses-in-instruction-list (instruction-list origin)
(loop :with address := origin (loop :with address := origin
:with cell := instruction-list
:for obj :in instruction-list :for obj :in instruction-list
:if (typep obj 'label) :if (typep obj 'label)
:do (setf (address obj) address) :do (setf (address obj) address)
:else :else
:do (incf address (instruction-length obj)))) :do (when (typep obj 'instruction)
(incf address (instruction-length obj)))
:unless (null (rest cell))
:do (setf cell (rest cell))
:finally (setf (cdr cell)
(list (make-label :name "PROGRAM_END" :address address)))))
;;; Testing ;;; Testing