IBM Mainframe Assembler - using MVC with a register displacement

mainframe assembler tutorial pdf
hlasm programmer's guide
mainframe assembler training

I am working on an assignment for a college assembly class. We are using IBM Mainframe PC370 emulator. (Old school, but great starting point)

I always try to go a little beyond the scope of the assignment in order to better my programming skills.

What I am trying to do is to move some character data (WORD) into (CWORD) with a offset of 1 using a register. My hope is to be able to place data into an index based off of the input from a file to determine the placement in an index.

We have been given a file that has a five digit dollar figure in position 1-5 and a two digit month code in position 20-21. I would like to put the month code in a register to determine the offset to add the dollar amount into that position in the index.

The following code is what I have been using to attempt the register offset.

Is this even possible? I have not found anything in the textbook or online that specifically discusses doing this type of thing.

         L     R5,1
         MVC   CWORD+0(R5),WORD
         WTO   CWORD
         WTOR  'PRESS ENTER TO EXIT',EXIT

Thank you for your time. SUBCAN

You wrote:

      L     R5,1                        Get the fullword (32bit) value at location 0001.
      MVC   CWORD+0(R5),WORD            Copy the 5 bytes at location WORD to location CWORD.
      WTO   CWORD                       Display the contents of CWORD.
      WTOR  'PRESS ENTER TO EXIT',EXIT  Display the message and wait for a response.

Plus, presumably:

CWORD DS    CL5                     Output area.
      ...
WORD  DS    CL4                     Input area

You should have written:

      LA    R5,CWORD+1                  Get the address of the second byte of CWORD.
      MVC   0(L'WORD,R5),WORD           Copy the Length(WORD) bytes at location WORD to location CWORD+1.
      WTO   CWORD                       Display the contents of CWORD.
      WTOR  'PRESS ENTER TO EXIT',EXIT  Display the message and wait for a response.
      ...
CWORD DS    CL5                     Output area.
WORD  DS    CL4                     Input area

At least, that sounds like what you wanted. But it isn't 100% clear from your question. If that wasn't your intention.

IBM Mainframe Assembler, You wrote: L R5,1 Get the fullword (32bit) value at location 0001. MVC CWORD+​0(R5),WORD Copy the 5 bytes at location WORD to location  The USING tells the assembler which registers to use when converting symbols to base/displacment addresses. So a symbol like X might be converted to a base/displacement address like C008 (C = Base register 12, displacment = 008).

     LA     R5,1
     MVC   CWORD+0(R5),WORD

In MVC instruction we provide length and not the register. In your case R5 will be interpreted as 5 since in starting of your program you would have declared R5 EQU 5 so it will move 5 characters and not 1.

If you want to use register use like below EX R5,MOVE . . . Move MVC CWORD(0),WORD

so this will replace legnth with the value in R5. In this case you can place value in R5 LA R5,1 will work

Reagrds, Shashank Assembler Developer.

[PDF] Introduction to Assembler Programming, subroutines etc. □ ARs – used in “Access Register” mode – provides the ability to access another address When coding base and displacement as part of an assembler HLASM – IBM's High Level Assembler Use MVC to copy the data. The USING instruction specifies a base address and range and assigns one or more base registers. If you also load the base register with the base address, you have established addressability in a control section. If a control section has not been established, USING initiates an unnamed (private) control section.

...move some character data (WORD) into (CWORD) with a offset of 1 using a register...

As per the above specification:

  [code to establish base register assumed] 
  LA 1,CWORD+1
  MVC 0(L'CWORD-1,1),WORD
  [...]
* assuming WORD and CWORD are both 4-byte fullwords
* only the first three bytes of WORD will fit into CWORD+1
WORD  DS  F 
CWORD DS  F 

[PDF] HLASM V1R6 Language Reference, HLASM Language Reference is for application programmers coding in the High represent storage addresses, displacements, constants, registers, and almost any MVC. AREA1,=C'This Area' Space inside quotes. In quotes, spaces and  Base register + displacement lets you specify an address in 16 bits: 4 bits to specify a register and 12 bits to specify the displacement. A register contained 32 bits, so you potentially had 4 gig of addressability in the register plus 4K in the displacement. The 12-bit displacement stayed fixed; you could achieve full relocatability much more

[PDF] Relative Addressing Part I, program to either save/restore registers in order to reuse them, or if that is not possible, consider addressing, IBM delivered a new assembler copybook and macro: IEABRC and found in z/OS V1R12.0 MVS Programming Assembler Services Reference Vol 2. MVC W_EYE,=CL16'REL1 W/S->' plug eye catcher in w/s. our wish to use register 12 as a base register, and associates R1 with the base address denoted by *. (Remember that * refers to the current value of the location counter in the assembler.) The MVC will move four bytes (x’03’ + 1). The target address is x’c008’ – an eight byte displacement off the contents of register 12.

DSECT instruction, The USING instruction tells the assembler that the register contains the lets the assembler determine a base register and displacement for the dummy section. ATYPE DS 0H MVC OUTPUTA,DATA_A MVC OUTPUTB,DATA_B FINISH BR  The USING instruction specifies a base address and range and assigns one or more base registers. If you also load the base register with the base address, you have established addressability in a control section. If a control section has not been established, USING initiates an unnamed (private) control section.

Labeled USING instruction, The labeled USING instruction specifies a base address, one or more base registers, and a USING label which can be used as a symbol qualifier. To indicate to the assembler that the USING established with the label is to provide of base and displacement for a symbol, the label must be used to qualify the symbol. Introduction This suite of sample programs is written in IBM Mainframe Assembler. The programs will compile using Assembler/H or HLASM. This suite provides examples of some of the coding techniques that have been used by mainframe assembler programmers.

Comments