![]() |
||
| Home | SwiftForth Archive | SwiftX Archive | |

Dear Folks,
Recently, while writing assembler code in SwiftForth (2.00.3) I encountered
two problems.
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
“SwiftForth Programming for Windows” 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 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
and in particular the “mask the flag bit” line of code. (What this word
does is go through a concatenated string of records where each record begins
with a ‘jump’ count byte in which the high (sign) bit serves as a flag.
This code resets this flag bit on each record until it encounters a jump
byte of zero which terminates the loop.)
When I run this code it makes one successful pass through the looping
portion of the code and then gives an ‘ACCESS_VIOLATION’ error message on
the second pass. However I find that if I run the code with the DWORD size
specifier in place of BYTE it works fine except, of course, the three high
bytes of the DWORD end up masking out the three leading bytes in each
record. Then it occurred to me that I could simply create a DWORD mask that
would preserve the three leading bytes. I.e. in binary the following mask:
1111111111111111111111101111111. This gave me the ACCESS_VIOLATION error.
So I tried other masks and find that 00001111111111111111111101111111 works
but anything higher such as 00011111111111111111111101111111 causes the
ACCESS_VIOLATION. I'm stumped. I’d be grateful for any suggestions.
Best regards, Colin
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
Received on Mon Mar 19 2001 - 10:28:38 PST
This archive was generated by hypermail 2.2.0 : Thu Nov 20 2008 - 03:04:18 PST