Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. 
Notices 
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto 
Site FAQ 
Sitemap 
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQrelated cookies.

Introduction to Linux  A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free. 


08032004, 11:08 PM

#1

LQ Newbie
Registered: Jul 2004
Posts: 10
Rep:

invalid `asm': operand number out of range
I am trying to compile my codes with inline assembler, but a error occured.
Could anyone give help me to have a look on my codes?
Thank you!
void mdct( long *in, long *out)
{
__asm__("move.l %2,%%a1\n\t"
"move.l %3,%%a2\n\t"
"adda.l #2448,%%a2\n\t"
"move.l #18,%%d1\n\t"
"LOOP_ONE:\n\t"
"move.l %1,%%a0\n\t"
"move.l #0x00000040, %%macsr\n\t"
"move.l #0,%%ACC1\n\t"
"movem.l (%%a0), #0x0078\n\t"
"movem.l (%%a2), #0x7800\n\t"
"mac.l %%d3, %%a3.ll,%%acc1\n\t"
"mac.l %d4, %a4.11,ACC1\n\t"
"mac.l %%d5, %%a5.11,ACC1\n\t"
"mac.l %%d6, %%a6.11,ACC1\n\t"
"movem.l (16,%%a0), #0x0078\n\t"
"movem.l (16,%%a2), #0x7800\n\t"
"mac.l %%d3, %%a3.11,ACC1\n\t"
"mac.l %%d4, %%a4.11,ACC1\n\t"
"mac.l %%d5, %%a5.11,ACC1\n\t"
"mac.l %%d6, %%a6.11,ACC1\n\t"
"movem.l (32,%%a0), #0x0078\n\t"
"movem.l (32,%%a2), #0x7800\n\t"
"mac.l %%d3, %%a3.11,ACC1\n\t"
"mac.l %%d4, %%a4.11,ACC1\n\t"
"mac.l %%d5, %%a5.11,ACC1\n\t"
"mac.l %%d6, %%a6.11,ACC1\n\t"
"movem.l (48,%%a0), #0x0078\n\t"
"movem.l (48,%%a2), #0x7800\n\t"
"mac.l %%d3, %%a3.11,ACC1\n\t"
"mac.l %%d4, %%a4.11,ACC1\n\t"
"mac.l %%d5, %%a5.11,ACC1\n\t"
"mac.l %%d6, %%a6.11,ACC1\n\t"
"movem.l (64,%%a0), #0x0078\n\t"
"movem.l (64,%%a2), #0x7800\n\t"
"mac.l %%d3, %%a3.11,ACC1\n\t"
"mac.l %%d4, %%a4.11,ACC1\n\t"
"mac.l %%d5, %%a5.11,ACC1\n\t"
"mac.l %%d6, %%a6.11,ACC1\n\t"
"movem.l (80,%%a0), #0x0078\n\t"
"movem.l (80,%%a2), #0x7800\n\t"
"mac.l %%d3, %%a3.11,ACC1\n\t"
"mac.l %%d4, %%a4.11,ACC1\n\t"
"mac.l %%d5, %%a5.11,ACC1\n\t"
"mac.l %%d6, %%a6.11,ACC1\n\t"
"movem.l (96,%%a0), #0x0078\n\t"
"movem.l (96,%%a2), #0x7800\n\t"
"mac.l %%d3, %%a3.11,ACC1\n\t"
"mac.l %%d4, %%a4.11,ACC1\n\t"
"mac.l %%d5, %%a5.11,ACC1\n\t"
"mac.l %%d6, %%a6.11,ACC1\n\t"
"movem.l (112,%%a0), #0x0078\n\t"
"movem.l (112,%%a2), #0x7800\n\t"
"mac.l %%d3, %%a3.11,ACC1\n\t"
"mac.l %%d4, %%a4.11,ACC1\n\t"
"mac.l %%d5, %%a5.11,ACC1\n\t"
"mac.l %%d6, %%a6.11,ACC1\n\t"
"movem.l (128,%%a0), #0x0078\n\t"
"movem.l (128,%%a2), #0x7800\n\t"
"mac.l %%d3, %%a3.11,ACC1\n\t"
"mac.l %%d4, %%a4.11,ACC1\n\t"
"mac.l %%d5, %%a5.11,ACC1\n\t"
"mac.l %%d6, %%a6.11,ACC1\n\t"
"move.l ACC1, (%%a1)\n\t"
"suba.l #4, %%a1\n\t"
"suba.l #144, %%a2\n\t"
"sub.l #1, %%d1\n\t"
"bne LOOP_ONE\n\t"
:"=m"(*out)
:"r"(in),"r"(out),"r"(win_cos_l)
:"%a0","%a1","%a2");
}
Note: *win_cos_l is a global variable
.................
l3mdct.c:707: invalid `asm': operand number out of range
l3mdct.c:707: invalid `asm': operand number out of range
Last edited by Annie0716; 08032004 at 11:12 PM.



08042004, 08:16 AM

#2

Member
Registered: Jan 2004
Location: Munich
Distribution: SuSE 9.2, 10.2, 10.3, knoppix
Posts: 274
Rep:

Hm. Good one. It looks like MC68k code, am I right? If my next guess is right and you're using gcc, I believe you'd be better off with the AT&T notation, because it is portable, if I understand correctly (and it's been a while since I used MC68k  what is
this mac opcode?)
Could you specifiy which line corresponds to number 707? Just comment out par
ticular lines and recompile, until it goes through the compilation.
BTW you don't have to put every line in quotation marks, just write like this:
asm(" movl %0,%%esi;
movl %1,%%edi;
movl %2,%%ebx;//Max. input string len
xorb %%dl,%%dl;
movb $13,%%dh;
lcp_1: movb (%%esi),%%cl;
movb %%cl,(%%edi);
incl %%esi;
incl %%edi;
decl %%ebx;
jz lcp_2;
cmpb %%dh,%%cl;//13
ja lcp_1;
je lcp_2;
cmpb %%dl,%%cl;//0
je lcp_2;
cmpb $10,%%cl;
jne lcp_1;
lcp_2:
"
:"=r"(psrc),"=r"(pdst),"=m"(pmaxlen)
:"0"(psrc),"1"(pdst),"2"(pmaxlen)
:"%ebx","%ecx","%esi","%edi"
);



08042004, 09:37 PM

#3

LQ Newbie
Registered: Jul 2004
Posts: 10
Original Poster
Rep:

Thank you for your help!
Yes, you are correct! I am using the MC68k and gcc.
I recompiled the code, and marked the error lines this time.
Acctually, I am trying to use the EMAC instrustions, but errors occured everytime.
Moreover, I also tried to use the MAC instruction (like this, move.l #0, %%acc; mac %%d0, %%a0; ) as a test. Althougth I coulde compile it, I do know how to use the SF to make a 1bit right shift.
The syntax is:
MAC.sz Ry.{U,L},Rx.{U,L}SF, ACCx
(Size= word, longword)
I donot know if I use the EMAC correctly, because the error message is not clear for me.
Could you give me a help?
Thank you so much!
__asm__("move.l %2,%%a1\n\t"
"move.l %3,%%a2\n\t"
"adda.l #2448,%%a2\n\t"
"move.l #18,%%d1\n\t"
"LOOP_ONE:\n\t"
"move.l %1,%%a0\n\t"
"move.l #0x00000040, %%macsr\n\t"
"move.l #0,%%ACC1\n\t"
"movem.l (%%a0), #0x0078\n\t"
"movem.l (%%a2), #0x7800\n\t"
"mac.l %%d3, %%a3.ll,%%acc1\n\t"
"mac.l %d4, %a4.11,ACC1\n\t"
"mac.l %%d5, %%a5.11,ACC1\n\t"
"mac.l %%d6, %%a6.11,ACC1\n\t"
"movem.l (16,%%a0), #0x0078\n\t"
"movem.l (16,%%a2), #0x7800\n\t"
"mac.l %%d3, %%a3.11,ACC1\n\t"
"mac.l %%d4, %%a4.11,ACC1\n\t"
"mac.l %%d5, %%a5.11,ACC1\n\t"
"mac.l %%d6, %%a6.11,ACC1\n\t"
"movem.l (32,%%a0), #0x0078\n\t"
"movem.l (32,%%a2), #0x7800\n\t"
"mac.l %%d3, %%a3.11,ACC1\n\t"
"mac.l %%d4, %%a4.11,ACC1\n\t"
"mac.l %%d5, %%a5.11,ACC1\n\t"
"mac.l %%d6, %%a6.11,ACC1\n\t"
"movem.l (48,%%a0), #0x0078\n\t"
"movem.l (48,%%a2), #0x7800\n\t"
"mac.l %%d3, %%a3.11,ACC1\n\t"
"mac.l %%d4, %%a4.11,ACC1\n\t"
"mac.l %%d5, %%a5.11,ACC1\n\t"
"mac.l %%d6, %%a6.11,ACC1\n\t"
"movem.l (64,%%a0), #0x0078\n\t"
"movem.l (64,%%a2), #0x7800\n\t"
"mac.l %%d3, %%a3.11,ACC1\n\t"
"mac.l %%d4, %%a4.11,ACC1\n\t"
"mac.l %%d5, %%a5.11,ACC1\n\t"
"mac.l %%d6, %%a6.11,ACC1\n\t"
"movem.l (80,%%a0), #0x0078\n\t"
"movem.l (80,%%a2), #0x7800\n\t"
"mac.l %%d3, %%a3.11,ACC1\n\t"
"mac.l %%d4, %%a4.11,ACC1\n\t"
"mac.l %%d5, %%a5.11,ACC1\n\t"
"mac.l %%d6, %%a6.11,ACC1\n\t"
"movem.l (96,%%a0), #0x0078\n\t"
"movem.l (96,%%a2), #0x7800\n\t"
"mac.l %%d3, %%a3.11,ACC1\n\t"
"mac.l %%d4, %%a4.11,ACC1\n\t"
"mac.l %%d5, %%a5.11,ACC1\n\t"
"mac.l %%d6, %%a6.11,ACC1\n\t"
"movem.l (112,%%a0), #0x0078\n\t"
"movem.l (112,%%a2), #0x7800\n\t"
"mac.l %%d3, %%a3.11,ACC1\n\t"
"mac.l %%d4, %%a4.11,ACC1\n\t"
"mac.l %%d5, %%a5.11,ACC1\n\t"
"mac.l %%d6, %%a6.11,ACC1\n\t"
"movem.l (128,%%a0), #0x0078\n\t"
"movem.l (128,%%a2), #0x7800\n\t"
"mac.l %%d3, %%a3.11,ACC1\n\t"
"mac.l %%d4, %%a4.11,ACC1\n\t"
"mac.l %%d5, %%a5.11,ACC1\n\t"
"mac.l %%d6, %%a6.11,ACC1\n\t"
"move.l ACC1, (%%a1)\n\t"
"suba.l #4, %%a1\n\t"
"suba.l #144, %%a2\n\t"
"sub.l #1, %%d1\n\t"
"bne LOOP_ONE\n\t"
:"=m"(*out)
:"r"(in),"r"(out),"r"(win_cos_l)
/*line 706*/ :"%a0","%a1","%a2");
l3mdct.c: In function `mdct':
l3mdct.c:706: invalid `asm': operand number out of range
l3mdct.c:706: invalid `asm': operand number out of range
Last edited by Annie0716; 08042004 at 09:38 PM.



