Send a String to another variable



High Level Assembler(HLASM) for MVS & VM & VSE

Send a String to another variable

Postby utpalpal07 » Tue Jul 17, 2012 6:55 pm

Hi Guys,

I have a string:
2768 IS A EVEN NO

I want to send 2768 in another variable using assembler prog.

how to do?

please help

regards
utpal
utpalpal07
 
Posts: 43
Joined: Wed Feb 08, 2012 12:02 pm
Has thanked: 1 time
Been thanked: 0 time

Re: string

Postby BillyBoyo » Tue Jul 17, 2012 7:40 pm

You mean you have some rule for obtaining a "sub-string" from a "string"?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: string

Postby utpalpal07 » Tue Jul 17, 2012 7:42 pm

Hi Billy
I want to unstring the string.
utpalpal07
 
Posts: 43
Joined: Wed Feb 08, 2012 12:02 pm
Has thanked: 1 time
Been thanked: 0 time

Re: string

Postby BillyBoyo » Tue Jul 17, 2012 8:34 pm

I'm sure the "traditional" way still works. Use a byte-location field to wander along the contents of your "string" looking for a space. Once located, the length of the sub-string is known. Repeat until end-of-string.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: string

Postby utpalpal07 » Tue Jul 17, 2012 11:05 pm

hi,
can you give an example how to compare upto space and save first part in a variable ?

regards
utpal
utpalpal07
 
Posts: 43
Joined: Wed Feb 08, 2012 12:02 pm
Has thanked: 1 time
Been thanked: 0 time

Re: string

Postby steve-myers » Tue Jul 17, 2012 11:49 pm

Well, I'm certainly not going to write any code for you considering how badly the "requirement" is documented, but you can use TRT to scan a string for a blank using this table -

FINDBLNK DC 0XL256'0',(C' ')X'00',X'04',(256-(*-FINDBLNK))X'00'

TRT will leave the address of the first blank in register 1. You have to prepare for the case where there are no blanks in the string, which I will leave as an exercise for you. With the address of the first blank in register 1, it is a simple matter to compute the length of the substring and copy the substring to another storage area using MVCL or by using the EX instruction to execute an MVC instruction.

FWIW, in some of my work in the last few months I have encountered this exact problem and used this technique to extract the substring.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: string

Postby utpalpal07 » Wed Jul 18, 2012 12:06 am

Hi Guys,

Thanks for reply


       WORD='4567 IS A NUMBER'
       LA R14,WORD
       LA R15,L'WORD
LOOP   CLI 0(R14),C' '
      BE NEXT

*WHAT INSTRUCTION SHOULD I USE HERE
*SO THAT I CAN INSERT EACH DIGIT 1 BY 1

NEXT   LA R14,1(,R14)
      BCT R15,LOOP



Please help me:
which instruction should i use in the commented part so that i can insert digits 1 by 1.
It will solve my problem

Thanks & regards
utpal
utpalpal07
 
Posts: 43
Joined: Wed Feb 08, 2012 12:02 pm
Has thanked: 1 time
Been thanked: 0 time

Re: string

Postby steve-myers » Wed Jul 18, 2012 12:23 am

WORD='4567 IS A NUMBER' is not exactly Assembler!

To answer your question, check out MVC.

More often than not, I use reg 0 for the BCT counter register rather than reg 15 as you used. Reg 0 is not useful as an address register, so this is a good use for a register that is not used all that often.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: string

Postby utpalpal07 » Wed Jul 18, 2012 12:26 am

Hello Steve,

I can use MVC once only. How to use it as a array/stack. So that until i get space MVC can insert a value into variable.

Thanks
utpalpal07
 
Posts: 43
Joined: Wed Feb 08, 2012 12:02 pm
Has thanked: 1 time
Been thanked: 0 time

Re: string

Postby steve-myers » Wed Jul 18, 2012 5:58 am

You have reg 14 that points to a byte that you have just tested. You will need a second register that points to a byte in the data area that will receive the byte. So you do

MVC 0(1,output-register),0(14)

after you have tested for the end of the substring.

Between NEXT and the BCT you will update the output register just like you update reg 14 in the NEXT instruction.

As I said earlier, and I think others have implied, more experienced Assembler programmers copy the substring in a single move after the end of the substring has been located. What you propose is certainly acceptable code, though slower than doing the block move.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Next

Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post