Article View: comp.lang.asm370
Article #230STOSM/STNSM
From: Valdis Kletnieks
Date: Fri, 10 Nov 1989 17:48
Date: Fri, 10 Nov 1989 17:48
49 lines
2455 bytes
2455 bytes
OK.. Here's the problem. You often get stuck writing a subroutine
that cannot tolerate any interrupts, but you don't know for sure what
the system mask is when you get called.
Solution:
... leadin code here
MASKOFF STNSM MASKON+1,X'00'
(protected code here)
MASKON STOSM MASKOFF+1,X'FF'
The STNSM will stick the current mask into the immediate field of the STOSM,
and then set the mask to zeros. Then when you hit the STOSM, the 'FF' has
been replaced by the actual mask you were running on, and ORing in that
results in the original mask again.
Note that this code is *NOT* suitable for AP or MP configurations.
Anybody got a version that works in a multiprocessor environment?
Now, are you using TR or TRT to find the last non-blank? And what's this
about BXLE? :-)
CS is pretty simple really - there's a good description on page A-40
of the S/370 PrincOp (GA22-7000-10). All it does is fetch a value,
compare it, and if it's the same update. It's used for serializing
code. Example (cribbing from A-40.. :) - you have a lock word, that
if it's a 0 you can proceed, but if it's a 1 you have to wait. The
person who gets the lock sets it to 1 when he enters, and to 0 when he leaves.
SR R1,R1 get a zero.
LA R2,1 get a one.
LOOP CS R1,R2,LOCKWORD do it
BC 4,LOOP if somebody else got it, spin.
... locked code here
ST R1,LOCKWORD clear the flag
What the CS will do is:
Fetch LOCKWORD
Compare to R1
If EQUAL, STORE R2 at LONGWORD
else set condition code.
So if you come in and it's zero, you fall through and set to 1 all in one
shot, while if it's a 1 you just spin...
Of course, THIS case could have been done with TS. See the example in
the PrincOp on how to do multiple bits and other extensions of the idea.
Valdis
Technical Details
Message-ID:
<8911112126.AA11923@brazos.rice.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!VTVM1.CC.VT.EDU!VALDISReferences:
<ASPRMH%UOFT01.BITNET@PSUVM.PSU.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!VTVM1.CC.VT.EDU!VALDIS From: VALDIS@VTVM1.CC.VT.EDU (Valdis Kletnieks) Newsgroups: comp.lang.asm370 Subject: STOSM/STNSM Message-ID: <8911112126.AA11923@brazos.rice.edu> Date: 10 Nov 89 17:48:24 GMT References: <ASPRMH%UOFT01.BITNET@PSUVM.PSU.EDU> Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: IBM 370 Assembly Programming Discussion List <ASM370%UCF1VM.BITNET@ricevm1.rice.edu> Distribution: inet Organization: The Internet Lines: 49