rewrite some code



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

rewrite some code

Postby bobguo » Sun Jun 24, 2012 6:59 am

this is one macro written in 1990:

3775      ADDRLIST SLOT#==Y(DWA_SLOT_FOR_DASC),SLOT_A=A_SLOT_FOR_DASC         
3776+DFHEISTG DSECT                                                           
3777+         ORG                                                             
3778+R14_CALL_ADDRLIST  DS   A                                                 
3779+REG_CALL_ADDRLIST  DS 18F                                                 
3780+ADDRLIST_PARMS     DS  0A                                                 
3781+ADDRLIST_A_SLOT#   DS   A                                                 
3782+ADDRLIST_A_SLOT_A  DS   A                                                 
3783+*                                                                         
3784+ABCD     CSECT                                                           
3787+         BRC   15,AROUND_CALL_ADDRLIST  (B)                               
3788+*                                                                         
3789+CALL_ADDRLIST DS 0H                                                       
3790+         ST    R14,R14_CALL_ADDRLIST                                     
3791+*                                                                         
3792+         LA    R1,ADDRLIST_PARMS               -> PARMS               
3793+         CNOP  0,4            !ALIGN ON WORD BOUNDARY FOR V()             
3794+         BRAS  R15,*+8                                                   
3795+          DC   V(A@DWASLT)                                               
3796+         L     R15,0(,R15)                     
3797+         ST    R13,REG_CALL_ADDRLIST+4        !!! PRESERVE R13           
3798+         LA    R13,REG_CALL_ADDRLIST           -> REG SAVE AREA           
3799+         BALR  R14,R15                         -> CALL ADDRLIST           
3800+         L     R13,4(0,R13)                   !!! RESTORE  R13           
3801+*                                                                         
3802+         L     R14,R14_CALL_ADDRLIST                                     
3803+         BR    R14                                                       
3804+AROUND_CALL_ADDRLIST DS 0H                                               
3805+*                                                                         
3806+         LA    R1,=Y(DWA_SLOT_FOR_DASC)                                   
3807+         ST    R1,ADDRLIST_A_SLOT#                                       
3808+         LA    R1,A_SLOT_FOR_DASC                                         
3809+         ST    R1,ADDRLIST_A_SLOT_A                                       
3811+         BRAS  R14,CALL_ADDRLIST  (A@DWASLT)   



i puzzled why not be written like the code below?
if the code above is better, can someone describe it in detail? thanks




3775      ADDRLIST SLOT#==Y(DWA_SLOT_FOR_DASC),SLOT_A=A_SLOT_FOR_DASC         
3776+DFHEISTG DSECT                                                           
3777+         ORG                                                     
3779+REG_CALL_ADDRLIST  DS 18F                                                 
3780+ADDRLIST_PARMS     DS  0A                                                 
3781+ADDRLIST_A_SLOT#   DS   A                                                 
3782+ADDRLIST_A_SLOT_A  DS   A                                                 
3783+*                                                                         
3784+ABCD     CSECT                                                   
3806+         LA    R1,=Y(DWA_SLOT_FOR_DASC)                                   
3807+         ST    R1,ADDRLIST_A_SLOT#                                       
3808+         LA    R1,A_SLOT_FOR_DASC                                         
3809+         ST    R1,ADDRLIST_A_SLOT_A                                 
3791+*                                                                         
3792+         LA    R1,ADDRLIST_PARMS               -> PARMS               
3793+         CNOP  0,4            !ALIGN ON WORD BOUNDARY FOR V()             
3794+         BRAS  R15,*+8                                                   
3795+          DC   V(A@DWASLT)                                               
3796+         L     R15,0(,R15)                     
3797+         ST    R13,REG_CALL_ADDRLIST+4        !!! PRESERVE R13           
3798+         LA    R13,REG_CALL_ADDRLIST           -> REG SAVE AREA           
3799+         BALR  R14,R15                         -> CALL ADDRLIST           
3800+         L     R13,4(0,R13)                   !!! RESTORE  R13   
bobguo
 
Posts: 76
Joined: Thu Apr 26, 2012 11:18 am
Location: shanghai
Has thanked: 22 times
Been thanked: 0 time

Re: rewrite some code

Postby dick scherrer » Sun Jun 24, 2012 9:01 am

Hello,

i puzzled why not be written like the code below?
if the code above is better, can someone describe it in detail? thanks
What has caused this question to be asked now? What is your meaning for "better"? Are you looking for less lines of code for some reason? There are so few instructions that there would be no performance consideration.

What business resaon is there to revisit this code? If it has run properly for 20 years, suggest it continue to be used until replaced or the system is retired.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: rewrite some code

Postby bobguo » Sun Jun 24, 2012 1:58 pm

thanks for your reply. there is no need to replace it. i just want to learn some from it.
maybe i can follow that coding style.
bobguo
 
Posts: 76
Joined: Thu Apr 26, 2012 11:18 am
Location: shanghai
Has thanked: 22 times
Been thanked: 0 time

Re: rewrite some code

Postby dick scherrer » Sun Jun 24, 2012 4:00 pm

Hello,

You still haven't posted what you mean by "better".

What is it that you want to learn?

maybe i can follow that coding style.
Which style and why?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: rewrite some code

Postby bobguo » Mon Jun 25, 2012 8:31 am

'that coding style', what i mean, just like this:

         B     ABC           
*                           
EDF      DS 0H               
         ST    R14,R14SAVE   
         ...     
         L     R14,R14SAVE
         BR    R14
*      
ABC      DS 0H               
         ...                 
         BASR  R14,EDF


For it works more than 20 years, maybe it's better than normal Waterfall-flow coding style(this is just my thought). Thanks
bobguo
 
Posts: 76
Joined: Thu Apr 26, 2012 11:18 am
Location: shanghai
Has thanked: 22 times
Been thanked: 0 time

Re: rewrite some code

Postby dick scherrer » Mon Jun 25, 2012 9:05 am

Hello,

maybe it's better than normal Waterfall-flow coding style
Who invented this term? I do not recall being on some remote desert island and i have never heard this before :?

Did this come from Any credible publication? Why might this be called "normal"?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: rewrite some code

Postby Akatsukami » Mon Jun 25, 2012 8:01 pm

dick scherrer wrote:Hello,

maybe it's better than normal Waterfall-flow coding style
Who invented this term? I do not recall being on some remote desert island and i have never heard this before :?

Did this come from Any credible publication? Why might this be called "normal"?

It's a misuse of "waterfall" as describing software development where the requirements are agreed upon beforehand and software engineers are fired when they ignore the design and turn out any piece of garbage that they feel like producing.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: rewrite some code

Postby steve-myers » Mon Jun 25, 2012 9:13 pm

bobguo wrote:'that coding style', what i mean, just like this:

         B     ABC           
*                           
EDF      DS 0H               
         ST    R14,R14SAVE   
         ...     
         L     R14,R14SAVE
         BR    R14
*      
ABC      DS 0H               
         ...                 
         BASR  R14,EDF


For it works more than 20 years, maybe it's better than normal Waterfall-flow coding style(this is just my thought). Thanks
Doesn't matter. It won't assemble.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: rewrite some code

Postby steve-myers » Mon Jun 25, 2012 10:37 pm

It's crappy program structures like this that give Assembler a bad name. Few people now remember the whole ethos for "structured programming" came from the simple observation that good programmers did not use a whole lot of unnecessary GO TO statement (e.g. bobguo's B statement to branch around what amounts to a subroutine coded inline.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times


Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post