Need help with practice assignment!!



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

Re: Need help with practice assignment!!

Postby steve-myers » Sun Apr 05, 2015 9:29 am

PRINT DSECT ?!! You still have not fixed this!

CUSTOUT DC CL6'       CUSTOMER ID'

The prototype data obviously contains more than 6 characters! The assembler will just process the first 6.

I just picked one example. You'll have to do the remainder.
         MVC TOTLOUT(6),=XL6'40206B2020214B2020'
         ED TOTLOUT(6),$TTOTAL

Lot's of problems.
  • The prototype edit mask obviously has more than 6 characters. You need to define a large enough output area.
  • You need to specify one digit select character (X'20' or X'21') for each digit in the packed decimal number you're editing. Your complete prototype edit mask just has 6 digit select characters. $TTOTAL, on the other hand, has 9 digits.
  • Except for very simple cases, I quit using literals for an edit mask. They are too hard to examine, and it is too easy to make a mistake.
  • The X'21' digit select does not immediately insert a 0; it starts with the next character.
This is what I do.
         MVC   TOTLOUT,EDMASK
         ED    TOTLOUT,$TTOTAL
*                 -----+----1--
EDMASK   DC    0C' N,NNN,NNN.NN'
         DC    C' ',X'20',C',',X'202020,C',',X'202120'
         DC    C'.',X'2020'
         ...
