LambdaMikel
Experienced Member
- Joined
- Jan 25, 2020
- Messages
- 309
Great! Good progress - maybe one more example: just knowing the CFA's doesn't help if we wanted to do the patching from "within" Forth.
See, as @GeoffB17 already explained, the definitions are in the parameter fields. To illustrate - say you have (acutally performed on the HX-20 Forth ):
: test + ;
How do we peek inside the definition of test?
' TEST @ U. -> 25798 OK
And as we already know, this is indeed the CFA of "+":
' + CFA U. -> 25798
How do we know when a definition ends? By checking for some EXIT word in the definition (EXIT does not seem to be defined, but there ought to be something equivalent):
' TEST DUP 2 + @ U. @ U. -> 25668 25798
So, the "EXIT" word in the definition of TEST is at CFA 25668. For all definitions (e.g., if you define
: test2 - ;
you'll also find
' TEST2 DUP 2 + @ U. @ U . -> 25668 26649
(where 26649 is the CFA of '-')
So in the "Forth disassembler" that @GeoffB17 describes, you'll have to go through the parameter field of each word you encounter until you find the 25668 address)
And now what I don't know - for BEEP, we obviously have a valid CFA and WORD - but within the definition of BEEP, we will probably find the "firmware routine":
' BEEP DUP DUP DUP 2+ @ U. @ U. -> 12850 13107
Now, THAT might either be MACHINE code (you can define words also in machine code directly), or it might be the BEEP firmware routine somehwere.
EDIT: So, after all, it might be easier to just edit that stuff in the ROM directly.
See, as @GeoffB17 already explained, the definitions are in the parameter fields. To illustrate - say you have (acutally performed on the HX-20 Forth ):
: test + ;
How do we peek inside the definition of test?
' TEST @ U. -> 25798 OK
And as we already know, this is indeed the CFA of "+":
' + CFA U. -> 25798
How do we know when a definition ends? By checking for some EXIT word in the definition (EXIT does not seem to be defined, but there ought to be something equivalent):
' TEST DUP 2 + @ U. @ U. -> 25668 25798
So, the "EXIT" word in the definition of TEST is at CFA 25668. For all definitions (e.g., if you define
: test2 - ;
you'll also find
' TEST2 DUP 2 + @ U. @ U . -> 25668 26649
(where 26649 is the CFA of '-')
So in the "Forth disassembler" that @GeoffB17 describes, you'll have to go through the parameter field of each word you encounter until you find the 25668 address)
And now what I don't know - for BEEP, we obviously have a valid CFA and WORD - but within the definition of BEEP, we will probably find the "firmware routine":
' BEEP DUP DUP DUP 2+ @ U. @ U. -> 12850 13107
Now, THAT might either be MACHINE code (you can define words also in machine code directly), or it might be the BEEP firmware routine somehwere.
EDIT: So, after all, it might be easier to just edit that stuff in the ROM directly.
Last edited: