"Condit, Christopher" <[EMAIL PROTECTED]> wrote: > > Thanks for the info Paul, but unfortunately I didn't specify my question > adequately. I'm writing *IBM* assembler, where a move is spelled MVC. My > third-hand doc says to write IBM opcodes but use Unix syntax. Whatever that > means. Here's a simplified example that would get 2 errors, for 2 label > references: > > __asm__ __volatile__( > " CHI %3,20\n" > " BH LABEL1\n" > " LA 2,1\n" > " B LABEL2 > "LABEL1 LA 2,0\n" > "LABEL2 BR 14\n" > : "=a" (retValue) > : "d" (pProc), "d" (pStack), "d" (cbStack) > );
I think you're missing a \n on that B LABEL2 - and a closing quote. That would cause the definition of "LABEL1" to `go missing', which might explain things... Also - you might want to look at Systems/C (http://www.dignus.com), we think it allows direct in-line assembler in C in a much nicer fashion than GCC does. But - that's a biased opinion. Systems/C generates either HLASM or GAS output - supporting both traditional mainframe operating systems and mainframe linux. With Systems/C - you would have: ... { __register(2) int r; /* retval is in R2 */ __register(3) int t; /* testval is in R3 */ t = /* some expression - set's testval in R3 */ __asm { CHI 3,20 BH LABEL1 LA 2,1 B LABEL2 LABEL1 LA 2,0 LABEL2 BR 14 } retval = r; /* Grab R2 and place it in `retval' */ } > > I have already displayed that certain simple register manipulation works in > context, so I am confident that this language works, and that I am on the > right track. > > On the other hand, it's news to me that AT&T/Unix assembler can work on an > IBM S/390 box. Oh yeah - it's just the GNU gas assembler... generating ELF format... at some point, bits are bits... > I was only brought in on this project cuz I know IBM > assembler. If Unix assembler can be used just as well, maybe I will try to > dump this thing back on our Unix guy... Well - it's UNIX assembler syntax - but IBM instructions. I'm sure you're input will be very much appreciated... - Dave Rivers - -- [EMAIL PROTECTED] Work: (919) 676-0847 Get your mainframe programming tools at http://www.dignus.com > > CXC > > -----Original Message----- > From: Paul L. Rogers [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, April 24, 2002 11:59 AM > To: Condit, Christopher > Subject: Re: Addressing problems using asm embedded in C > > > It's been many years since I did any assembly programing, but I seem > to recall that different assemblers would use a different syntax to > denote if the address or the contents of the address should be used. > > Any chance that this explanation would apply? > > From: http://www.cis.ohio-state.edu/~parent/classes/360/faq.html > > Relocation Truncated to Fit > > The problem is that if you have declared a label, say something like: > > X: .word 20 > > Then in your code, suppose you say something like: > > mov X, %r3 > > What you are trying to do is to copy the value in the word corresponding > to X into %r3; except the right way to do it is first get the address of X > into another register etc. > > The reason why the assembler assembles this without complaint is thatthe > (unrelocated) address of X is typically small enough to fit in 13 bits > available in the mov instruction; so it assembles using that address. Then > the loader relocates the stuff and now the relocated address won't fit in > the 13 bits, so it `truncates the relocation to fit'. > > Paul > > On Wed, 24 Apr 2002, Condit, Christopher wrote: > > > Date: Wed, 24 Apr 2002 14:13:17 -0400 > > From: "Condit, Christopher" <[EMAIL PROTECTED]> > > Reply-To: Linux on 390 Port <[EMAIL PROTECTED]> > > To: [EMAIL PROTECTED] > > Subject: Addressing problems using asm embedded in C > > > > I'm trying to write some assembler embedded in C via __asm__ > __volatile__(). > > A couple hundred lines or so. Compiler doesn't complain, but linker > gives > > "relocation truncated to fit" errors on any instruction that refers to a > > label (B's and EX's). I know that message usually (in C) means you are > > calling an unknown function or else are branching too far. Neither of > these > > conditions is the case, since I am only branching down a few bytes, and > I'm > > not calling any functions by name. Total dll length is under 32K. > > > > Fooling around, I note that by recoding to avoid using any labels (lots of > > relative branching), I can eliminate the link time errors. So my linker > is > > choking basically on all labels. Anybody know what's up, or what I can do > > about it? Writing labelless code is not an appealing prospect. > > > > TIA, > > Christopher > > > > > Paul L. Rogers [EMAIL PROTECTED] > Are you prepared for NetDay? http://www.netday.org/ > Linux: It works for me. http://www.linuxdoc.org/ >
