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
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:
0
" 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.