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

data moved using MVI on para-name.


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

New User


Joined: 29 Jun 2021
Posts: 16
Location: India

PostPosted: Fri Aug 26, 2022 11:39 pm
Reply with quote

i am not able to understand what exactly line 2 is trying to do in the below attached code. normally MVI instruction is used on a variable, but here it is getting used on a para name. even though line 2-4 are getting executed sometimes, looking at the below code it feels line 2-4 will never get executed.

Code:

PARA1    B     PARA2           
         MVI   PARA1+1,X'F0'   
         MVC   VAR1+64(25),MSG01
         BAL   R14,CHECKAGE     
PARA2    ZAP   DEBIT,=P'0'     
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: Sat Aug 27, 2022 12:01 am
Reply with quote

As posted, lines 2 through 4 will never be executed.

HOWEVER, that MVI instruction is changing a byte in the code stream which means what you are seeing is not necessarily what is being executed. Dynamically changing instructions while a program is executing can be done (COBOL, for example, used to have the ALTER GO TO construct to do this) -- but it is ALWAYS dangerous and a very bad practice to do. Debugging such a program can be pretty close to impossible without lots of dumps and careful inspection of memory to see what the code changes have done.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2011
Location: USA

PostPosted: Sat Aug 27, 2022 1:17 am
Reply with quote

Yes, I agree: any self-modifying program is a dangerous and bad practice of coding.

In my opinion, any developer who has ever created a self-modifying code, deserves nothing else but death penalty.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2011
Location: USA

PostPosted: Sat Aug 27, 2022 1:44 am
Reply with quote

anonguy456 wrote:
i am not able to understand what exactly line 2 is trying to do in the below attached code. normally MVI instruction is used on a variable, but here it is getting used on a para name. even though line 2-4 are getting executed sometimes, looking at the below code it feels line 2-4 will never get executed.

Code:

PARA1    B     PARA2           
         MVI   PARA1+1,X'F0'   
         MVC   VAR1+64(25),MSG01
         BAL   R14,CHECKAGE     
PARA2    ZAP   DEBIT,=P'0'     

Most likely, the whole code also includes another instruction like
Code:
         MVI   PARA1+1,X’00’


The original instruction
PARA1 B PARA2
is assembled into the code
X’47F0bddd’
Where bddd is base and displacement of PARA2 label.
After MVI PARA1+1,X’00’
the instruction code is changed to
X’4700bddd’
which in turn works as if it was the Assembler instruction
PARA1 NOP PARA2

So next time the point PARA1 is somehow reached, no branch is done, but the instructions below PARA1 are executed normally. The first of those MVI reverts the updated PARA1 instruction back to
PARA1 B PARA2
and this group of instruction should not execute again unless any MVI …,X’00’ changed the B instruction to NOP.

Please, never try to repeat this exercise again!
Back to top
View user's profile Send private message
anonguy456

New User


Joined: 29 Jun 2021
Posts: 16
Location: India

PostPosted: Sat Aug 27, 2022 8:45 pm
Reply with quote

Thank You Sergeyken.
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 Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
No new posts JCL EXEC PARM data in C Java & MQSeries 2
This topic is locked: you cannot edit posts or make replies. Automation need help in sorting the data DFSORT/ICETOOL 38
Search our Forums:

Back to Top