Browse code

(asma) Optimise advancing asma/addr

Andrew Alderwick authored on 07/06/2022 23:38:55
Showing 1 changed files
... ...
@@ -520,21 +520,26 @@
520 520
 	;asma/lit LDA2 ,&present JCN
521 521
 	,asma-flush-held JSR
522 522
 	POP #01 ;asma/lit STA2
523
-	;asma/addr LDA2k INC2 INC2 SWP2 STA2
524
-	JMP2r
523
+	#0002 ,asma-advance-addr JMP ( tail call )
525 524
 	&present
526
-	;asma/addr LDA2k #0002 SUB2 SWP2 STA2
525
+	#fffe ,asma-advance-addr JSR
527 526
 	LIT LIT2 ,asma-write-byte/raw JSR
528 527
 	,asma-write-byte/raw JSR
529 528
 	,asma-write-byte/raw JSR
530 529
 	#0000 ;asma/lit STA2
531 530
 	JMP2r
532 531
 
532
+@asma-advance-addr ( delta* -- )
533
+	;asma/addr LDA2k ( delta* ptr* value* )
534
+	ROT2 ADD2 ( ptr* new-value* )
535
+	SWP2 STA2
536
+	JMP2r
537
+
533 538
 @asma-flush-held ( -- )
534 539
 	;asma/lit LDA2 ,&lit-present JCN
535 540
 	POP ,&part2 JMP
536 541
 	&lit-present
537
-	;asma/addr LDA2k #0002 SUB2 SWP2 STA2
542
+	#fffe ,asma-advance-addr JSR
538 543
 	LIT LIT ,asma-write-byte/raw JSR
539 544
 	,asma-write-byte/raw JSR
540 545
 	#0000 ;asma/lit STA2
... ...
@@ -543,7 +548,7 @@
543 548
 	;asma/jsr LDA DUP ,&jsr-present JCN
544 549
 	POP JMP2r
545 550
 	&jsr-present
546
-	;asma/addr LDA2k #0001 SUB2 SWP2 STA2
551
+	#ffff ,asma-advance-addr JSR
547 552
 	,asma-write-byte/raw JSR
548 553
 	#00 ;asma/jsr STA
549 554
 	JMP2r
... ...
@@ -710,24 +715,22 @@
710 715
 
711 716
 @asma-pad-absolute
712 717
 	;asma-flush-held JSR2
713
-	#0000 ,asma-pad-helper JMP
718
+	#0000 ;asma/addr STA2
719
+	,asma-pad-helper JMP
714 720
 
715 721
 @asma-pad-relative
716 722
 	;asma-flush-held JSR2
717
-	;asma/addr LDA2
718 723
 	( fall through )
719 724
 
720
-@asma-pad-helper ( offset* -- )
725
+@asma-pad-helper ( -- )
721 726
 	#00 ;asma-parse-hex-string JSR2
722 727
 	,&valid JCN
723 728
 
724 729
 	;asma-msg-hex ;asma/error STA2
725
-	POP2
726 730
 	JMP2r
727 731
 
728 732
 	&valid
729
-	ADD2 ;asma/addr STA2
730
-	JMP2r
733
+	;asma-advance-addr JMP2 ( tail call )
731 734
 
732 735
 @asma-raw-char
733 736
 	;asma/token LDA2 LDA
... ...
@@ -869,14 +872,13 @@
869 872
 	&hold-jsr
870 873
 	;asma-flush-held JSR2
871 874
 	;asma/jsr STA
872
-	;asma/addr LDA2k INC2 SWP2 STA2
873
-	JMP2r
875
+	#0001 ;asma-advance-addr JMP2 ( tail call )
874 876
 
875 877
 	&optimise-jsr-jmp2r
876 878
 	POP
877 879
 	;asma/jsr LDAk #00 SWP2 STA
878 880
 	#e0 AND [ LIT JMP ] ORA
879
-	;asma/addr LDA2k #0001 SUB2 SWP2 STA2
881
+	#ffff ;asma-advance-addr JSR2
880 882
 	,&write-opcode JMP
881 883
 
882 884
 	&not-opcode