View previous topic :: View next topic
|
Author |
Message |
alokagarwaljgd
New User
Joined: 02 Jun 2006 Posts: 28
|
|
|
|
UmeySan,
Thanks for your reply.
But can you please let me know how to code the same LA instruction and USING directive in COBOL with examples. Also, please let me know what is the meaning of DB_UMSATZ variable in your example.
Alok
------------------------------------------------------------------------------
Sorry for my long outstanding answer. I had been upsend for a time.
Anyway, with L you load the content into a register and with LA you load the adress of a field into a register.
LA R4,Field Field is in WS at adress 4711 so reg-4 points to 4711
L R5,0(R4) Loads content sdtarting at 4711 into reg-5
L R6,=F'07' Loads 7 into reg-6
CR R5,R6 compares now content from WS-4711 (loaded before
in reg-5 with content loaded in reg-6
CLI 0(R4),X'FF' Checks WS-position loaded in reg-4 if there id FF-value
With USING you assign a register to a data-structure defined in a dummy-section.
USING UM0UMSATZ,R14
LA R14,DB_UMSATZ
Now all the fields belonging to DB_UMSATZ are addressed througth R14
Regards, UmeySan |
|
Back to top |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
Hi !
In my example, DB_UMSATZ is nothing more than a data-structure.
Really that point you mentioned was the hardest, as i worked in a migration (Ass to Cob) project long time ago. That's, because you don't have Registers in Cobol as like in Assembler.
You habe to dermine if you could do it with a audenairy move or if you can use pointers.
With a normal L you only load content. So you could use a move instruction. But Remember: the LA loads a adress !!!
If you don't have a third-party-product for code-conversion, you have to
do everything on your own. Otherwise, the conversation software will help you to get a first cobol structure, that you can optimize and customize, so that it fits the requirements the same way as in assembler. There is allways a lot work to do after the automatic conversation. But without automatic pre-conversation the best way is to analyse the ass-code and
have a look at the functional guideline, what the programm has to do and then code it new in cobol.
Good luck & regards, UmeySan |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
I have no idea what you two are talking about, but as far as this:
Quote: |
But can you please let me know how to code the same LA instruction and USING directive in COBOL with examples. |
goes, pointers and linkage section can do it all. |
|
Back to top |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
Hi William !
We are talking about a migration project which includes the transformation
of Assembler programms into Cobol code.
And as you mentioned, I also invoke the aspect of using pointers to simulate the LA instruction.
Accessorily, i pointed out some general aspects of souch a project.
Regards, UmeySan |
|
Back to top |
|
|
alokagarwaljgd
New User
Joined: 02 Jun 2006 Posts: 28
|
|
|
|
Hi William,
As UmeySan pointed out correct, it is regarding Assembler to Cobol conversion project.
You said that, it can be achieved by using pointers and linkage section.
Can you please let me know about it with an example.
Alok |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
An example of what? |
|
Back to top |
|
|
alokagarwaljgd
New User
Joined: 02 Jun 2006 Posts: 28
|
|
|
|
An example of how to convert the LA instruction and USING directive of Assembler in Cobol. i.e. the equivalent corresponding instruction in Cobol. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
I used this method to pick my way through some pretty strang undefined data blocks.
Code: |
Working-Storage Section.
77 Data-Anywhere pic x(100) value
'1A1 3Man1 1A1 4Plan1 1A1 5Canal1 6Panama0'.
01 Filler.
05 Register usage Pointer.
05 LA redefines Register pic s9(8) comp.
Linkage Section.
01 Dsect.
05 D-Count pic 9.
05 D-Text pic x occurs 9 times
depending on ALAD-Count.
Procedure Division.
Set Register to address of Data-Anywhere.
Set address of Dsect to Register.
Perform until D-Count = 0
If D-Count = 1
Move D-Count to D-Count
Display '*' D-Text '*'
else
Move D-Count to D-Count
Display ' ' D-Text ' '
end-if
Compute LA = LA + 1 + D-Count
end-perform.
*A*
* *
Man
* *
*A*
* *
Plan
* *
*A*
* *
Canal
* *
Panama
|
|
|
Back to top |
|
|
alokagarwaljgd
New User
Joined: 02 Jun 2006 Posts: 28
|
|
|
|
Hi William,
Thanks for your reply.
I could understand your code to certain extent but not completely. Once we have set the register to address of Data-Anywhere by using
Set Register to address of Data-Anywhere,
then again in the next statement,
Set address of Dsect to Register
we are setting the register to contain the address of the Dsect. When we are doing this won't it overwrite the previous content of the register which contained the address of Data-Anywhere, if yes then what is the use of loading the register first with the address of Data-Anywhere.
Alok |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
alokagarwaljgd wrote: |
we are setting the register to contain the address of the Dsect. When we are doing this won't it overwrite the previous content of the register which contained the address of Data-Anywhere, if yes then what is the use of loading the register first with the address of Data-Anywhere. |
No, we are setting addressability TO the Dsect, that is the "using". As I adjust up (and I could have gone down too) the value in the pointer, the storage addresses under the linkage item move up (and down) too. |
|
Back to top |
|
|
alokagarwaljgd
New User
Joined: 02 Jun 2006 Posts: 28
|
|
|
|
Can any one please let me know with an example, what is the use of NOP instruction in HLASM ? I read that it does not do any operation, then what is the use of it ? |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Back in the olden days, NOPs were routinely OIed to turn them into actual branches amd NIed to return them to NOPs. |
|
Back to top |
|
|
alokagarwaljgd
New User
Joined: 02 Jun 2006 Posts: 28
|
|
|
|
William,
Can you please explain me this with an example? |
|
Back to top |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
Hi alokagarwaljgd !
Litte example for your nop. The routine named B05 is for reading input-data. Only on the first time it also executes the open of the dataset. Then
all nexed times it is only fetching the nexed record.
In MainStructure of programm:
BALR B05 ...for reading input
BALR F05 ...for processing input data
B05 NOP B05A ...first time = NoOperation
Open Input
OI B05,X'F0' ...Set NOP to BRANCH
B05A GET Input,In_Area
Accordingly you could set a BRANCH to NOP condition by using NI command.
But better don't use this old programming way. Take care of clearly defind structure. There is allway an other person who has to customize your programm if you leave the company.
Regards, UmeySan
Regards, UmeySan |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Hi alokagarwaljgd,
Looking back, for this project I think your best method would be to stand back from the code a little.
In other words, look at what the program is doing, not how it's doing but what. Loosely flowchart it in very general term and start getting more and more detailed until you reach a point where you can relate a stretch of assembler code to a single function, like here it sets up a print line and prints it or here is produces a page heading and resets its line counter.
At that point, just do it in COBOL regardless of how it was done in assembler.
At least you seam to have the assembler source listing, try to do this with only a loadmod....
Have fun,
Bill |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Just to add a bit to what Bill said, if the goal is to convert from assembler to COBOL, you probably do not want a system of "COBOL" code that emulates assembler code. Keep in mind that those who will maintain this code in the future will most likely be COBOL programmers.
From doing this a few times (again, as Bill recommended), I'd also recommend that you look at what the module needs to do and code COBOL for that. The resulting code will both perform better as well as be more maintainable. If your situation is like some of the ones i've supported, lots of the programs will be quite similar. Once you have one of a particular kind working, it will be quite easy to "clone" it for the next requirement savind the time to analyze each assembler program line by line. |
|
Back to top |
|
|
|