Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Tiger99

Assembly

This topic is 5540 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello All The following is the example of the inline assembly code I got from the web. which get the value of A7 address register and put it in temp. Then temp can be used as a normal C varible My question is that how can I do the opposit eg. copy the value in temp and put it in A7 please help Thanks asm("move.l %%a7, %0" : "=d" (temp) : ); current_proc->user_stack = temp;

Share this post


Link to post
Share on other sites
Advertisement
Doesn't this work ?


asm( "move.l %0, %%a7"
:
: "d" (temp)
: "a7" // if you want a7 to be saved & restored
);


See this page. It is not extremely clear, but that's all the documentation I am aware of on inline assembly in gcc.


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]


[edited by - Fruny on March 23, 2003 4:42:16 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Tiger99
should I use %7 instead of %%7?



%7 should refer to the 8th ''formal'' operand, just like %0 here refers to the first ''formal'' operand, that is the variable ''temp''.

There is a second page, I''m looking at it right now.

More info if I find or understand any


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]

Share this post


Link to post
Share on other sites
Actually, your best bet if you have a full GNU environment is to look at the info pages for gas in addition to the gcc inline assembly ones.

The page on the Motorola 68k confirms %a7 ... that's the CPU you're using, right ?

note - messing up a6 or a7 is usually a *bad* idea, since they are the frame and stack pointers respectively.


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]


[edited by - Fruny on March 23, 2003 4:59:24 PM]

Share this post


Link to post
Share on other sites
I am not sure
My Teaching assistant told me that I could find the answer in the following documentation
http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html

but I have problem understanding most of the part

Share this post


Link to post
Share on other sites
quote:
Original post by Tiger99
http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html



That''s where I''ve been pulling the doc from (except from the 3.2 version instead of the 2.95 one).

I''ll decompose the statement you''ve been using :

asm( // opcodes
"mov.l %a7, %0" // Move (mov)
// 32 bits (.l)
// from register a7 (%a7)
// to operand #0 (%0)
: // formal output operands
"=d" (temp) // operand #0 is write only (=)
// operand #0 is in a data register (d)
// operand #0 is the C variable ''temp'' ((temp))
: // formal input operands
// none
);


The compiler is free to choose any data register to put ''temp'' in.

Share this post


Link to post
Share on other sites
Hello
I am getting an unknown register name a7 in asm
How could I solve this problem?

please help

Thanks
VOID initialization(VOID)
{
int sr;
/* Disable all interupts */
asm( "move.w #0x2700,%sr" );
coldfire_vbr_init();
//Initialize PCB
initialize_pcb();
sr = NullPCB[254];
asm( "move.l %0, %%a7" : : "d" (sr) : "a7" // if you want a7 to be saved & restored
);
asm("rte");
/* enable interrupt */
asm( "move.w #0x2000,%sr" );
}

Share this post


Link to post
Share on other sites
Since you haven't confirmed whether you were using a M68K processor - which has an A7 register - I cannot answer that question. Look at the gas info page for what register your CPU does provide. You can also try taking out the : "a7" part, because, the way you're using it, the whole statement is a no-op.




[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]


[edited by - Fruny on March 23, 2003 7:00:55 PM]

Share this post


Link to post
Share on other sites
I am using M68K, I took off the a7 but it compiles. However, I am getting
Illegal stack type! and
Access Error: FS=C, Physical bus error on operand read

errors after I download to the coldfire board
How can I fix the problems?

Thanks

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!