08052004, 03:10 AM

#4

Member
Registered: Jan 2004
Location: Munich
Distribution: SuSE 9.2, 10.2, 10.3, knoppix
Posts: 274
Rep:

I cutcopypasted your code into one of my projects, but sadly SuSE
only comes with x86 gcc. There are still a few points of interest
(though they are only roughly guessed).
1. Concerning line 706  "clobbered registers"
Try giving an operand size, the compiler may not only want to
know which registers you are explicitly changing ("clobbering")
in your code but their size as well. So try changing
:"%a0","%a1","%a2"); to :"%a0.l","%a1.l","%a2.l");
or :"%a0.ll","%a1.ll","%a2.ll");
2. I think all registers should be addressed with a double %,
so the line "mac.l %d4, %a4.11,ACC1\n\t" should actually read
"mac.l %%d4, %%a4..."
3. I'm finding a
"mac.l %%d3, %%a3.ll,%%acc1\n\t"
and a
"mac.l %%d5, %%a5.11,ACC1\n\t"
but I think only %%a[n].ll is correct (longlong, maybe?)
BTW May I ask what you are doing with a dct on 68k? Is this
going to be a software mpg decoder on a coldfire in an embedded
machine? What is the purpose?
HTH



08052004, 04:57 AM

#5

LQ Newbie
Registered: Jul 2004
Posts: 10
Original Poster
Rep:

