Page 2 of 2
Re: 6502 Assembler in 96 lines of Forth (July 1980)
Posted: Sat Aug 24, 2019 4:38 am
by chitselb
The assembler I wrote for my Forth for the Commodore 64 is also based on Ragsdale's assembler. I rewrote M/CPU and the index table is ten bytes smaller. I added range checking for the instructions that compile a branch. One change I'm thinking about is removing the comma's at the end of the opcode and control structure names. On the other hand, the code words for the system are written with the comma's in the names and I'd have to rewrite it.
I squeezed it down a bit in PETTIL too. The best reason to leave the commas at the end of the opcodes is that it's how most other RPN Forth Assembly language is written.
Re: 6502 Assembler in 96 lines of Forth (July 1980)
Posted: Sun Aug 25, 2019 10:10 pm
by JimBoyd
The best reason to leave the commas at the end of the opcodes is that it's how most other RPN Forth Assembly language is written.
Thank you! I don't have experience with other RPN Forth assemblers. I will keep the commas.
Re: 6502 Assembler in 96 lines of Forth (July 1980)
Posted: Thu Feb 11, 2021 12:31 am
by JimBoyd
Does anyone know of any bugs in Ragsdale's assembler?
Blazin' Forth's assembler is based on Ragsdale's and the creator of Blazin' Forth said the following.
Actually, there was only one bug ever reported from Blazin' Forth, and I found that myself and uploaded a patch. To tell the truth, there is one other bug in that program, I discovered it years later. It's actually a bug in the assembler - there was a garbage line that should have triggered an error but didn't, it assembled garbage. But the nature of the bug is such that it actually is only triggered extremely rarely. No one has ever reported it. Hehe!
I don't know if he was referring to:
1) The assembler he used to build Blazin' Forth and the bug is in Blazin' Forth.
2) The assembler he included with Blazin' Forth which is based on Ragsdale's.
Re: 6502 Assembler in 96 lines of Forth (July 1980)
Posted: Thu Feb 11, 2021 12:59 am
by GARTHWILSON
The best reason to leave the commas at the end of the opcodes is that it's how most other RPN Forth Assembly language is written.
Which ones have you used? Besides my own, the only one I've used, which was a metacompiler, did this kind of thing:
Code: Select all
( d1 d2 -- f )
CODE D= TOS 0 + LDA TOS 4 + CMP 1$ BNE
TOS 1 + LDA TOS 5 + CMP 1$ BNE
TOS 2 + LDA TOS 6 + CMP 1$ BNE
TOS 3 + LDA TOS 7 + CMP 1$ BNE
POP3-TRUE JMP
1$: POP3-FALSE JMP END-CODE
No commas. I don't remember any in Forth Dimensions magazine using commas either; but I'd have to look through a lot of old issues to make sure that's true.
Re: 6502 Assembler in 96 lines of Forth (July 1980)
Posted: Thu Feb 11, 2021 2:01 am
by JimBoyd
Interesting. I just got an idea on how to write an editor tool to automate the task of changing the comma terminated version of the mnemonics and control flow words to a version without commas yet it will not affect any other words with commas. I think I'll get rid of those commas after all.
Re: 6502 Assembler in 96 lines of Forth (July 1980)
Posted: Thu Feb 18, 2021 1:40 am
by JimBoyd
I ran into a minor issue which I mention here.
Re: 6502 Assembler in 96 lines of Forth (July 1980)
Posted: Sat Feb 18, 2023 3:42 am
by JimBoyd
The best reason to leave the commas at the end of the opcodes is that it's how most other RPN Forth Assembly language is written.
Thank you! I don't have experience with other RPN Forth assemblers. I will keep the commas.
I removed the commas from my assembler about two years ago and do not miss them.
This reads much nicer
Code: Select all
CODE BOUNDS ( N1 N2 -- N1+N2 N1 )
CLC
0 ,X LDA 2 ,X ADC 0 ,X STA
1 ,X LDA 3 ,X ADC 1 ,X STA
' SWAP @ JMP END-CODE
than this
Code: Select all
CODE BOUNDS ( N1 N2 -- N1+N2 N1 )
CLC,
0 ,X LDA, 2 ,X ADC, 0 ,X STA,
1 ,X LDA, 3 ,X ADC, 1 ,X STA,
' SWAP @ JMP, END-CODE
and it's faster to type.