uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit ca6d755bd69b524ea5703a4450922eeafdeb8a98
parent 55f5f7a80074ad258a425fb007d7e16c9681adaf
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date:   Wed, 19 Oct 2022 12:07:52 +0100

(asma) Remove tail call optimisation.

Diffstat:
Mprojects/library/asma.tal | 48+++++++++++-------------------------------------
1 file changed, 11 insertions(+), 37 deletions(-)

diff --git a/projects/library/asma.tal b/projects/library/asma.tal @@ -225,7 +225,7 @@ ;asma-read-buffer DUP2 ;asma-read-buffer/end ROT2 SUB2 ( func* line^ filename* buf* size^ ) ROT2 ( func* line^ buf* size^ filename* ) ,file-read-chunks JSR - ;asma-flush-held JSR2 + ;asma-flush-lit JSR2 asma-IF-ERROR ,&error JCN @@ -351,7 +351,7 @@ @asma [ &pass $1 &state $1 &line $2 &lines $2 &break $1 &eof $1 &comment-level $1 - &token $2 &orig-token $2 &lit $1 &lit-present $1 &jsr $1 + &token $2 &orig-token $2 &lit $1 &lit-present $1 &addr $2 &written-addr $2 &flush-fn $2 &src-filename $2 &dest-filename $2 &error $2 &log-level $1 @@ -516,7 +516,6 @@ @asma-write-lit ( byte -- ) ;asma/lit LDA2 ,&present JCN - ,asma-flush-held JSR POP #01 ;asma/lit STA2 #0002 ,asma-advance-addr JMP ( tail call ) &present @@ -533,22 +532,14 @@ SWP2 STA2 JMP2r -@asma-flush-held ( -- ) - ;asma/lit LDA2 ,&lit-present JCN - POP ,&part2 JMP - &lit-present +@asma-flush-lit ( -- ) + ;asma/lit LDA2 ,&present JCN + POP JMP2r + &present #fffe ,asma-advance-addr JSR LIT LIT ,asma-write-byte/raw JSR ,asma-write-byte/raw JSR #0000 ;asma/lit STA2 - - &part2 - ;asma/jsr LDA DUP ,&jsr-present JCN - POP JMP2r - &jsr-present - #ffff ,asma-advance-addr JSR - ,asma-write-byte/raw JSR - #00 ;asma/jsr STA JMP2r @asma-write-short ( short -- ) @@ -557,7 +548,7 @@ ( fall through ) @asma-write-byte ( byte -- ) - ,asma-flush-held JSR + ,asma-flush-lit JSR &raw ;asma/addr LDA2 ;asma/written-addr LDA2 LTH2k ,&rewound JCN @@ -676,7 +667,7 @@ JMP2r @asma-label-define - ;asma-flush-held JSR2 + ;asma-flush-lit JSR2 ;asma-trees/labels ,asma-label-helper JSR ,&already-existed JCN @@ -687,7 +678,7 @@ JMP2r @asma-sublabel-define - ;asma-flush-held JSR2 + ;asma-flush-lit JSR2 ;asma-trees/scope LDA2 ,asma-label-helper JSR POP POP2 JMP2r @@ -717,12 +708,12 @@ #00 JMP2r @asma-pad-absolute - ;asma-flush-held JSR2 + ;asma-flush-lit JSR2 #0000 ;asma/addr STA2 ,asma-pad-helper JMP @asma-pad-relative - ;asma-flush-held JSR2 + ;asma-flush-lit JSR2 ( fall through ) @asma-pad-helper ( -- ) @@ -861,25 +852,8 @@ @asma-normal-body ;asma-parse-opcode JSR2 ,&not-opcode JCN - DUP [ LIT JSR ] EQU ,&hold-jsr JCN - DUP [ LIT JSR2 ] EQU ,&hold-jsr JCN - DUP [ LIT JMP2r ] NEQ ,&write-opcode JCN - ;asma/jsr LDA ,&optimise-jsr-jmp2r JCN - &write-opcode ;asma-write-byte JMP2 ( tail call ) - &hold-jsr - ;asma-flush-held JSR2 - ;asma/jsr STA - #0001 ;asma-advance-addr JMP2 ( tail call ) - - &optimise-jsr-jmp2r - POP - ;asma/jsr LDAk #00 SWP2 STA - #e0 AND [ LIT JMP ] ORA - #ffff ;asma-advance-addr JSR2 - ,&write-opcode JMP - &not-opcode #01 ;asma-parse-hex-string JSR2 JMP ( hex invalid ) ,&not-hex JMP