HEX
Most of the system runs in user mode. In user mode you cannot disable interrupt. There are however times when interrupts must be disabled. When you are updating system list for instance.
Trap 08 to 0F can be used to control interrupts level enabling and disableing. Many systems however don't have the rich interrrupt control that is available with the 68k family so we have limited ourselves to these two functions. Enable and disable.
CODE _lock_word ( --)
0F # TRAP
NEXT inline
CODE _unlock_word ( -- )
08 # TRAP
NEXT inline
run_tcp is executed when a packet is queue by udp or tcp
CODE run_tcp
06 # TRAP
NEXT inline
Used to execute a word in superviser state
CODE super_execute ( ?? code --)
03 # TRAP
NEXT inline
Divide the input by 4.
CODE 4/ ( n1 --n2)
S )+ D0 MOV
2 # D0 ASR
D0 S -) MOV
NEXT inline \ 8 bytes allow for speed.
The top stack to the third.
CODE -rot ( 32b1 32b2 32b3 -- 32b3 32b1 32b2)
S )+ D0 MOV
S )+ D1 MOV
S )+ D2 MOV
D0 S -) MOV
D2 S -) MOV
D1 S -) MOV
NEXT
Square root of an unsigned integer
CODE sqrt ( u0 -- u1 )
S )+ D0 MOV \ i
0 # D1 MOV \ a
0 # D2 MOV \ c
0F # D3 MOV \ j
40000000 # D4 MOV \ s = 1 << (j*2)
BEGIN
D1 D6 MOV
D3 D6 LSL
1 # D6 LSL \ a<<(j+1)
D2 D6 ADD \ c + (a<<(j+1))
D4 D6 ADD \ d = c + (a<<(j+1)) + s)
\ D6 = d D0 = i
D6 D0 CMP CC IF \ if d<=i
D6 D2 MOV \ c = d
1 # D7 MOV
D3 D7 LSL \ 1<< j
D7 D1 OR \ a |= 1<< j
THEN
D0 D6 CMP EQ IF \ d = i
D1 S -) MOV
NEXT assembler
THEN
2 # D4 LSR \ s>>=2
1 # D3 SUB
LT UNTIL
D1 S -) MOV
NEXT
Swap the low two bytes of the top stack item.
AABBCCDD -> AABBDDCC
CODE >< ( 32b1 - 32b2)
3 S) D0 B. MOV
2 S) 3 S) B. MOV
D0 2 S) B. MOV
NEXT inline
Swap the two words of the top stack item.
AABBCCDD -> CCDDAABB
CODE >w< ( 32b1 - 32b2)
S ) D0 MOV
D0 SWP
D0 S ) MOV
NEXT inline
AABBCCDD -> DDCCBBAA
CODE >l< ( 32b1 - 32b2)
S ) D0 MOV
D0 D1 MOV
8 # D1 LSL
8 # D0 LSR
D0 D1 B. MOV
8 # D1 LSL
8 # D0 LSR
D0 D1 B. MOV
8 # D1 LSL
8 # D0 LSR
D0 D1 B. MOV
D1 S ) MOV
NEXT
Drop the top three stack items.
CODE 3drop
0C # S ADD
NEXT inline
Drop the top four stack items.
CODE 4drop
10 # S ADD
NEXT inline
The base address of the tasks user area.
CODE @u
U S -) MOV
NEXT inline
Takes the address of the stack doing so is not recommended.
CODE @s ( - addr)
S S -) MOV
NEXT
Definitly a no no. You will find it used in the rpc code. The parameters are moved to the call buffer using a MOVE.
CODE !s
S ) S MOV
NEXT
Takes the address of the return stack doing so is not recommended.
CODE @r ( - addr)
R S -) MOV
NEXT
Takes the address of the lp doing so is not recommended.
CODE @lp ( - addr)
LP S -) MOV
NEXT
The loop limit. It is no longer a standard word.
CODE i' ( - 32b)
8 R) S -) MOV
NEXT
Fetch a sixteen bit value; you also need one to fetch the valuein network order; irrelivent for COLDFORTH but very relevent for intel based system.
#5407 [IF]
CODE W@ ( addr -- 16b)
S )+ A0 MOV
A0 ) D0 W. MVZ
D0 S -) MOV
NEXT
inline
[ELSE]
CODE W@ ( addr -- 16b)
S )+ A0 MOV
0 # D0 MOV
A0 ) D0 W. MOV
D0 S -) MOV
NEXT
\ [THEN]
Fetch a sixteen bit signed value.
CODE s@ ( addr -- n)
S )+ A0 MOV
A0 ) A1 W. MOV
A1 S -) MOV
NEXT inline
CODE W! ( n a)
S )+ A0 MOV
2 # S ADD
S )+ A0 ) W. MOV
NEXT inline
CODE W+! ( n a--)
S )+ A0 MOV
S )+ D0 MOV
\ we only use the low sixteen bits so it doesn't matter
\ how the high bits are set.
[ A0 ] D1 W. MOV
D1 D0 ADD
D0 A0 ) W. MOV
NEXT
CODE C+! ( n a --)
S )+ A0 MOV
S )+ D0 MOV
\ we only use the low eight bits so we don't
\ have to worry about how the high bits are set.
[ A0 ] D1 B. MOV
D1 D0 ADD
D0 [ A0 ] B. MOV
NEXT
\ set the op register
CODE >op ( addr --)
S )+ OP MOV
NEXT