MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

NOP directive in HLASM

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
alokagarwal
Beginner


Joined: 08 Nov 2006
Posts: 3
Topics: 2

PostPosted: Tue Dec 19, 2006 9:56 am    Post subject: NOP directive in HLASM Reply with quote

Can any one tell me what does NOP directive does with an example. I read that it actually does not do anything then what is its significance?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Tue Dec 19, 2006 10:23 am    Post subject: Reply with quote

alokagarwal,

NOP is No operation Command. AFAIK it does nothing but waste processor time. There are times when you want to delay the program execuetion. That is where you use NOP command.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Tue Dec 19, 2006 12:27 pm    Post subject: Reply with quote

Actually, the no operation does nothing. The processor interprets it, but does not send it to the execution unit (e-unit). Unless you string enough of them together to completely empty the pipeline at the i-unit stage, there will no performance penalty at all. It is normally used just to align the next instruction on a half word, word, or doubleword boundary.
Back to top
View user's profile Send private message Visit poster's website
Bill Dennis
Advanced


Joined: 03 Dec 2002
Posts: 579
Topics: 1
Location: Iowa, USA

PostPosted: Tue Dec 19, 2006 4:11 pm    Post subject: Reply with quote

A practice considered reckless today, the NOP would sometimes be modified to a BR instruction in an action called self-modifying code. You could control program flow by modifying the code itself. Very difficult to debug problems! Consider this:
Code:
TEST    NOP OPENED
        OPEN (FILEA,(INPUT))     one-time only code
        MVI   TEST+1,X'F0'      change 4700 to 47F0
OPENED  MVC .....      (the process continues)

_________________
Regards,
Bill Dennis

Disclaimer: My comments on this foorum are my own and do not represent the opinions or suggestions of any other person or business entity.
Back to top
View user's profile Send private message
alokagarwal
Beginner


Joined: 08 Nov 2006
Posts: 3
Topics: 2

PostPosted: Tue Dec 19, 2006 11:43 pm    Post subject: Reply with quote

Hi Dennis,

In your example, when will the control come to the label OPENED, if it is coming to it, when the contol hits the label TEST second time, then why?
Back to top
View user's profile Send private message
Mervyn
Moderator


Joined: 02 Dec 2002
Posts: 415
Topics: 6
Location: Hove, England

PostPosted: Wed Dec 20, 2006 6:21 am    Post subject: Reply with quote

alokagarwal, the NOP command takes the form of a Branch instruction, with a condition operand of zero, indicating that the branch will never take place. The MVI command changes the condition operand to 15, indicating an unconditional branch.

In Bill's example, this prevents the file being opened twice, which would cause an error.
_________________
The day you stop learning the dinosaur becomes extinct
Back to top
View user's profile Send private message
DaveyC
Moderator


Joined: 02 Dec 2002
Posts: 151
Topics: 3
Location: Perth, Western Australia

PostPosted: Thu Dec 21, 2006 4:52 am    Post subject: Reply with quote

Bill Dennis wrote:
A practice considered reckless today


You would be surprised how much of that "reckless" code is still being executed today! Of course, it's not re-entrant.
_________________
Dave Crayford
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group