Page 1 of 1

rewrite some code

PostPosted: Sun Jun 24, 2012 6:59 am
by bobguo
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   

Re: rewrite some code

PostPosted: Sun Jun 24, 2012 9:01 am
by dick scherrer
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.

Re: rewrite some code

PostPosted: Sun Jun 24, 2012 1:58 pm
by bobguo
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.

Re: rewrite some code

PostPosted: Sun Jun 24, 2012 4:00 pm
by dick scherrer
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?

Re: rewrite some code

PostPosted: Mon Jun 25, 2012 8:31 am
by bobguo
'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

Re: rewrite some code

PostPosted: Mon Jun 25, 2012 9:05 am
by dick scherrer
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"?

Re: rewrite some code

PostPosted: Mon Jun 25, 2012 8:01 pm
by Akatsukami
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.

Re: rewrite some code

PostPosted: Mon Jun 25, 2012 9:13 pm
by steve-myers
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.

Re: rewrite some code

PostPosted: Mon Jun 25, 2012 10:37 pm
by steve-myers
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.