Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Assembler to Cobol conversion

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
alokagarwaljgd

New User


Joined: 02 Jun 2006
Posts: 28

PostPosted: Wed Nov 29, 2006 1:06 pm    Post subject: Assembler to Cobol conversion
Reply with quote

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
View user's profile Send private message

UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 743
Location: Germany

PostPosted: Wed Nov 29, 2006 4:40 pm    Post subject:
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Wed Nov 29, 2006 5:43 pm    Post subject:
Reply with quote

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
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 743
Location: Germany

PostPosted: Wed Nov 29, 2006 6:22 pm    Post subject:
Reply with quote

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
View user's profile Send private message
alokagarwaljgd

New User


Joined: 02 Jun 2006
Posts: 28

PostPosted: Thu Nov 30, 2006 10:15 am    Post subject: Re: Assembler to Cobol conversion
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Thu Nov 30, 2006 5:34 pm    Post subject:
Reply with quote

An example of what?
Back to top
View user's profile Send private message
alokagarwaljgd

New User


Joined: 02 Jun 2006
Posts: 28

PostPosted: Thu Nov 30, 2006 6:06 pm    Post subject: Re: Assembler to Cobol conversion
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Thu Nov 30, 2006 7:21 pm    Post subject:
Reply with quote

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
View user's profile Send private message
alokagarwaljgd

New User


Joined: 02 Jun 2006
Posts: 28

PostPosted: Fri Dec 01, 2006 10:49 am    Post subject: Re: Assembler to Cobol conversion
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Fri Dec 01, 2006 3:04 pm    Post subject: Re: Assembler to Cobol conversion
Reply with quote

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
View user's profile Send private message
alokagarwaljgd

New User


Joined: 02 Jun 2006
Posts: 28

PostPosted: Tue Dec 19, 2006 8:10 pm    Post subject: Re: Assembler to Cobol conversion
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Tue Dec 19, 2006 8:40 pm    Post subject:
Reply with quote

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
View user's profile Send private message
alokagarwaljgd

New User


Joined: 02 Jun 2006
Posts: 28

PostPosted: Wed Dec 20, 2006 10:02 am    Post subject: Re: Assembler to Cobol conversion
Reply with quote

William,

Can you please explain me this with an example?
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 743
Location: Germany

PostPosted: Wed Dec 20, 2006 8:50 pm    Post subject:
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Fri Dec 22, 2006 11:15 pm    Post subject:
Reply with quote

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.... icon_lol.gif

Have fun,

Bill
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Dec 23, 2006 2:09 am    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Full Time COBOL Software Development ... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:24 am
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us