1
           MAIN       CSECT
           USING     MAIN,15
           L         6,=F'1000'
           XDECO     6,DISCOUNT
           XPRNT     LINE,80
           BR        14
           LTORG
LINE       DC        C'0'
DISCOUNT   DS        12C
           END       MAIN

SO I have this code in IBM assembler, what I want to do is print the value in register 6 which is 1000decimal but when I run the code it doesnt show anything

  • How about moving 1000 to LINE as that is the variable that you are wanting to print? – NicC Jul 07 '19 at 10:26
  • This isn't really "code in IBM assembler" - it's more like pseudo-code with mystery macros embedded, and what they do is anyone's guess. Just at a glance, your base register is suspect since you're using R15 and most of the services you'll call (like PUT to write the record somewhere) use R15 as a return code, squashing your base. Somehow, you're "LINE field is only one character long, and it's not clear what your "DISCOUNT" field is for. You'll need to unpack the binary F'1000' you start with into EBCDIC...point is, a lot of the stuff you'd need isn't clear from the snippet you posted. – Valerie R Jul 18 '19 at 19:35
  • The OP says he's using "assist/assembler"; this is a reference to Penn State's ASSIST system ("Assembler System for Student Instruction and Systems Teaching"), which is a one-step assembler and emulator, which included simplified pseudoinstructions for I/O (like XPRNT) and data conversion (like XDECO), to allow students to understand the then-S/370 instruction set without having to get immediately bogged down in things like DCBs and GET/PUT for I/O and CVD/UNPK etc. for decimal conversion. – codingatty May 31 '21 at 04:05

1 Answers1

2

It's been more almost thirty years since I've used S/3x0 assembler; and more than forty since I used ASSIST, but let's see if I can remember.

Your line XDECO 6,DISCOUNT will put the characters "1000" at the location DISCOUNT; that appears to be correct. I think the issue is likely the length specified in your XPRNT statement. (But see my comment about carriage control, below.)

After your XDECO, your storage portion looks like this:

  • LINE (1 byte): "0"
  • DISCOUNT (12 bytes): " 1000" (eight blanks, followed by the "1000")

That's it. Only 13 bytes. But your XPRNT is saying to print 80 bytes, starting at LINE. The problem is, only the first 13 bytes are defined. In a real assembler program you'd have your 13 defined bytes, and probably binary zeroes in the undefined area; I'm not sure what the ASSIST system will do.

You should do one of the following: either declare your own padding of another 67 bytes ( DC CL67' ') after DISCOUNT; or limit your XPRNT to 13 bytes.

Note: contrary to the comment above, you are correct to be printing from LINE rather than from DISCOUNT; XPRNT uses the first character for carriage control, and prints whatever follows; in this case the '0' will not be printed, but will be used to tell the printer to advance 2 lines before printing the text that follows.

In fact, it's customary for your first XPRNT to use a carriage control of '1' to indicate to advance to a new page. It's possible your program is printing the correct information (maybe with some garbage after the " 1000"), but without the advance-to-new-page, you're looking at the wrong spot instead of directly after your listing.

By the way, just a style thing: your DISCOUNT field should really be declared as:

DISCOUNT   DS        CL12

or, even better:

DISCOUNT   DC        CL12' '    NOTE: USE OF DC RATHER THAN DS HERE

instead of as:

DISCOUNT   DS        12C

DISCOUNT DS CL12 means to declare a character field of length 12 (uninitialized; DS, "declare storage", means to just declare the field); DISCOUNT DC CL12' ' means to declare a character field of length 12 and pre-fill it with blanks (DC, "declare constant", not only declares the field, but fills it as indicated). In contrast, DISCOUNT DS 12C declares a sequence of twelve fields, each of length 1 (since it's not specified). It won't burn you here, but some assembler instructions will used the length of the field as a default when a length is not explicitly specified, so it's a good idea to use the right length when declaring.

codingatty
  • 2,026
  • 1
  • 23
  • 32