Qdos GCC and inline assembly code

Anything QL Software or Programming Related.
Post Reply
SM7I
ROM Dongle
Posts: 45
Joined: Mon Dec 10, 2012 6:52 pm

Qdos GCC and inline assembly code

Post by SM7I »

Hi all !

In most C compilers inline assembly is accepted in one way or another. Often just a matter of finding the correct syntax.
For a few days now I´ve searched for a source that could tell/show how to do this with Qdos GCC, but so far I´ve been unsuccesful. I´m using XorA qdos-gcc docker container.

Can anyone please shine a light on how to do this please ?


User avatar
tofro
Font of All Knowledge
Posts: 3009
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Qdos GCC and inline assembly code

Post by tofro »

In a nutshell, you simply pack your assembly statements in-between an asm volatile () bracket.

Code: Select all

void main () {
   asm volatile (
      "move.l #100,d0");
}
The volatile should be present to prevent GCC from over-eagerly optimizing away your precious code.

GCC knows an extended asm statement that allows you to specify input / output operands and clobbered registers:

Code: Select all

asm asm-qualifiers ( AssemblerTemplate 
                 : OutputOperands 
                 [ : InputOperands
                 [ : Clobbers ] ])
A description on how to specify these extended arguments to asm can be found here, for example.


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
SM7I
ROM Dongle
Posts: 45
Joined: Mon Dec 10, 2012 6:52 pm

Re: Qdos GCC and inline assembly code

Post by SM7I »

That is exactly what I’ve tried, but when compiling gcc complains about jas missing :

Tried different variants, but same error.


SM7I
ROM Dongle
Posts: 45
Joined: Mon Dec 10, 2012 6:52 pm

Re: Qdos GCC and inline assembly code

Post by SM7I »

Solved it....sat me down and figured about the error and more or less tried until I got it right :)


Post Reply