IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

assembler program to count no. of digits in a string


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
parikshit123

Active User


Joined: 01 Jul 2005
Posts: 269
Location: India

PostPosted: Mon Aug 28, 2006 1:04 pm
Reply with quote

Hi folks,

I need an assembler program to count no. of digits in a string.

Can anyone please help me?

I am new to assembler.

Thanks,
Parikshit.
Back to top
View user's profile Send private message
bengtpelle

New User


Joined: 28 Aug 2006
Posts: 24
Location: St. Petersburg, FL

PostPosted: Mon Aug 28, 2006 9:15 pm
Reply with quote

I like to use registers for all processing of this type. Here is an example using 3 registers:

Code:
          SR    2,2        Set counter to zero
          LA    3,String   Start of string
          LA    4,10       Length of string
LOOP      TM    0(3),X'F0' Test if it is a digit
          BNO  *+8         If not a digit, bypass next instruction
          LA    2,1(2)     Add one to counter
          BCT   4,LOOP     Loop the length of the string

Register 2 now contains number of digits.
icon_biggrin.gif
Back to top
View user's profile Send private message
parikshit123

Active User


Joined: 01 Jul 2005
Posts: 269
Location: India

PostPosted: Tue Aug 29, 2006 12:44 am
Reply with quote

Hi,

Thanks a lot.

It was really good solution.

well, I welcome other solutios as well.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top