Re: [colorforth] Machine Forth 'IF'
- Subject: Re: [colorforth] Machine Forth 'IF'
- From: Jeff Fox <fox@xxxxxxxxxxxxxxxxxxx>
- Date: Mon, 24 Feb 2003 11:23:22 -0800
Frank Kujawski wrote:
>
> I would like to revisit this question on an index if.
> The if uses the value on top of the data stack to compute its target
> address. Two questions come to mind,
> 1) is the first address after command the '0' address or '1'?
Forth uses a branch if the top of the parameter stack is zero.
Code falls through if T is true and jumps to the ELSE or
THEN portion (no ELSE in colorforth) when T=0.
Chuck named the opcode T0 or T=0 on P21. The traditional
Forth name was 0Branch.
> 2) should the address be relitive or absolute?
There are advantages to each. P21 and F21 use paged branches.
That is upper bits come from the program counter, lower bits
are in the instruction. P21 has only 10-bit page branching
opcodes. The macro >R ; is used for branching to anywhere.
F21 has 10-bit and 14-bit paged branch instructions and
a home-page bit in a control register. When this bit is
clear homepage is zero in DRAM (actual zero page) when
the control bit is set homepage branch instructions
use zero in SRAM (140000h) for the upper bits of the
branch.
C18 (also used as the core in 25x) uses absolute addressing
in its 128 WORD address range.
On Pentium one could implement relative, or absolute. For
people who use Operating Systems that can load their program
at any address absolute addressing creates a problem when
systems are saved and then reloaded at a different address.
Colorforth does not have this problem when it loads things
at a known address and by compiling modules when needed
absolute addressing works fine.
Instruction bandwidth issues, argument sizes, decoding,
and the number of cycles involved are all very architectural
dependent issues.
Best wishes,
Jeff Fox
---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
Main web page - http://www.colorforth.com