Print Topic - Archive
XBLite Forum / Working Code Snippets / Low Level stuff (ASM inside)
Posted by: 26 (Guest), August 24, 2008, 9:39am
I am working to rewrite some of my ASM and lowlevel code from NASM to include it directly in XBlite.This is a MMX copying demo and i'll post more if i think they can be usefull.
Posted by: XBLiteAdmin, August 24, 2008, 10:37pm; Reply: 1
Thanks for the mmx mCopyMemory demo.
ciao,
D.
Posted by: 13 (Guest), August 25, 2008, 6:54am; Reply: 2
Hi Fano,
Thanks for this. One trick that you may not be aware of is that you can also put asm routines in your program between the final END FUNCTION and END PROGRAM. Then declare them as EXTERNAL. That way you can have the "purest" assembly in your code, without the xblite stack frame and initialization.
For an example of that, see xblite.x, scroll down to the very end, and you will see the StrCmp function done in that manner.
Excellent coding BTW. I may borrow it. :)
Yours,
Greg
Posted by: 26 (Guest), August 25, 2008, 9:23am; Reply: 3
Quoted from 13
One trick that you may not be aware of is that you can also put asm routines in your program between the final END FUNCTION and END PROGRAM. Then declare them as EXTERNAL. That way you can have the "purest" assembly in your code, without the xblite stack frame and initialization.
This is a great trick ! I took a look to xblite.x and i think it will be very usefull, thanks a lot ;)
I'm going to try to learn more about goAsm because i'm still a bit confused with its syntax.A last thingie : this is great to have definitions for variables in functions.It is now an easy work to use local variables directly in asm, no more need to work with EBP offsets :D
Posted by: 13 (Guest), August 25, 2008, 9:47am; Reply: 4
Yeah, I didn't like the EBP offsets either. The method I implemented using definitions is not perfect, but it works in most cases.
One thing I like about GoAsm is that it's syntax is consistent. Once you learn it, it will make a lot of sense.
Greg
Posted by: 13 (Guest), August 26, 2008, 8:51am; Reply: 5
Quoted from 26
I am working to rewrite some of my ASM and lowlevel code from NASM to include it directly in XBlite.This is a MMX copying demo and i'll post more if i think they can be usefull.
Have you seen AdaptAsm.exe, which is part of the GoAsm distribution? It automates some of this.
Greg
Posted by: 26 (Guest), August 26, 2008, 12:23pm; Reply: 6
Thanks i'll take a look to this tool but i think it will not very usefull because i'm trying to rewrite code (Nasm/Xblite) to take advantage of MMX/SSE (speaking about SSE, it is difficult to find a correct doc about that, it is often a list of opcode quickly commented without diagrams :s)
Posted by: 26 (Guest), August 28, 2008, 11:16am; Reply: 7
After testing more mCopy, i realized it was slower when using MMX so i rewrote it to use fully MMX register so now it is faster :)
I inclued too mFill(MMX) and mCompare(MMX/SSE) , the program testes theses funcs in 6 steps, the size of blocks if powered by 2 each step.
-copying block to another (use MMX if it is larger than 64bytes)
-filling a block with 0
-comparing identical blocks
-comparing differents blocks
On a AthlonXP2400+, the MMX code is faster except when blocks are differents (results varies a lot).Theses funcs are not located on the main file so you can include them with m4 without modifications (see memtest.x).To compile demo, load memtest.x and compile with M4 preprocessor checked in options/compiler.
Posted by: Rhett Thompson, August 28, 2008, 2:57pm; Reply: 8
Posted by: 26 (Guest), August 29, 2008, 10:03am; Reply: 9
Made a little error in mCopy, edited and attached
Print page generated: February 5, 2012, 2:42pm