🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.asm370
Article #235

More pet ALC tricks...

#235
From: Rob Hamilton
Date: Sun, 12 Nov 1989 21:27
49 lines
2524 bytes
I was a little off in my description of the TR/TRT thing; what I do when
I want to find the last nonblank character in a character string is to
use TR to reverse the string, and then use TRT to calculate the offset
from the beginning of the translated string (end of the original string)
of the last character.  Whew!!!  It looks kinda like this

.
...
.
    MVC  STRING(256),BLANKS       blank out string to be xlated
    MVC  STRING(L'INPUT),INPUT    insert string to be checked
    TR   TRTAB(256),STRING        use the string as the translation table
    TRT  TRTAB(256),NONBLANK      find the first nonblank
    LA   R2,TRTAB+256             calculate where that is...
    SR   R2,R1                    ...and that address is in R2
.
...
.
*  TRTAB is collating sequence in reverse order
TRTAB    DC   256AL1(TRTAB+255-*)
*  NONBLANK is a TRT table for finding anything but a blank
NONBLANK DC   C' ',255AL1(*-NONBLANK)
         ORG  NONBLANK+C' '
         DC   X'00'
         ORG
.
...
.

This has worked for me before; I picked this up 8 years or so ago and
tried it then and didn't have any trouble.  Note that you have to
reinitialize the TRTAB table each time through, but if it's in dynamic
storage, you have to initialize it anyway. . .Let me know if this doesn't
work because I have it in a program somewhere and I'm in serious trouble
if it doesn't.

About that BXLE thing, I just think it's handy for doing just what it says;
Add two registers, compare two registers, and branch if the sum isn't bigger
than the comparand register.  Usually we use this instruction and its
brother-in-law, BXH, for handling simple looping.  Usually.  As pointed
out by this particular discussion, there are no REAL rules about where these
things are to be used....

Thanks, Valdis and Doron, for your info on CS and CDS.  Somehow, I had a
mental block for those guys, and a few others as well.  Also, I agree
that there must be something similar for AP and MP environments.  Any
clues yet???

R;
Technical Details
Message-ID: <8911122345.AA21802@brazos.rice.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!UOFT01.BITNET!ASPRMH

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!UOFT01.BITNET!ASPRMH
From: ASPRMH@UOFT01.BITNET (Rob Hamilton)
Newsgroups: comp.lang.asm370
Subject: More pet ALC tricks...
Message-ID: <8911122345.AA21802@brazos.rice.edu>
Date: 12 Nov 89 21:27:08 GMT
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