programming tools for Windows applications development
  Home  |   SwiftForth Archive  |   SwiftX Archive  |

asm code for SWAP?

From: Michael Hugh Knowles <mhknowles_at_paias.com>
Date: Sat, 22 Mar 2003 23:32:23 -0300

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.

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.

MHKnowles

----------------------------------------------------------------------
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:40:09 PST

This archive was generated by hypermail 2.2.0 : Tue Dec 02 2008 - 03:04:31 PST