From 010cc5dd87032f396c029eb92d3a0c77cd58ceca Mon Sep 17 00:00:00 2001 From: John Lorentzson Date: Thu, 8 May 2025 22:17:36 +0200 Subject: [PATCH] Make FIX-LABEL-ADDRESSES-IN-INSTRUCTION-LIST add PROGRAM_END label --- wip-duuqnd/user-side-compiler/instruction.lisp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wip-duuqnd/user-side-compiler/instruction.lisp b/wip-duuqnd/user-side-compiler/instruction.lisp index 16c9e61..c613adc 100644 --- a/wip-duuqnd/user-side-compiler/instruction.lisp +++ b/wip-duuqnd/user-side-compiler/instruction.lisp @@ -101,11 +101,17 @@ (defun fix-label-addresses-in-instruction-list (instruction-list origin) (loop :with address := origin + :with cell := instruction-list :for obj :in instruction-list :if (typep obj 'label) :do (setf (address obj) address) :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