IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

MVC in assembler


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
hchinnam

New User


Joined: 18 Oct 2006
Posts: 73

PostPosted: Wed Oct 01, 2008 3:53 pm
Reply with quote

All,

I have following piece of code in my pgm

Code:


        MVC   KEY1,SPACES                                           
        MVC   KEY2,SPACES                                           
        WTO   MF=(E,WTOBLOCK)          DISPLAY THEM                 
        MVC   KEY1(R9),0(7)            GET THE KEY FROM FILE1       
        WTO   MF=(E,WTOBLOCK)          DISPLAY THEM                 
        MVC   KEY2(R9),0(8)            GET THE KEY FROM FILE2       
        WTO   MF=(E,WTOBLOCK)          DISPLAY THEM                 



Declarations as below

Code:

WTOBLOCK EQU   *                                                     
         DC    H'150'         * FOR WTO, LENGTH OF WTO BUFFER...     
         DC    H'0'                     SHOULD BE BINARY ZEROES...   
WTOTEXT  DC    CL1'D'                                               
D        DC     CL30'< WS STARTS HERE>       '                       
D0       DC     CL1'A'                                               
SAV02    DS     F                                                   
D01      DC     CL1'B'                                               
SAV07A   DS     F                                                   
D02      DC     CL1'C'                                               
SAV08A   DS     F                                                   
D03      DC     CL1'D'                                               
SAV09A   DS     F                                                   
D04      DC     CL1'E'                                               
KEY1     DS     CL50'                                          '     
D05      DC     CL1'F'                                               
KEY2     DS     CL50                                                 


My memory at R7 looks as below,

Code:

1 A                                                                     


My memory at R8 looks as below,

Code:

2 B                                                                     


for this my WTO output looks as below

Code:


 11.00.21 JOB04253  +D< WS STARTS HERE>             A    B     ¯ C     ÷ D       E                                         
4FF4FF4FF4DDCFFFFF444C44EE4EECDEE4CCDC64444444444444C0000C00000A2C00000E2C0000000C444444444444444444444444444444444444444444
011B00B2101620425300E4C062023193208595E0000000000000100002000001030000010400000015000000000000000000000000000000000000000000
---------------------------------------------------------------------------------------------------------------------------
 11.00.21 JOB04253  +D< WS STARTS HERE>             A    B     ¯ C     ÷ D       E1 A                                       
4FF4FF4FF4DDCFFFFF444C44EE4EECDEE4CCDC64444444444444C0000C00000A2C00000E2C0000000CF4C444444444444444444444444444444444444444
011B00B2101620425300E4C062023193208595E0000000000000100002000001030000010400000015101000000000000000000000000000000000000000
---------------------------------------------------------------------------------------------------------------------------
 11.00.21 JOB04253  +D< WS STARTS HERE>             A    B     ¯ C     ÷ D       E1 A                                       
4FF4FF4FF4DDCFFFFF444C44EE4EECDEE4CCDC64444444444444C0000C00000A2C00000E2C0000000CF4C444444444444444444444444444444444444444
011B00B2101620425300E4C062023193208595E0000000000000100002000001030000010400000015101000000000000000000000000000000000000000
---------------------------------------------------------------------------------------------------------------------------
                             F2 B                                                                                           
44444444444444444444444444444CF4C4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444
0000000000000000000000000000062020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000



As you can see my R9 content is 1 (between 'D' and 'E'). Now my question is why my MVC statement is moving more then one character.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Oct 01, 2008 4:43 pm
Reply with quote

Your MVC syntax is not correct and I don't see why you need R9.

MVC KEY1,0(R7)
MVC KEY2,0(R8)

Note that the data moved to KEY1 and KEY2 will equal the length of these labels (50-Bytes).

Where do you have SPACES defined?

Regards,

Bill
Back to top
View user's profile Send private message
hchinnam

New User


Joined: 18 Oct 2006
Posts: 73

PostPosted: Wed Oct 01, 2008 5:55 pm
Reply with quote

Bill O'Boyle wrote:


I don't see why you need R9.



This is part of a key matching program. Each file will have a key, and position and length of the key are passed in a control card.

I store the length in R9. So i need it go get the exact Key out.

Quote:


Your MVC syntax is not correct



Can please explain. I didn't see anything wrong with syntax. over to that, pgm compiled and ran with out any issues. it's just that results are not as expected.

Quote:


Where do you have SPACES defined?


Yes it is defined.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Oct 01, 2008 6:32 pm
Reply with quote

Quote:
Can please explain. I didn't see anything wrong with syntax. over to that, pgm compiled and ran with out any issues. it's just that results are not as expected.
Have you looked at the expansion of the MVC instruction in the Assembler listing? Do you see where it starts D208? The D2 means it is an MVC instruction, the 08 means you're moving 9 bytes of data -- not the length in register 9, but 9 actual bytes.
Back to top
View user's profile Send private message
hchinnam

New User


Joined: 18 Oct 2006
Posts: 73

PostPosted: Wed Oct 01, 2008 7:12 pm
Reply with quote

Thanks for the clarification Robert. Is there a way in Assembler to pass length in a variable?

