Colin,
>The first concerns the inequality operators ( < and > ). I find the sense=
>of them to be the opposite of what I would expect and is specified in the
>=93SwiftForth Programming for Windows=94 manual (middle p. 137). To
>illustrate,
>I use the following test word to examine a number on the stack and replace=
>it with zero if it (the number on the stack) is greater than 10.
>
> CODE Test ( n1 -- n2 )
> 10 # EBX CMP < IF 0 # EBX MOV THEN
> RET END-CODE
>
>When I execute the word I get the opposite result:
>
> 12 test . 12 ok
> 8 test . 0 ok
The manual is wrong. The sense "seems" inverted, but it follows from
how the CMP operator works, subtracting 10 from EBX and then testing
the sign (or is it the overflow) bit. In english, that code would read
something like: if ebx is less than 10, set ebx to zero.
>The second problem pertains to the following code:
>
>VARIABLE topPatron \ pointer to jump byte at head of first record
>
>CODE resetPatrons ( -- )
> topPatron # EAX MOV
> 0 [EAX] EAX MOV
> BEGIN 0 # 0 [EAX] BYTE CMP 0<> WHILE
> 127 # 0 [EAX] BYTE AND \ mask the flag bit.
> 0 [EAX] BYTE EAX ADD
> REPEAT
> RET END-CODE
>
The first and most obvious problem is that 0 [EAX] BYTE EAX ADD simply
adds the byte at 0 [EAX] to AL -- not to EAX . Not sure about the rest of
it tho...
Try:
CODE RESETPATRONS
TOPPATRON # EAX MOV 0 [EAX] EAX MOV
0 # ECX MOV BEGIN
0 [EAX] CL MOV
CL CL OR 0<> WHILE
127 # CL AND CL 0 [EAX] MOV
ECX EAX ADD
REPEAT END-CODE
rICK
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
Received on Mon Mar 19 2001 - 15:35:16 PST
Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!
This archive was generated 08-Feb-2012. Archive updated nightly.