Home | Forums | What's new | Resources | |
Inline Assembly |
vbt - Jan 18, 2003 |
AntiPasta | Jan 18, 2003 | |||
if you want to learn SH2 asm I think you'd better use SNASMSH2 like I do... then when you get a feel of the instruction set you could bother with the weird GCC syntax... |
antime | Jan 18, 2003 | |||||||
GCC's own manual has a section on it, titled Assembler Instructions with C Expression Operands..., but like most GNU manuals it's not as good as one would hope. A couple of other links I managed to dig up: http://www.cs.virginia.edu/~clc5q/gcc-inline-asm.p... combines a few popular docs on inline assembly. x86-oriented like most, unfortunately. http://linuxassembly.org/... focuses on assembly programming for Linux. http://www.egnite.de/ethernut/GCCAVRInlAsmCB.pdf... is a doc on using assembly in the AVR port of GCC. It differs a bit from mainstream GCC, but it seems like a pretty good document nevertheless. http://www-106.ibm.com/developerworks/linu...brary... is IBM's tutorial on x86 assembly under Linux. I'm still suspicious of _A being modified in your example, IMO it would be better written as
Code:
|
vbt | Jan 18, 2003 | |||
Antime, you know too many doc. sites and your site is really great, I use it very often.
|
antime | Mar 29, 2003 | |||
What core are you using? It's difficult to tell what's going on from just a partial snippet (ie. what is the array SZ used for?) Two things though: bit-munging is much easier in assembler and sometimes it's easier to do a table look-up than to compute the value and secondly the Z80 flags are 1:1 reproducible in the x86 flags so if you do the same operations in x86 assembly you get the flags for "free" (remember that the two share a common ancestor, Intel's 8080). |
vbt | Mar 29, 2003 | |||
It's the Z80 core used by SMS plus and derived from MAME's Z80 core. Thanks for your answer it's really interesting. I need to learn more about Z80 internal core. |
AntiPasta | Mar 29, 2003 | |||
Z80 ASM is actually very easy and straightforward (although it is VERY different from SH2, but a lot like x86). I'd recommend you look here... (scroll to the bottom) |
TakaIsSilly | Mar 29, 2003 | ||||
If i recall correctly, the MAME Z80 uses the SZ[] array to check if the zero/sign flag should activate. The ASM core seems to retrieve that flag directly from of the CPU. In the SH-2 attempt I made, I used comparisations to set this flag. As for the GCC syntax, is not that terrible. I learned to use it with little more than the as exceptions doc and the Hitachi SH-2 reference. Writing code worthwile, that's where the real deal is:
Code:
You can replace it on the MAME core, and it will compile and run correctly on a SH-2. But it's 2 instructions slower than the C built code :/ |
vbt | Apr 20, 2003 | |||
I tried to use this code instead of the C function but after that the emu seemed to be stucked TakaIsSilly thanks again for your help |