i.e I will have length to be extracted in a GPR and i want to move that many bytes to a destination.

I know i can do this with MVI and loop but is there a better way.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Oct 01, 2008 7:15 pm
Reply with quote

Investigate the EX instruction -- it exists for MVC of variable length data.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Oct 01, 2008 10:40 pm
Reply with quote

I agree that you probably need to use an EX of an MVC instruction, which is a popular (and powerful) instruction combination.

If you can't figure out how to use this (or the length of your Operand 1 data exceeds 256 --- MVC limitation), then you can use an MVCL.

However, an MVCL requires the use of four (4) registers and you can probably get away with using R0/R1 for the RECEIVING address and length and R14/R15 for the SENDING address and length or (if you need to be cautious) save them in two adjacent doublewords, using a Load Multiple (LM) and restore them using a Store Multiple (STM).

FWIW, the maximum length for an MVCL is 16777215 (16MB-1).

Regards,

Bill
Back to top
View user's profile Send private message
bengtpelle

New User


Joined: 28 Aug 2006
Posts: 24
Location: St. Petersburg, FL

PostPosted: Wed Oct 22, 2008 9:24 pm
Reply with quote

Change your code to:

Code:
       MVC   KEY1,SPACES                                           
        MVC   KEY2,SPACES                                           
        WTO   MF=(E,WTOBLOCK)          DISPLAY THEM                 
        EX      R9,MVC1                   GET THE KEY FROM FILE1       
        WTO   MF=(E,WTOBLOCK)          DISPLAY THEM                 
        EX      R9,MVC2                   GET THE KEY FROM FILE2       
        WTO   MF=(E,WTOBLOCK)          DISPLAY THEM                 
         -
         -
         B      ?????
MVC1 MVC   KEY1(0),0(7)            GET THE KEY FROM FILE1     
MVC2 MVC   KEY2(0),0(8)            GET THE KEY FROM FILE2
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Oct 22, 2008 11:11 pm
Reply with quote

You need to issue a -

Code:

      BCTR   R9,0          REDUCE BY 1 FOR 'MVC' LENGTH

The BCTR is required every time R9 is loaded.

FWIW, you can also issue an "ADD HALFWORD IMMEDIATE" of a negative 1 -

Code:

      AHI    R9,-1         REDUCE BY 1 FOR 'MVC' LENGTH

Regards,

Bill
Back to top
View user's profile Send private message
Bill Dennis

Active Member


Joined: 17 Aug 2007
Posts: 562
Location: Iowa, USA

PostPosted: Thu Oct 23, 2008 2:41 am
Reply with quote

Make sure R9 isn't zero and goes negative or you'll move 256 bytes!
Back to top
View user's profile Send private message
bengtpelle

New User


Joined: 28 Aug 2006
Posts: 24
Location: St. Petersburg, FL

PostPosted: Thu Oct 23, 2008 2:58 am
Reply with quote

It can be zero!!!
Zero means one byte.
R9 should contain number of bytes to move -1.
Back to top
View user's profile Send private message
stkg

New User


Joined: 22 Oct 2008
Posts: 1
Location: Japan

PostPosted: Thu Oct 23, 2008 6:01 am
Reply with quote

Code:
MVC   KEY1(R9),0(7)

is interpreted as
Code:
MVC   KEY1(9),0(7)

and then it means "move 9 byte from the storage pointed by R7 to KEY1".
hlasm sees this "9" as the length
Back to top
View user's profile Send private message
Bill Dennis

Active Member


Joined: 17 Aug 2007
Posts: 562
Location: Iowa, USA

PostPosted: Thu Oct 23, 2008 7:14 pm
Reply with quote

bengtpelle wrote:
It can be zero!!!
Zero means one byte.
I meant if R9 starts as zero and you -1 then you get x'FF' for the MVC.
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Thu Oct 23, 2008 8:15 pm
Reply with quote

Also, in my experience, an MVC with length of -1 will move "two's complement " bytes. Assembler didn't enforce the 256-byte limit and a large chunk of memory got overwritten - it wasn't easy to debug.

Garry
Back to top
View user's profile Send private message
Mario S Nusbaum

New User


Joined: 27 Jan 2009
Posts: 1
Location: Sao Paulo,Brazil

PostPosted: Wed Jan 28, 2009 1:51 am
Reply with quote

Garry Carroll wrote:
Also, in my experience, an MVC with length of -1 will move "two's complement " bytes. Assembler didn't enforce the 256-byte limit and a large chunk of memory got overwritten - it wasn't easy to debug.

Garry


No way! It'll move exactly 256 bytes. There aren't negative values in the lenght field. Otherwise you'd "loose" the first bit.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Build dataset list with properties us... PL/I & Assembler 4
No new posts Finding Assembler programs PL/I & Assembler 5
No new posts How Can I Recall a Migrated Data Set ... PL/I & Assembler 3
No new posts step by step trace 4 ISPF dialog call... TSO/ISPF 17
No new posts Getting SOC4 while calling a Cobol DB... PL/I & Assembler 4
Search our Forums:

Back to Top