Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

MVC in assembler

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
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    Post subject: MVC in assembler
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Oct 01, 2008 4:43 pm    Post subject: Re: MVC in assembler
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    Post subject: Re: MVC in assembler
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: 7912
Location: Bellevue, IA

PostPosted: Wed Oct 01, 2008 6:32 pm    Post subject:
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    Post subject:
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: 7912
Location: Bellevue, IA

PostPosted: Wed Oct 01, 2008 7:15 pm    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Oct 01, 2008 10:40 pm    Post subject: Re: MVC in assembler
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    Post subject: Use the EX instruction
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Oct 22, 2008 11:11 pm    Post subject: Re: Use the EX instruction
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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

Active Member


Joined: 08 May 2006
Posts: 988
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Thu Oct 23, 2008 8:15 pm    Post subject:
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    Post subject: Lenght field in MVC
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    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Online Assembler Program Starting point Aditya.Srivastava PL/I & Assembler 4 Fri Jul 08, 2016 6:48 pm
This topic is locked: you cannot edit posts or make replies. MVS Assembler profiles for Pune Locat... shailesh_do Mainframe Jobs 0 Mon Feb 22, 2016 6:21 pm
No new posts ASRA abend calling Assembler from CICS surya8 PL/I & Assembler 13 Thu Sep 10, 2015 7:50 pm
No new posts Is Enterprise PL/I v4.2 compatible wi... sundarkudos PL/I & Assembler 2 Wed Aug 19, 2015 11:15 pm
No new posts Assembler Code to check normal retur... amitc23 PL/I & Assembler 6 Mon Aug 17, 2015 3:52 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us