Comp Number Guy
Comp Number Guy

Reputation: 41

Using Statement in z390 Mainframe Code

About what I'm using: I'm using z390 Portable Mainframe Assembler and Emulator.

I'm getting a "no base register found" error when attempting to assemble.

I tried putting in USING *,12 but wherever I put it it doesn't do anything. "no base register found"

I tried to apply BASR 12,0; got an error. I got:

17:53:44 PROG4     EZ390 EZ390E error  11 ABEND PSW=07050600 800FFCEC F6F6F6F64040 ????? ABEND S0C1
17:53:44 PROG4     EZ390 EZ390E error  12 program aborting due to abend S0C1

An assembly manual is at http://publibz.boulder.ibm.com/epubs/pdf/asmr1020.pdf, but I'm having trouble applying it.

A source I looked at: http://en.wikipedia.org/wiki/IBM_Basic_assembly_language#Assembler_instructions

How do I have the assembler find the base register?

Update: Still having trouble with the base register.

Additional resources:

www.tradingwiz.net63.net/pdf/Sessions5and6.pdf

www.z390.org/z390_Documentation.htm

        TITLE 'CS 4321 Program #4 by J. Colt Wright' 
        PRINT NOGEN    
COPY          SUBENTRY
    USING *,12
    TITLE 'PROGRAM 4 80/80 LISTING'
    PRINT NOGEN
COPY2 SUBENTRY

    WTO 'PROG4 COPY PROG4 (ASCII) TO COPY (ASCII)'
    OPEN (INFILE,INPUT)
    OPEN (OUTFILE,OUTPUT)
    WTO 'Files opened successfully'
*

LOOP EQU *
    GET INFILE,IRECORD
    MVC ORECORD,=CL80' '
    MVC ORECORD(72),IRECORD
    PUT OUTFILE,ORECORD
    B LOOP
*
EOF EQU *
    CLOSE (INFILE,,OUTFILE)
    WTO 'PROG4 ENDED OK'
    SUBEXIT

    SUBEXIT   


INFILE  DCB     DDNAME=INFILE,                                         X
                DSORG=PS,                                              X
                RECFM=FT,                                              X
                LRECL=72,                                              X
                EODAD=EOF,                                             X
                MACRF=GM
*
OUTFILE DCB     DDNAME=OUTFILE,                                        X
                DSORG=PS,                                              X
                RECFM=FT,                                              X
                LRECL=80,                                              X
                MACRF=PM
*
IRECORD DC    CL72' '
ORECORD DC    CL80' '
ENDPGM  DS D
 END COPY

I either get an abend or a "no base register found" error, depending on whether or not I provide COPY2 SUBENTRY.

I'm trying to get the code to run.

I have the code working besides for this.

Upvotes: 1

Views: 960

Answers (3)

zarchasmpgmr
zarchasmpgmr

Reputation: 1424

First, you should not need the COPY SUBENTRY, as that only places a copy of the macro definition into the source during first-pass processing. There are times where you might need it (specifically for macro debugging), but this is not one of those times. (SUBENTRY/EXIT are distributed as assist macros with z390.)

I took your program and removed the PRINT NOGEN statements. In general, I don't like using PRINT NOGEN, because there is lots of information that it suppresses, such as the instructions generated by SUBENTRY. Back in the days of tree-killing printouts, you saw this more, but now when listings are sent to disk, it's not a big deal.

Generally, when you have entry macros like SUBENTRY, it sets up a base register. Deleting the PRINT NOGEN shows that it's actually putting the register 13 (or R13--a common abbreviation in assembler) save area at the beginning of the program area, and it's using R13 as your base register and initializing it. What has happened is that you've run into a documented rule of the assembler, but not many people remember it. The rule is: if an address is covered by multiple USING statements, the assembler will use the lower-numbered register. Your USING *,12 at the beginning is covering the entire program, which is OK, but it overlaps the "USING COPY2+8,13" that SUBENTRY generates.

So what happens is that your data areas are covered by two registers, and the assembler chose the lower value (12). And because you never loaded a value into R12, it's pointing at who knows what. So when you try to access data off that register - boom.

The simple solution is to remove the USING *,12 from your program, and the assembler generates base-displacement address from R13. I did this and it died because I don't have the input files, but I expected that.

Upvotes: 2

Singlestone
Singlestone

Reputation: 2099

The site doesn't make it apparent how to comment on the original question, so I'll make an entry here.

More information is needed. Which base register is the assembler expecting? PRINT NOGEN says "don't show the instructions generated by macros", and without seeing them, we can't tell what's going on. PRINT GEN is generally the default, and is generally useful.

As for your S0C1: The value of F6F6F6F64040 showing after the PSW is the key to understanding the problem. It appears that your added BASR 12,0 instruction caused the use of an invalid address for the code base. At the time of the abend, register 12 addressed a hunk of data with the F6F6... value, the first byte of which (F6) is an invalid opcode. Invalid opcodes produce S0C1 abends. This kind of thing will happen when base registers are assigned improper addresses.

Upvotes: 0

Matthew Slattery
Matthew Slattery

Reputation: 46998

I haven't used z390 (and know only a little about 390 assembly in general), but: SUBENTRY and SUBEXIT must be macros which expand to a CSECT declaration and appropriate register fiddling for entry/exit, and so I would guess that nesting the COPY2 SUBENTRY ... SUBEXIT inside the COPY SUBENTRY ... SUBEXIT is a really bad idea.

Upvotes: 0

Related Questions