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

On Sat, Mar 22, 2003 at 11:32:23PM -0300, Michael Hugh Knowles wrote:
> X-Spam-Checker-Version: SpamAssassin 2.51 (1.174.2.4-2003-03-20-exp)
>
> I have started translating some floating point intensive forth (SF 2.2.2.9)
> into code for speed, and I have been perusing the source for examples of how
> to do things. I saw the code for SWAP and had a question:
>
>
> ICODE SWAP ( x1 x2 -- x2 x1 ) \ exchange top and second
> 0 [EBP] EAX MOV
> EBX 0 [EBP] MOV
> EAX EBX MOV
> RET END-CODE
>
> { EBP is the data stack pointer, and EBX holds the TOS element }
>
> Why not:
>
> ICODE SWAP ( x1 x2 -- x2 x1 ) \ exchange top and second
> 0 [EBP] EBX XCHG
> RET END-CODE
>
> It seems to work, but maybe there is some obscure reason why not.
>
Because XCHG does an implicit bus lock so that the exchange happens atomically.
The first code sample will likely run to completion a few times over before
your version finished.
> Also, I thought I should be able to do a 2 # AL SHL but when I do a
>
> code zzz EBX EAX MOV 2 # AL SHL EAX EBX MOV RET END-CODE it assembles with
> no errors, but when I run it I get an ACCESS_VIOLATION.
>
I have no help for you here.
> MHKnowles
>
-- Trey
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Sat Mar 22 2003 - 18:58:34 PST
This archive was generated by hypermail 2.2.0 : Tue Dec 02 2008 - 03:04:31 PST