Also, it would be much less dangerous if the results were stored in the caller's arguments AFTER the MODESET KEY=NZERO. You would have to save R1 and R15 in other registers before the MODESET, perhaps R0 and R9.
Bill On Fri, 5 Apr 2013 17:27:18 -0400, Thomas H Puddicombe wrote: >Should R5 be instead R10? > >If so, whose foot was R5 pointing to? <g,d,r> > >Tom > > > >From: Scott Ford <[email protected]> >To: [email protected] >Date: 04/05/2013 04:58 PM >Subject: C and Assembler >Sent by: IBM Mainframe Discussion List <[email protected]> > > > >Guys: > >I have an Assembler routine below i want to call in C. I have changed it >to be LE conforming. > >GETSP231 START 0 >GETSP231 AMODE 31 >GETSP231 RMODE ANY > EDCPRLG BASEREG=R12,DSALEN=WORKLEN > USING LGINWORK,R13 SAVEAREA AND LOCAL VARS >*------------------------------------------------------------- >* LOADS STG AMOUNT INTO R9, STG ADDR INTO R10 AND RC IN R11 >*------------------------------------------------------------- > LM R9,R11,4(R1) LOAD ADDRESS STG AMT, ADR & RC > L R9,0(R9) STG AMT - S/B 4K MULTIPLE > MODESET KEY=ZERO,MODE=SUP GO INTO SUPERVISOR MODE > STORAGE OBTAIN,LENGTH=(9),SP=231,LOC=ANY > ST R1,0(R5) RETURN ADDR, IF ANY > ST R15,0(R11) RETURN CODE, OK IF ZERO > MODESET KEY=NZERO,MODE=PROB BACK TO MORTALITY >*------------------------------------------------------------- > EDCEPIL > LTORG >LGINWORK EDCDSAD >WORKLEN EQU *-LGINWORK > YREGS > END GETSP231 > >In C is did this: > >/*--------------------------------*/ >#include <stdio.h> >#include <string.h> >#pragma linkage(GETSP231,OS) >int rc; >unsigned long int fullwd2; >char fullwd1[8]; >main() >{ > fullwd2 = 102400; > rc = GETSP231(&fullwd2,&fullwd1,&rc); > printf("Getsp231 rc: %d\n",rc); > if (rc == 0 ) > { printf("Getsp231 allocation worked\n"); > printf("Allocation of: %d\n,",fullwd2); > printf("Allocation at: %s\n,",fullwd1); > } > else > { printf("Getsp231 allocation failed\n"); > } > } > >I get a RC=0 which is great, but i should get the address passed back to C >and I dont see it .. >So ...i call upon the great C crystal ball ... > ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
