Posted: Tue Mar 08, 2005 12:13 pm Post subject: help in assembler...Compare string.
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.
Joined: 10 Dec 2004 Posts: 110 Topics: 8 Location: Colorado USA
Posted: Wed Mar 09, 2005 10:06 am Post subject:
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.
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
Posted: Wed Mar 09, 2005 1:33 pm Post subject:
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 $
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