Thank you so much! I will try it again right now.
Considering to the "mac.l %%d5, %%a5.11,ACC1\n\t", in fact, I just want to implement the instruction "MAC.sz Ry.{U,L},Rx.{U,L}SF, ACCx". According to the program manual, it will be >>1, when ths SF is 11.
Now, I am almost confused by some posts I found, one is as followed:
Patch to properly assemble/disassemble ColdFire MAC/EMAC instructions
From: Peter Barada <peter at thebaradas dot com>
To: binutils at sources dot redhat dot com
Cc: peter at thebaradas dot com
Date: Tue, 20 Apr 2004 11:56:01 0400 (EDT)
Subject: Patch to properly assemble/disassemble ColdFire MAC/EMAC instructions

This is a repost of the patch with change in m68kparse.y to fix a
missing ')'.

Peter Barada
peter@thebaradas.com
>Teun Grinwis pointed out to me that the assembler currently has
>support for the MAC, but not support for the EMAC, so I added the
>instructions and operands.
>
>I also ripped out the gross hack of the macmw/macml/msacmw/msacml
>insns and added '&' parsing so it understands mask addressing for the
>mac instructions. While I was chaning the parser, I added the
>proper scale factors tokens for the mac instructions, namely '<<' and
>'>>'. I left in the previous support of using '+1", '1' to specify
>the scale factor.
>
>Now the assembler properly handles:
>
> mac.w %a1l,%a2u,<<,(%a3)&,%d1,%acc1
===========================================
I donot know if I have to patch or change somethings to make the emac instruction works.
I tried the one above with the change I need, but it doesnot work.
Do you have any idea about this?
Thanks again!
I am trying to make a software encoder of mp3 on MCF5249, and the mdct is for it. In fact, I am trying to use the assembler to accelerate its running speed. I want to implement a realtime encoder.
It was for a mp3 player before, but now just for my study.



Thread Tools 
Search this Thread 


Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off



All times are GMT 5. The time now is 07:18 PM.

LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.

Latest Threads
LQ News

