From 2f36ecc007a81029b864b96cc0e0967b2ab4d207 Mon Sep 17 00:00:00 2001 From: mgcaret Date: Wed, 12 Dec 2018 08:57:36 -0800 Subject: [PATCH] macro/util changes to support reserved space after loaded command --- davex-mg.inc | 20 ++++++++++++++++---- utils/auto_origin.sh | 8 +++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/davex-mg.inc b/davex-mg.inc index 5d3e510..e3baecf 100644 --- a/davex-mg.inc +++ b/davex-mg.inc @@ -59,7 +59,7 @@ dx_desc_none = 0 ; if the Load address is zero, we don't export X_DX_LOAD ; so that later we can calculate an appropriate start addr ; and let the linker do it. -.macro DX_start Load +.macro DX_start Load,Resv .ifdef DID_DX_start .warning "DX_start used more than once" .else @@ -74,6 +74,13 @@ dx_desc_none = 0 X_DX_AUTO_LOAD = 1 .endif X_DX_LOAD := * + .ifblank Resv + X_DX_RESV = 0 + .else + X_DX_RESV = Resv + .out .sprintf("Reserving %d bytes", Resv) + .endif + .export X_DX_RESV ext_start: rts .byte $ee, $ee @@ -153,7 +160,7 @@ X_DX_DESC: .byte .strlen(Desc) .error "DX_start not used" .endif X_DX_END = * - X_DX_SIZE = X_DX_END - X_DX_LOAD + X_DX_SIZE = X_DX_END - X_DX_LOAD + X_DX_RESV DID_YOU_DX_end = 1 .ifndef DID_DX_info .error "DX_info not used" @@ -169,12 +176,17 @@ X_DX_DESC: .byte .strlen(Desc) X_DX_DESC := 0 .endif .ifndef X_DX_AUTO_LOAD - .out .sprintf("Code ends at $%x, size $%x", X_DX_END, X_DX_SIZE) + .out .sprintf("Code ends at $%x, size $%x (%x resv)", X_DX_END, X_DX_SIZE, X_DX_RESV) .assert * < $b000, error, "Code is past $b000!" - .if * < $af00 + .if (X_DX_END+X_DX_RESV) < $af00 .out "Consider moving code start to place end shortly before $b000" .out .sprintf("Perhaps at $%x", ($b000-X_DX_SIZE)&$ff00) .endif + .if (X_DX_END+X_DX_RESV) > $afff + .out "Code overruns available space, consider moving code start" + .out .sprintf("Perhaps at $%x", ($b000-X_DX_SIZE)&$ff00) + .error "Cannot continue" + .endif .else .out .sprintf("Auto load address, size $%x", X_DX_SIZE) .endif diff --git a/utils/auto_origin.sh b/utils/auto_origin.sh index eb71056..224c40f 100755 --- a/utils/auto_origin.sh +++ b/utils/auto_origin.sh @@ -63,7 +63,13 @@ else exit 4 fi echo "Code size: ${CODE_SIZE}" - START=$(( (${END_FENCE} - ${CODE_SIZE}) / 256 * 256 )) + RESERVE=0 + RESV=`${OD65} --dump-exports ${OBJECT_FILE} | awk -F'(' 'f{print substr(\$2,1,length(\$2)-1);f=0} /X_DX_RESV/{f=1}'` + if [ -n "${RESV}" ]; then + RESERVE="${RESV}" + echo "Reserve: ${RESERVE}" + fi + START=$(( (${END_FENCE} - ${CODE_SIZE} - ${RESERVE}) / 256 * 256 )) if [ -z "${START}" ]; then echo "Could not calculate a start address!" exit 4