View previous topic :: View next topic |
Author |
Message |
alokagarwal Beginner
Joined: 08 Nov 2006 Posts: 3 Topics: 2
|
Posted: Tue Dec 19, 2006 9:56 am Post subject: NOP directive in HLASM |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Tue Dec 19, 2006 10:23 am Post subject: |
|
|
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 |
|
|
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Tue Dec 19, 2006 12:27 pm Post subject: |
|
|
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 |
|
|
Bill Dennis Advanced
Joined: 03 Dec 2002 Posts: 579 Topics: 1 Location: Iowa, USA
|
Posted: Tue Dec 19, 2006 4:11 pm Post subject: |
|
|
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 |
|
|
alokagarwal Beginner
Joined: 08 Nov 2006 Posts: 3 Topics: 2
|
Posted: Tue Dec 19, 2006 11:43 pm Post subject: |
|
|
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 |
|
|
Mervyn Moderator
Joined: 02 Dec 2002 Posts: 415 Topics: 6 Location: Hove, England
|
Posted: Wed Dec 20, 2006 6:21 am Post subject: |
|
|
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 |
|
|
DaveyC Moderator
Joined: 02 Dec 2002 Posts: 151 Topics: 3 Location: Perth, Western Australia
|
Posted: Thu Dec 21, 2006 4:52 am Post subject: |
|
|
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 |
|
|
|
|