Browse code

(asma) Remove tail call optimisation.

Andrew Alderwick authored on 19/10/2022 11:07:52
Showing 1 changed files
... ...
@@ -225,7 +225,7 @@
225 225
 	;asma-read-buffer DUP2 ;asma-read-buffer/end ROT2 SUB2 ( func* line^ filename* buf* size^ )
226 226
 	ROT2 ( func* line^ buf* size^ filename* )
227 227
 	,file-read-chunks JSR
228
-	;asma-flush-held JSR2
228
+	;asma-flush-lit JSR2
229 229
 
230 230
 	asma-IF-ERROR ,&error JCN
231 231
 
... ...
@@ -351,7 +351,7 @@
351 351
 @asma [
352 352
 	&pass $1 &state $1 &line $2 &lines $2 &break $1 &eof $1
353 353
 	&comment-level $1
354
-	&token $2 &orig-token $2 &lit $1 &lit-present $1 &jsr $1
354
+	&token $2 &orig-token $2 &lit $1 &lit-present $1
355 355
 	&addr $2 &written-addr $2 &flush-fn $2
356 356
 	&src-filename $2 &dest-filename $2
357 357
 	&error $2 &log-level $1
... ...
@@ -516,7 +516,6 @@
516 516
 
517 517
 @asma-write-lit ( byte -- )
518 518
 	;asma/lit LDA2 ,&present JCN
519
-	,asma-flush-held JSR
520 519
 	POP #01 ;asma/lit STA2
521 520
 	#0002 ,asma-advance-addr JMP ( tail call )
522 521
 	&present
... ...
@@ -533,22 +532,14 @@
533 532
 	SWP2 STA2
534 533
 	JMP2r
535 534
 
536
-@asma-flush-held ( -- )
537
-	;asma/lit LDA2 ,&lit-present JCN
538
-	POP ,&part2 JMP
539
-	&lit-present
535
+@asma-flush-lit ( -- )
536
+	;asma/lit LDA2 ,&present JCN
537
+	POP JMP2r
538
+	&present
540 539
 	#fffe ,asma-advance-addr JSR
541 540
 	LIT LIT ,asma-write-byte/raw JSR
542 541
 	,asma-write-byte/raw JSR
543 542
 	#0000 ;asma/lit STA2
544
-
545
-	&part2
546
-	;asma/jsr LDA DUP ,&jsr-present JCN
547
-	POP JMP2r
548
-	&jsr-present
549
-	#ffff ,asma-advance-addr JSR
550
-	,asma-write-byte/raw JSR
551
-	#00 ;asma/jsr STA
552 543
 	JMP2r
553 544
 
554 545
 @asma-write-short ( short -- )
... ...
@@ -557,7 +548,7 @@
557 548
 	( fall through )
558 549
 
559 550
 @asma-write-byte ( byte -- )
560
-	,asma-flush-held JSR
551
+	,asma-flush-lit JSR
561 552
 	&raw
562 553
 	;asma/addr LDA2 ;asma/written-addr LDA2
563 554
 	LTH2k ,&rewound JCN
... ...
@@ -676,7 +667,7 @@
676 667
 	JMP2r
677 668
 
678 669
 @asma-label-define
679
-	;asma-flush-held JSR2
670
+	;asma-flush-lit JSR2
680 671
 	;asma-trees/labels ,asma-label-helper JSR
681 672
 	,&already-existed JCN
682 673
 
... ...
@@ -687,7 +678,7 @@
687 678
 	JMP2r
688 679
 
689 680
 @asma-sublabel-define
690
-	;asma-flush-held JSR2
681
+	;asma-flush-lit JSR2
691 682
 	;asma-trees/scope LDA2 ,asma-label-helper JSR
692 683
 	POP POP2
693 684
 	JMP2r
... ...
@@ -717,12 +708,12 @@
717 708
 	#00 JMP2r
718 709
 
719 710
 @asma-pad-absolute
720
-	;asma-flush-held JSR2
711
+	;asma-flush-lit JSR2
721 712
 	#0000 ;asma/addr STA2
722 713
 	,asma-pad-helper JMP
723 714
 
724 715
 @asma-pad-relative
725
-	;asma-flush-held JSR2
716
+	;asma-flush-lit JSR2
726 717
 	( fall through )
727 718
 
728 719
 @asma-pad-helper ( -- )
... ...
@@ -861,25 +852,8 @@
861 852
 
862 853
 @asma-normal-body
863 854
 	;asma-parse-opcode JSR2 ,&not-opcode JCN
864
-	DUP [ LIT JSR ] EQU ,&hold-jsr JCN
865
-	DUP [ LIT JSR2 ] EQU ,&hold-jsr JCN
866
-	DUP [ LIT JMP2r ] NEQ ,&write-opcode JCN
867
-	;asma/jsr LDA ,&optimise-jsr-jmp2r JCN
868
-	&write-opcode
869 855
 	;asma-write-byte JMP2 ( tail call )
870 856
 
871
-	&hold-jsr
872
-	;asma-flush-held JSR2
873
-	;asma/jsr STA
874
-	#0001 ;asma-advance-addr JMP2 ( tail call )
875
-
876
-	&optimise-jsr-jmp2r
877
-	POP
878
-	;asma/jsr LDAk #00 SWP2 STA
879
-	#e0 AND [ LIT JMP ] ORA
880
-	#ffff ;asma-advance-addr JSR2
881
-	,&write-opcode JMP
882
-
883 857
 	&not-opcode
884 858
 	#01 ;asma-parse-hex-string JSR2 JMP
885 859
 	( hex invalid ) ,&not-hex JMP