Assembler coding has it’s role to fill. There are a lot of system services that are only available to assembler programs and when performance is key there is often nothing better. That being said, when you are coding in assembler you want to focus on the problem at hand and not spend a lot of time debugging print routines or parsing routines, et al. Wouldn’t be nice to have a trove of already written routings to call upon to do the more mundane things? Try using the C runtime library. The only requirement to use the C runtime from assembler is that the assembler program be Language Environment (LE) enabled. The calls are static as they are resolved at link-edit from SCEELKED.
LE enabled means using the appropriate macros for entry to and exit from the program and including some DSECT macros. Use CEEENTRY for the entry point, for example,
ceetest2 CEEENTRY PPA=mainppa,BASE=11,AUTO=DSA_SIZE
CEETERM to exit:
CEETERM RC=0
and include these:
mainppa CEEPPA , CEEDSA , [...] DSA_SIZE EQU *-CEEDSA
These macros are in SCEEMAC. The dynamic area (automatic storage) is in CEEDSA (so you don’t have to do a separate getmain). [Note that there are other ways to set this up.]
Here’s an example I wrote to convince myself that leap seconds were being handled:
ceetest2 CEEENTRY PPA=mainppa,BASE=11,AUTO=DSA_SIZE * TIME DEC,ZONE=GMT ST R0,TIMEGMT ST R1,DATEGMT TIME DEC,ZONE=LT ST R0,TIMELOC ST R1,DATELOC * CALL TIME,NULL time_t time(NULL) ST R15,CurTimeT * CALL PUTS,LEGENDSTR, + MF=(E,arglist) * CALL GMTIME,CurTimeT, struct tm *gmtime(time_t *) + MF=(E,arglist) ST R15,CurTimeTM LR R2,R15 CALL ASCTIME,((R2)), char *asctime(strcut tm *) + MF=(E,arglist) ST R15,CharTime LR R2,R15 L R3,TIMEGMT L R4,DATEGMT CALL PRINTF, + (GMTSTR,(R4),(R3),(R2)), + MF=(E,arglist) * CALL LOCALTIM,CurTimeT, + MF=(E,arglist) ST R15,CurTimeTM LR R2,R15 CALL ASCTIME,((R2)), char *asctime(struct tm *) + MF=(E,arglist) ST R15,CharTime LR R2,R15 L R3,TIMELOC L R4,DATELOC CALL PRINTF, + (LOCSTR,(R4),(R3),(R2)), + MF=(E,arglist) * CEETERM RC=0 * LEGENDSTR DC C'TIME Macro CCYYDDDf HHMMSSth C Runtine' DC X'1500' GMTSTR DC C' ZONE=GMT %08x %08x gmtime(): %s' DC X'00' LOCSTR DC C' ZONE=LT %08x %08x localtime(): %s' DC X'00' * NULL DC A(0) * mainppa CEEPPA , * EJECT , * CEEDSA , * arglist DS 5A * DATEGMT DS F TIMEGMT DS F DATELOC DS F TIMELOC DS F * CurTimeT DS F time_t CurTimeTM DS A *(struct tm) CharTime DS A *(char) * * DSA_SIZE EQU *-CEEDSA * CEECAA , * YREGS * END ceetest2