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 

help in assembler...Compare string.

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


Joined: 11 Dec 2004
Posts: 103
Topics: 39

PostPosted: Tue Mar 08, 2005 12:13 pm    Post subject: help in assembler...Compare string. Reply with quote

Hi Floks,

I have this requirement and have to implement it in assembler.

I get this user id of 8 bytes long and it is defined as :-

THISUSER DS CL8. It will be populated at RUN TIME.

I cannot change the way it gets this.All i know is during Execution the USER id is there in this variable THISUSER.

Now i have to compare the data in THISUSER with

DM01 Through DM99 and DK01 Through DK99.

If any body enter DM010 i.e DM01X, X can be anything and DM00 it should not work and branch to FAIL1. Also if any body enters DM99X, X can be anything it should not work and Branch to FAIL1.

That is it should only work for values DM01 through DM99 ( Both Inclusive ). The values DM01 through DM99 will come in the variable THISUSER as i had mentioned above.

Same requirement for DK01 through DK99. Only diffrenece is here branching on fail condition should be to FAIL2.

Please help.

Thanks in advance ,

Karun
Back to top
View user's profile Send private message Send e-mail
dtf
Beginner


Joined: 10 Dec 2004
Posts: 110
Topics: 8
Location: Colorado USA

PostPosted: Wed Mar 09, 2005 10:06 am    Post subject: Reply with quote

Karun,

I would be happy to help you out here, but I am not sure that I should. It is apparent that this is some kind of course exercise. If I give you the answer what purpose will that have served?

By way of a hint though, I think that this can be accomplished with a very small number of CLC statements. Since the last 4 characters need to be spaces, make sure that you compare for 8 bytes, and include the spaces in your compare.

Hope this helps Smile
DTF
________
GM 60-Degree V6 engine history


Last edited by dtf on Tue Feb 01, 2011 1:49 pm; edited 1 time in total
Back to top
View user's profile Send private message
karunkallore
Beginner


Joined: 11 Dec 2004
Posts: 103
Topics: 39

PostPosted: Wed Mar 09, 2005 10:31 am    Post subject: The code.. Reply with quote

Hi,

Sorry for the misrepresentation of the statmenets. I am just New to assembler and was horning my skills. It is not any exercise of any sort.

I worked withe code and found that this works..
Code:

         CLC   HLQDM(2),THISUSER   
         BE    VALIDUSR             
         CLC   HLQDK(2),THISUSER   
         BNE   UNAUTHO             
*                                   
VALIDUSR EQU   *                   
         LA    R2,THISUSER         
         CLC   VALLOW,2(R2)         
         BE    UNAUTHO             
         CLC   VALLOW,2(R2)         
         BH    UNAUTHO             
         CLC   VALHGH,2(R2)         
         BE    EXCELLNT             
         CLC   VALHGH,2(R2)         
         BH    EXCELLNT             
*                                   

UNAUTHO  EQU   *                                               
*KK1-E                                                         
         WTO   'UNAUTHORIZED USER ACCESS, EXITING!',ROUTCDE=11
         B     EXITSAVE                                       

HLQDM    DC    CL2'DM'           
HLQDK    DC    CL2'DK'           
VALLOW   DC    CL3'00 '           
VALHGH   DC    CL3'99 '           


It worked. Still if i give a DM000 or DM001 it wont work Though it works for DM999.

Thanks for the tips. Hope to be in touch.
Back to top
View user's profile Send private message Send e-mail
nevilh
Beginner


Joined: 11 Aug 2004
Posts: 115
Topics: 0

PostPosted: Wed Mar 09, 2005 10:53 am    Post subject: Reply with quote

Have I understood correctly USERIDS can only be 4 bytes long.......
if so all you need to do is compare byte 5 to blank ie
CLI 4(R2),C' '
BNE ERROR

and change the length of VALLOW VALHGH to 2
Back to top
View user's profile Send private message
semigeezer
Supermod


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

PostPosted: Wed Mar 09, 2005 1:33 pm    Post subject: Reply with quote

I haven't written an assembler program in years, so this little problem sounded fun... here is my attempt which does not require any looping. This technique may be overkill in this case, but it is good for validating invalid characters. the user id is hardcoded within the message buffer because I'm lazy.
Code:
$        CSECT
$        AMODE 24
$        RMODE 24
         BALR  12,0
         USING *,12
         STM   14,12,12(13)
         ST    13,SAVEAREA+4
         LA    13,SAVEAREA
         XR    15,15                set rc to 0
         MVC   WORKAREA,USERID
         CLC   WORKAREA+2(2),=C'00' check invalid low num
         BE    FAILURE
         CLC   WORKAREA+2(2),=C'99' check invalid high num
         BE    FAILURE
         TR    WORKAREA,TRTABLE     translate numbers to '0'
         CLC   WORKAREA,=CL8'DK00    ' check vakid DM prefix
         BE    GOODDK
         CLC   WORKAREA,=CL8'DM00    ' check valid DM prefix
         BE    GOODDM
FAILURE  EQU   *                    fall through for error
         LA    3,WTOBUFF
         WTO   MF=(E,(3)),ROUTCDE=11
         LA    15,12
         B     EXIT
GOODDK   EQU   *
         WTO   'User passed as a DK id',ROUTCDE=11
         B     EXIT
GOODDM   EQU   *
         WTO   'User passed as a DM id',ROUTCDE=11
EXIT     EQU   *
         L     13,SAVEAREA+4
         L     14,12(13)
         LM    0,12,20(13)
         BR    14
         LTORG
WTOBUFF  DC    H'28',H'0'
         dc    CL8'User id '
USERID   DC    CL8'DM09    '
         dc    CL8'failed.'
WORKAREA DS    CL8
SAVEAREA DS    18F
TRTABLE  DC    256AL1(*-TRTABLE)
         ORG   TRTABLE+C'0'
         DC    C'0000000000'
         ORG   TRTABLE+256
         END   $
Back to top
View user's profile Send private message Visit poster's website
karunkallore
Beginner


Joined: 11 Dec 2004
Posts: 103
Topics: 39

PostPosted: Wed Mar 09, 2005 5:48 pm    Post subject: Thanks Reply with quote

Thanks guys for the code and advises !!
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