character compare

Ask/Clarify the questions on ASSEMBLER language.

Moderator: Moderator Group

Post Reply
jimwallis2001@yahoo.com
Member
Posts: 1
Joined: Sun Jan 16, 2011 10:41 pm

character compare

Post by jimwallis2001@yahoo.com » Sun Jan 16, 2011 11:05 pm

Would like some direction on character compare using the address in registers. Ex:
Data:
  • AAABBBTOMCCCCDICKDDDDHARRYEEEE
    LOAD REG 2 with beginning of above string.
    In the LTORG
    KTOM DC 'TOM'
    KDICK DC 'DICK'
    KHARRY DC 'HARRY'
    LOAD REG 3 with KTOM:
    LA R3,KTOM
I realize that I will need to bump through the string one character at a time but how do I perform the compare?
Thank you in advance,
Jim

ChinoBernardo
Member
Posts: 1
Joined: Thu Mar 01, 2012 9:03 pm

Post by ChinoBernardo » Thu Mar 01, 2012 9:19 pm

One way of doing it could be:

EXAMPLE CSECT
********************
* OUTPUT should contain:
* TOM DICK HARRY
********************
USING *,R15

LA R2,DATA
LOOP1 CLC 0(3,R2),KTOM
BE DONE1
LA R2,1(R2)
CLI 0(R2),C'$'
BE SKIP1
B LOOP1
DONE1 EQU *
MVC OUTPUT(3),0(R2)

SKIP1 LA R2,DATA
LOOP2 CLC 0(4,R2),KDICK
BE DONE2
LA R2,1(R2)
CLI 0(R2),C'$'
BE SKIP2
B LOOP2
DONE2 EQU *
MVC OUTPUT+10(4),0(R2)

SKIP2 LA R2,DATA
LOOP3 CLC 0(5,R2),KHARRY
BE DONE3
LA R2,1(R2)
CLI 0(R2),C'$'
BE SKIP3
B LOOP3
DONE3 EQU *
MVC OUTPUT+20(5),0(R2)
SKIP3 EQU *

LA R2,OUTPUT
SVC 209 WRITE CONSOLE MESSAGE
BR R14 EXIT

DATA DC C'AAABBBTOMCCCCDICKDDDDHARRYEEEE'
DC C'$' DELIMITER FOR COMPARE LOOP
KTOM DC CL5'TOM'
KDICK DC CL5'DICK'
KHARRY DC CL5'HARRY'
OUTPUT DC CL80' '
DC C'$' DELIMITER FOR SVC 209
R2 EQU 2
R3 EQU 3
R14 EQU 14
R15 EQU 15
END

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others