From d15e52eb53865e68d75d97c1bb66c2d9c7ba5f3c Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Sat, 30 Mar 2019 08:21:34 -0700 Subject: [PATCH] Macros for relocated procs --- desk.acc/calculator.s | 7 ++----- desktop.system/desktop.system.s | 9 +++------ macros.inc | 24 ++++++++++++++++++++++++ res/asmfmt.pl | 6 ++++-- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/desk.acc/calculator.s b/desk.acc/calculator.s index d38703d..1039eb1 100644 --- a/desk.acc/calculator.s +++ b/desk.acc/calculator.s @@ -1598,9 +1598,7 @@ draw_title_bar: .endproc ;; Following proc is copied to $B1 - save_org := * -.proc adjust_txtptr_copied - .org $B1 +PROC_AT adjust_txtptr_copied, $B1 dummy_addr := $EA60 loop: inc TXTPTR @@ -1619,8 +1617,7 @@ loop: inc TXTPTR sec sbc #$D0 ; carry set if successful end: rts -.endproc - .org save_org + .sizeof(adjust_txtptr_copied) +END_PROC_AT sizeof_adjust_txtptr_copied = .sizeof(adjust_txtptr_copied) da_end := * diff --git a/desktop.system/desktop.system.s b/desktop.system/desktop.system.s index aa6e93e..df414ba 100644 --- a/desktop.system/desktop.system.s +++ b/desktop.system/desktop.system.s @@ -899,9 +899,7 @@ path0: .res 65, 0 ;;; Launch FILER - used if machine is not 128k ;;; Relocated to $300 before invoking - saved_org := * -.proc launch_filer - .org $300 +PROC_AT launch_filer, $300 sys_start := $2000 @@ -931,13 +929,12 @@ path0: .res 65, 0 filename: PASCAL_STRING "FILER" -.endproc + +END_PROC_AT .assert .sizeof(launch_filer) <= $D0, error, "Routine length exceeded" ;;; ============================================================ - .org (saved_org + .sizeof(launch_filer)) - filenum: .byte 0 ; index of file being copied diff --git a/macros.inc b/macros.inc index 34fdbef..da43216 100644 --- a/macros.inc +++ b/macros.inc @@ -675,6 +675,30 @@ loop: lda src,x .endmacro +;;; ============================================================ +;;; Placed Procedures +;;; ============================================================ +;;; Usage: +;;; PROC_AT relocated_proc, $300 +;;; .assert * = $300, ... +;;; ... +;;; END_PROC_AT +;;; .assert * = back to normal + +.macro PROC_AT name, addr +.proc name + saved_org := * + .org addr +.proc __inner__ +.endmacro + +.macro END_PROC_AT +.endproc ; __inner__ + .org saved_org + .sizeof(__inner__) +.endproc +.endmacro + + ;;; ============================================================ ;;; Flow Control ;;; ============================================================ diff --git a/res/asmfmt.pl b/res/asmfmt.pl index 633c154..c16229a 100755 --- a/res/asmfmt.pl +++ b/res/asmfmt.pl @@ -57,14 +57,16 @@ while () { $_ .= ' ' while length($_) % $tab; $_ .= ':= ' . $expression . ' '; - } elsif (m/^(\.(?:end)?(?:proc|scope|macro|struct|enum)\b)\s*(.*)$/) { + } elsif (m/^(\.(?:end)?(?:proc|scope|macro|struct|enum)\b)\s*(.*)$/ || + m/^(\b(?:END_)?(?:PROC_AT)\b)\s*(.*)$/) { # scope - flush left my ($opcode, $arguments) = ($1 // '', $2 // ''); $_ = $opcode . ' ' . $arguments; - } elsif (m/^(\.(?:if\w*|elseif|else|endif)\b)\s*(.*)$/) { + } elsif (m/^(\.(?:if\w*|elseif|else|endif)\b)\s*(.*)$/ || + m/^(\b(?:IF_\w+|ELSE|END_IF)\b)\s*(.*)$/) { # conditional - half indent left my ($opcode, $arguments) = ($1 // '', $2 // '');