TOTLOUT  DC    CL(L'EDMASK)' '

I first define what I want the output to look like as a 0C'...' data area. This is more for documentation and to define a length. Then I construct the edit mask. When I want to specify a real character, I break the digit selects and insert the character using C'character'. Now I do not want to claim I never make a mistake here, but it's usually easier to find and correct the goof than when you use a literal.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Need help with practice assignment!!

Postby pintu1228 » Sun Apr 05, 2015 11:20 am

This is what the professor said regarding PRINT: move the math code inside of your table loop code.....the table loop code is not doing any processing the way you have it.

I don't quite get what he is saying. I have my math in the PLOOP
pintu1228
 
Posts: 48
Joined: Mon Mar 23, 2015 12:41 am
Has thanked: 5 times
Been thanked: 0 time

Re: Need help with practice assignment!!

Postby steve-myers » Sun Apr 05, 2015 12:31 pm

The only proper loop in CMPUTE is
CLOOP  CR R6,R7                EXIT LOOP IF PAST THE LAST NUMBER
       BC B'0100',EXIT2        CHECK END OF FILE
       LA R6,32(R6)            GO TO THE NEXT ENTRY
       C R6,0(0,R3)
       B CLOOP                 GO TO TOP OF THE LOOP


I think there is valid code elsewhere in CMPUTE that you want to move to just after the BC.

IF      CP TPNUM(7),CMP(5)   COMPARES PRODUCT OF TPNUM TO VALUE OF CMP
        BC B'0101',ELSE         JUMP TO ELSE IF TPNUM IS LESS THAN CMP
        ZAP $TSHIP(4),NOSHP(1)  ZERO OUT TSHIP & ADD NOSHP VALUE TO IT
        BC B'1111',ENDIF        UNCONDITIONAL VALUE
ELSE    DS 0H
        ZAP $TSHIP(4),SHPCH(3)  ZERO OUT TSHIP & ADD SHPCH VALUE TO IT
ENDIF   DS 0H

You're thinking something like C here. That's OK, but an Assembler programmer thinks differently. When faced with
if (a test)
 a statement
else
 another statement

An Assembler programmer will usually write the equivalent of
another statement
if (a test)
 a statement

The statement that's always executed is the quickest of the two options. If the two statements really are mutually exclusive, an Assembler programmer will write what you did, though we try to avoid it
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Need help with practice assignment!!

Postby steve-myers » Sun Apr 05, 2015 8:27 pm

pintu1228 - You might want to share this with your professor. I'd be interested in his reaction.

<rant mode on>
Long Assembler literals as edit masks

For almost 50 years code like this -
         MVC   OUTAREA,=X'40206B2020206B2021204B2020'
         ED    OUTAREA,PDNUM
         ...
PDNUM    DC    P'100000000'
         ...
OUTAREA  DC    CL13' '

has been accepted practice in our industry. Books have taught this. Assembler language instructors have tolerated this. For almost 50 years no one has clearly stated this is a poor practice, for multiple reasons.
  • These long literals are difficult to analyze, especially if there is a mistake in the literal.
  • The analyst or programmer must either memorize or look up the hexadecimal codes for a blank character, a comma (,) character, and a period (.) character or other characters that are in the mask.
  • The relationship between the target area and the edit mask was very poor. If there was a mistake it was difficult to analyze, and some times difficult to even detect.
About the only advantage to this method is the edit mask was defined with its use.

I propose a practice more like this.
         MVC   OUTAREA,EDMASK
         ED    OUTAREA,PDNUM
         ...
PDNUM    DC    PL5'100000000'
EDMASK   DC    0C' N,NNN,NNN.NN'
         DC    C' ',X'20',C',',X'202020',C',',X'202120'
         DC    C'.',X'2020'
         ...
OUTAREA  DC    CL(L'EDMASK)' '

There are a number of advantages to this.
  • The 0C' N,NNN,NNN.NN' clearly shows the intent of the edit mask.
  • The 0C' N,NNN,NNN.NN' clearly defines the actual length of the actual output area.
  • The Assembler converts characters to their hexadecimal equivalent, which, by definition, it can do perfectly.
Now I will not claim this method is perfect. There is no convenient method to cross check the proposed edit mask in 0C' N,NNN,NNN.NN' with the actual edit mask that follows, and switching between character data and the hexadecimal digit select codes is somewhat error prone, though at least the Assembler catches the goofs. And, as was implied earlier, the edit mask is separated from its use.
<rant mode off>
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Need help with practice assignment!!

Postby pintu1228 » Sun Apr 05, 2015 9:56 pm

So do I need to my my valid if statement inside the bc call to fix the print then?
pintu1228
 
Posts: 48
Joined: Mon Mar 23, 2015 12:41 am
Has thanked: 5 times
Been thanked: 0 time

Re: Need help with practice assignment!!

Postby steve-myers » Sun Apr 05, 2015 10:29 pm

I think the IF you proposed belongs in CMPUTE. There may be something similar in PRINT. That needs to be determined.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Need help with practice assignment!!

Postby pintu1228 » Sun Apr 05, 2015 10:52 pm

What exactly am I fixing in PRINT DSECT???
pintu1228
 
Posts: 48
Joined: Mon Mar 23, 2015 12:41 am
Has thanked: 5 times
Been thanked: 0 time

Re: Need help with practice assignment!!

Postby Robert Sample » Sun Apr 05, 2015 11:30 pm

There is quite a bit to fix in PRINT.
1. You defined PRINT as a DSECT so you got an unresolved external reference when attempting to define the V-type address.
2. In line 185 you move 5 characters of the edit mask literal to a 3-character field. I don't think the ED instruction will work properly in such a case.
3. You move $TNUM and $TDATE directly to the print line. Since both variables are defined as packed, I suspect you won't be seeing much printable data from such a command.
4. You move 5 bytes for the date -- ok for packed but not so good for printable data.
5. Your moves in lines 191, 194, 197 suffer the same flaw mentioned in #2 above -- the receiving field is shorter than the sending field.
6. You are not inserting the currency signs on the print line fields.
7. Your assignment indicates you should have a report header which is not in your code.
8. Your assignment indicates you should double-space the report which is not in your code.
9. Your assignment indicates you should have summary data at the end of the report which is not in your code.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Need help with practice assignment!!

Postby pintu1228 » Mon Apr 06, 2015 12:36 am

Thanks but before I move on to Print, can you help me with my compute logic. Does the logic I have do everything I need?

I am confused on this assignment, whereas previous ones I finished and do well.

Thanks
pintu1228
 
Posts: 48
Joined: Mon Mar 23, 2015 12:41 am
Has thanked: 5 times
Been thanked: 0 time

Re: Need help with practice assignment!!

Postby Robert Sample » Mon Apr 06, 2015 12:45 am

Have you changed the loop in CMPUTE to actually do anything? You haven't posted any Assist output if so, so it isn't possible to say if your CMPUTE is now correct or not.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

PreviousNext

Return to Assembler