View previous topic :: View next topic
|
Author |
Message |
parikshit123
Active User
Joined: 01 Jul 2005 Posts: 269 Location: India
|
|
|
|
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 |
|
|
bengtpelle
New User
Joined: 28 Aug 2006 Posts: 24 Location: St. Petersburg, FL
|
|
|
|
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.
|
|
Back to top |
|
|
parikshit123
Active User
Joined: 01 Jul 2005 Posts: 269 Location: India
|
|
|
|
Hi,
Thanks a lot.
It was really good solution.
well, I welcome other solutios as well. |
|
Back to top |
|
|
|