View previous topic :: View next topic
|
Author |
Message |
suryamtechcse Warnings : 1 New User
Joined: 28 Apr 2006 Posts: 9 Location: Chennai
|
|
|
|
Hi,
I am in need to write an assembler code:
I want to give valid values for a field called ACTATTR.
The valid values should be only A-Z or 0-9.
Code: |
ACTATRTN ------------Main Routine
CLI ACTATTR,C'A'
BL Error-routine
CLI ACTATTR,C'Z'
BNH Exit-routine
BNE ACTAt09
ACTAT09 DS 0H
CLI ACTATTR,C'0'
BL Error-routine
CLI ACTATTR,C'9'
BNH Exit-routine
BNE ACTAt09 |
Could you please provide me an Assembler code for this?
Thanks |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Probably the fastest way would be to use the TRT instruction. Googling assembler trt instruction returns 175,000 hits with plenty of examples on how to use it. |
|
Back to top |
|
|
suryamtechcse Warnings : 1 New User
Joined: 28 Apr 2006 Posts: 9 Location: Chennai
|
|
|
|
Hi Robert,
I am a beginner in Assembler. Could you please provide me exact code?
Thanks |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
This is a help forum, not a DO-YOUR-JOB-FOR-YOU forum. Most of the people who monitor this forum are paid for their professional work product (such as assembler code). Unless you're willing to pay the appropriate amount for professional assistance (rates of USD 1000 per day are fairly typical), please do not ask for code. If you code it up on your own and have trouble, there's plenty of people willing to help you fix it. But unless you show some initiative by coding on your own, you're probably not going to see much support here.
You are expected to be able to research things, read manuals, and figure out things on your own. |
|
Back to top |
|
|
Ronald Burr
Active User
Joined: 22 Oct 2009 Posts: 293 Location: U.S.A.
|
|
|
|
A warning is in order here - MANY have erred in thinking that all values between 'A' and 'Z' ( inclusive ) are alphabetic. In fact, they are NOT. In EBCDIC, the letter 'A' is hex 'C1' (x'C1') and the letter 'Z' is hex 'E9' (x'E9'). But between x'C1' and x'E9' there are values ( i.e. x'CA', x'CB', x'CC', x'CD', x'CE', x'CF', x'D0', x'DA', x'DB', x'DC', x'DE', x'DF', x'E0', and x'E1' ) which are NOT alphabetic. Do NOT neglect to account for these if you test individual bytes to determine if they are "alphabetic". |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Yes, you must heed this warning and this is why a TRT table is your best choice for validating this data.
TRT's are issued (under the covers) by COBOL on a regular basis, such as -
IF field IS NUMERIC
IF field IS ALPHABETIC-UPPER AND field IS NOT = SPACE
The above tests will check field for 0-9 and A-Z characters.
To generate the Assembler expansion of a COBOL program which issue these tests, compile the program using the compile options LIST,NOOFFSET (normal default is NOLIST, OFFSET).
Bill |
|
Back to top |
|
|
Ronald Burr
Active User
Joined: 22 Oct 2009 Posts: 293 Location: U.S.A.
|
|
|
|
One additional caution is now indicated.
It is never a good idea to test a ONE-BYTE field to see if it is NUMERIC or ALPHABETIC.
Why? Well, because if the value is x'C1' it will qualify as BOTH. That is, the value x'C1' is both a valid (signed) number ( value +1 ) AND a valid alphabetic character ( letter 'A' ).
To test a 1-byte field, either test the actual hex representation in accordance with your requirements, or move it to the last byte of a larger field that has been pre-filled with valid values (according to your requirements), and then test that larger field. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Thats true Ronald, but i guess the TS is talking about characters, not the numeric values of 0-9, e.g. x'F0' - x'F9'.
But nevertheless TRT would do the job. |
|
Back to top |
|
|
|