uxn

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

commit e8f58aa5790f079521f2f24369431b5490f9add3
parent 4525d47699b878a6e5449436a0075d78a3d870dc
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date:   Mon,  4 Oct 2021 22:28:13 +0100

Use file-read-chunks library in asma.

Diffstat:
Mprojects/software/asma.tal | 62++++++++++++++++++++++++++++----------------------------------
1 file changed, 28 insertions(+), 34 deletions(-)

diff --git a/projects/software/asma.tal b/projects/software/asma.tal @@ -250,10 +250,8 @@ ;asma-output/offset STA2 ;asma/addr STA2 ;asma/state STA - #01 ( 0001 ) - SWPk ( 0001 0100 ) ;asma/written-addr STA2 + #01 SWP ( 0100 ) ;asma/written-addr STA2 ;&preamble-end ;&preamble SUB2k ,asma-assemble-chunk JSR POP2 POP2 - ;asma/line STA2 JMP2r &preamble @@ -265,32 +263,22 @@ ) @asma-assemble-file-pass ( filename-ptr* -- ) - #0000 + ;asma-assemble-chunk #0001 ROT2 ( func* line^ filename* ) + ;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 - &loop - OVR2 .File/name DEO2 - DUP2 .File/offset-ls DEO2 - ;asma-read-buffer/end ;asma-read-buffer SUB2 STH2k .File/length DEO2 - ;asma-read-buffer DUP2k .File/load DEO2 - .File/success DEI2 - DUP2 STH2r SUB2 ORA ,&last-one JCN - ,asma-assemble-chunk JSR asma-IF-ERROR ,&error JCN - SUB2 SUB2 - ,&loop JMP - - &last-one - ADD2k #00 ROT ROT STA - INC2 - ,asma-assemble-chunk JSR asma-IF-ERROR ,&error JCN + asma-IF-ERROR ,&error JCN ( flush output buffer ) ;asma-output/ptr LDA2 ;asma-write-buffer SUB2 ;asma/flush-fn LDA2 JSR2 - POP2 &error - POP2 POP2 POP2 + POP2 POP2 POP2 POP2 POP2 JMP2r +include projects/library/file-read-chunks.tal + ( Assemble a chunk of source code, which begins with whitespace or the start of a token and is divided up into tokens separated by whitespace. If the @@ -300,28 +288,34 @@ of the last token in the chunk. ) -@asma-assemble-chunk ( ptr* len* -- assembled-up-to-ptr* ) - OVR2 ADD2 #0001 SUB2 SWP2 STH2k +@asma-assemble-chunk ( line^ ptr* len^ -- assembled-up-to-ptr* ) + ROT2k ( line^ ptr* len^ ptr* len^ line^ ) + ;asma/line STA2 ( line^ ptr* len^ ptr* len^ ) + ADD2 #0001 SUB2 NIP2 ( line^ ptr* last-ptr* ) + SWP2 STH2k ( line^ last-ptr* ptr* / ptr* ) ,&loop JMP - &next-char-pop + &next-char-pop ( line^ last-ptr* ptr* char / start-of-token* ) POP - &next-char INC2 - &loop ( last-ptr* ptr* / start-of-token* ) - OVR2 OVR2 LTH2 ,&end JCN - LDAk ( last-ptr* ptr* char / start-of-token* ) + &loop ( line^ last-ptr* ptr* / start-of-token* ) + LTH2k ,&end JCN + LDAk ( line^ last-ptr* ptr* char / start-of-token* ) DUP #20 GTH ,&next-char-pop JCN - #00 OVR2 ( last-ptr* ptr* char 00 ptr* / start-of-token* ) - STA - STH2r ,asma-assemble-token JSR asma-IF-ERROR ,&error JCN + #00 OVR2 ( line^ last-ptr* ptr* char 00 ptr* / start-of-token* ) + STA STH2r ( line^ last-ptr* ptr* char start-of-token* ) + ,asma-assemble-token JSR ( line^ last-ptr* ptr* char ) + asma-IF-ERROR ,&error JCN - #0a NEQ ,&not-newline JCN - ;asma/line LDA2 INC2 ;asma/line STA2 + #0a NEQ ,&not-newline JCN ( line^ last-ptr* ptr* ) + ROT2 INC2 ( last-ptr* ptr* line+1^ ) + DUP2 ;asma/line STA2 + ROT2 ROT2 ( line^ last-ptr* ptr* ) &not-newline - DUP2 INC2 STH2 ,&next-char JMP + INC2 DUP2 STH2 ( line^ last-ptr* ptr* / start-of-token* ) + ,&loop JMP &end POP2 POP2 STH2r