This page (revision-7) was last changed on 03-Feb-2023 15:21 by Carsten Strotmann 

This page was created on 25-Apr-2010 09:19 by Carsten Strotmann

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Page revision history

Version Date Modified Size Author Changes ... Change note
7 03-Feb-2023 15:21 8 KB Carsten Strotmann to previous
6 25-Apr-2010 17:29 6 KB Carsten Strotmann to previous | to last
5 25-Apr-2010 17:20 4 KB Carsten Strotmann to previous | to last
4 25-Apr-2010 16:54 3 KB Carsten Strotmann to previous | to last
3 25-Apr-2010 16:45 1 KB Carsten Strotmann to previous | to last
2 25-Apr-2010 09:22 416 bytes Carsten Strotmann to previous | to last
1 25-Apr-2010 09:19 379 bytes Carsten Strotmann to last

Page References

Incoming links Outgoing links

Version management

Difference between version and

At line 50 added 31 lines
!! AN EXAMPLE
As a practical example, here's a simple call to the system monitor, via the NMI address vector (using the BRK opcode).
{{{
CODE MON ( exit to monitor )
BRK,
NEXT JMP,
END-CODE
}}}
The word CODE is first encountered, and executed by Forth. CODE builds the following name "MON" into a dictionary header and calls ASSEMBLER as the CONTEXT vocabulary.
The "(" is next found in FORTH and executed to skip til ")". This method skips over comments. Note that the name after CODE and the ")" after "(" must be on the same text line.
!! OP-CODES
BRK, is next found. in the assembler as the op-code. When BRK, executes, it assembles the byte value 00 into the dictionary as the op-code for "break to monitor via "NMI".
Many assembler word names end in ",". The significance of this is:
# The comma shows the conclusion of a logical grouping that would be one line of classical assembly source code.
# "," compiles into the dictionary, thus a comma implies the point at which code is generated.
# The "," distinguishes op-codes from possible hex numbers ADC and ADD.
!! NEXT
Forth executes your word definition under control of the address interpreter, named NEXT. This short code routine moves execution from one definition, to the next. At the end of your code definition, you must return control to NEXT or else to code which returns to NEXT.
!! RETURN OF CONTROL
Most 6502 systems can resume execution after a break, since the monitor saves the CPU register contents. Therefore, we must return control to Forth after a return from the monitor. NEXT is a constant that specifies the machine address of Forth's address interpreter (say $0242). Here it is the operand for "JMP,". As "JMP," executes, it assembles a machine code jump to the address of NEXT from the assembly time stack value.