LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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

Reply
 
LinkBack Search this Thread
Old 08-03-2004, 10:08 PM   #1
Annie0716
LQ Newbie
 
Registered: Jul 2004
Posts: 10

Rep: Reputation: 0
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; 08-03-2004 at 10:12 PM.
 
Old 08-04-2004, 07:16 AM   #2
Marius2
Member
 
Registered: Jan 2004
Location: Munich
Distribution: SuSE 9.2, 10.2, 10.3, knoppix
Posts: 274

Rep: Reputation: 30
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"
);
 
Old 08-04-2004, 08:37 PM   #3
Annie0716
LQ Newbie
 
Registered: Jul 2004
Posts: 10

Original Poster
Rep: Reputation: 0
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; 08-04-2004 at 08:38 PM.
 
Old 08-05-2004, 02:10 AM   #4
Marius2
Member
 
Registered: Jan 2004
Location: Munich
Distribution: SuSE 9.2, 10.2, 10.3, knoppix
Posts: 274

Rep: Reputation: 30
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
 
Old 08-05-2004, 03:57 AM   #5
Annie0716
LQ Newbie
 
Registered: Jul 2004
Posts: 10

Original Poster
Rep: Reputation: 0
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 the-baradas dot com>
To: binutils at sources dot redhat dot com
Cc: peter at the-baradas 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 m68k-parse.y to fix a
missing ')'.
--
Peter Barada
peter@the-baradas.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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
squirremail ...it says invalid user or invalid password. rnj Fedora 9 10-25-2004 09:56 PM
log.winbindd:uid range missing or invalid jwizardc Linux - Networking 1 07-14-2004 10:24 AM
Procedure call number is out of range China Jack Linux - Networking 1 06-11-2004 11:54 AM
Procedure number out of range TY2K4 Linux - Networking 2 05-29-2004 05:47 AM
invalid operand 0000 x2000koh Linux - General 3 07-03-2003 08:50 AM


All times are GMT -5. The time now is 07:22 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration