gupta@cullsj.UUCP (Yogesh Gupta) (06/18/88)
Hello VMS gurus,
I have a question regarding VAX-C:
Can I embed one or more Vax-assembler statements in my C program?
If so, how?
I would like to do the following:
{
char *x;
int y;
... c-code
x = foo;
y = bar;
ASM [bbssi y, x, label1]; /* there is no c statement to do this */
... c-code
ASM [bbcci y, x, label2]; /* there is no c statement to do this */
... c-code
label1: c-code;
label2: c-code;
}
Any comments, suggestions, etc?
Yogesh
--
Yogesh Gupta | If you think my company will let me
Cullinet Software, Inc. | speak for them, you must be joking.
LEICHTER@VENUS.YCC.YALE.EDU ("Jerry Leichter ", LEICHTER-JERRY@CS.YALE.EDU) (06/23/88)
I have a question regarding VAX-C: Can I embed one or more Vax-assembler statements in my C program? If so, how? You can't. Embedding assembler code in an HLL is a hack. Either use an HLL that provides REALLY low-level, totally non-portable support for the hardware (BLISS is the only one I know of that supports EVERYTHING; VAX C has some limited stuff - if I remember right, MTPR/MFPR and the interlocked queue instructions - that you can find out about if you read the VAXELN listings, but it's not really supported except for the VAXELN developers), or call an assembler subroutine. For the particular case you give (uses of BBSSI and BBCCI), the assembler subroutines already exist (LIB$BBxxI). In most cases, the difference in performance isn't going to be noticeable. In the rare cases where it is, you may want to move a larger chunk of code into the assembler routine. This might be worth it anyway, if a couple of micro- seconds REALLY matter to you; VAX C generates pretty good code, but a skilled "code bummer" can usually beat it if he tries hard enough. -- Jerry
gupta@cullsj.UUCP (Yogesh Gupta) (06/24/88)
I have received a bunch of replies stating that I should just use the LIB$BBSSI routines. I would, except that I can not make the VAX-C compiler to generate code (ONE instruction) in-line for this routine. It is not that I need this routine to be fast, I need to hold the bit for as short a time as possible. So, the code between LIB$BBSSI and LIB$BBCCI is very small (a few instructions). Now, if they are routines, then the code between the macro instructions BBSSI ans BBCCI just doubled! This is what I am trying to avoid. Thanks everyone for your replies. Any suggestions (other than "do it all in macro")?
GG.SPY@ISUMVS.BITNET ("John Hascall") (07/01/88)
> Date: Thu, 23 Jun 88 21:18:45 GMT > Sender: INFO-VAX Discussion <INFO-VAX@UBVM> > From: Yogesh Gupta <voder!cullsj!gupta@ucbvax.Berkeley.EDU> > Subject: Re: Vax assembler code in C routines. > > I have received a bunch of replies stating that I should just use the LIB$BBSS I > routines. I would, except that I can not make the VAX-C compiler to generate > code (ONE instruction) in-line for this routine. It is not that I need this > routine to be fast, I need to hold the bit for as short a time as possible. > So, the code between LIB$BBSSI and LIB$BBCCI is very small (a few > instructions). Now, if they are routines, then the code between the macro > instructions BBSSI ans BBCCI just doubled! This is what I am trying to avoid. > > Thanks everyone for your replies. Any suggestions (other than "do it all in > macro")? Well, you could always do something truly arcane like, put the code you want to execute (the BBSSI, the middle stuff, the BBCCI) into an array and then put the address of the array into a variable defined as a pointer to a function and call it, something like.... char objcode[] = { 0x00, 0x00, /* .entry rtn,M<> */ 0xE6, 0x00, .... /* BBSSI #0,.... */ : : 0xE7, 0x00, .... /* BBCCI #0,.... */ 0x04}; /* RET */ int *objrtn() = &objcode[0]; dummy = *objrtn();