PDA

View Full Version : jump's in inline assembler




Larrson
Feb 24, 2009, 07:32 PM
Hi,

Could anyone tell me, please, what wrong is with this frag of code:

...
dec edx
jnz short loc_10014FC3
xor edx, edx
...


There is always "error: expected primary-expression before 'short'"

And, where i can find more informations about inline assembly on Mac OSX.

Cheers,
L.



LtRammstein
Feb 26, 2009, 01:56 PM
All of my assembly programming have been done on Freescale HC12s, so the information I give could and probably is wrong.

Fro my understanding, and I can be wrong, that a short is just a way to define a length of bits, problem is you need to define what kind of data it is, an int or what not.

So from my assembly programming, we don't worry about casting or anything like that. We know that the registers and data are in 2's complement, and are 16 bits (2 words) big.

This might be a place to start:

http://developer.apple.com/DOCUMENTATION/DeveloperTools/Reference/Assembler/000-Introduction/chapter_1_section_1.html

kainjow
Feb 26, 2009, 08:33 PM
From googling that error it looks like you might have a curly-brace syntax error, possibly surrounding the asm block, but that's just a wild guess ;)

Larrson
Mar 5, 2009, 01:44 AM
Hi,

Sorry guys for delay from my end.
Problem solved by removing word "short"; you right LtRammstein, no casting or anything like that.

Cheers,
L.

gnasher729
Mar 5, 2009, 03:31 AM
And, where i can find more informations about inline assembly on Mac OSX.


Google for "gcc documentation". As a simple example for inline assembler, create a program, enter "htonl", Jump to definition and follow where it takes you. Inline assembler is tough.

What you are trying to do is assembler, not inline assembler. Go to any source file, best in "Release" mode, and "Show assembler" in the Build menu. Look at what's there. Then add a .s file to your project containing your own assembler code.