Grande 64 bit Operation



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

Grande 64 bit Operation

Postby xboss » Sat Feb 04, 2012 2:00 am

Hello all,
I am trying to run a simple assembler program that do basic arithmetic function (ADD, MULTIPLY, DELETE) using 64 bit register. I don't see any error in my program (I compiled and ran successfully) but I am not getting result I expected when looking at storage dump. By expected result, I mean to say when I Defined Double Word of value "2", in memory I am seeing 412 as its hex representation. May be this is how it should display I don't know. Please help me understand if I am doing something run in coding or reading.

Program
***************************************************************
         DS    0H                 DEFINE HALWORD FOR CSECT     
         STMH  R14,R12,128(R13)   Save upper register halves   
         STM   R14,R12,12(R13)    Saving Registers             
         BALR  R12,0              ESTABLISHING BASE REGISTER   
         USING *,R12              ESTABLISHING ADDREASIBILITY   
         LA    R2,SAVELOW         LOAD MEMORY ADD TO REG       
         ST    R13,4(,R2)         STORE CALLER REG IN 2ND WORD 
         ST    R2,8(,R13)         STORING CALLEE REG IN 3rd WORD
         LA    R3,SAVEHIGH                                     
         ST    R3,128(,R13)       64 BIT STORE                 
         LR    R13,R2                                           
ADD      EQU   *                                                 
         LG    R2,VALUE1          LOAD Double Word to R2         
         AG    R2,VALUE2          ADD AND STORE RESULT TO R2     
         STG   R2,ADDR                                           
         WTO   'ADD'                                             
MULTI    EQU   *                                                 
         LG    R3,VALUE3          LOAD DOUBLE WORD TO R3         
         MSGR  R2,R3              MULTIPLY AND STORE RESULT TO R2
         STG   R2,MULTIR                                         
         WTO   'MULTIPLY'                                       
DIVIDE   EQU   *                                                 
         LG    R4,VALUE4          LOAD DOUBLE WORD               
         DSGR  R2,R4              DIVIDE AND STORE RESULT TO R2 
         STG   R2,DIVIDER                                       
         WTO   'DIVIDE'                                         
         DC    H'0'                                             
 RETURN   EQU    *                       
          L      R13,SAVELOW+4           
 *        LM     R14,R12,12(13)        RE
          LMD    R14,R12,SAVEHIGH,12(R13)
          BR     R14                     
 ********************* DATA AREAS *******         
 SAVEHIGH DC     18F'0'                 
 SAVELOW  DC     18F'0'                 
 LOOHERE  DC     CL8'STARTING'           
 VALUE1   DC     X'000000007FFFFFFF'     
 VALUE2   DC     1D'2'                   
 VALUE3   DC     1D'-1'                 
 VALUE4   DC     1D'255'                 
 ADDR     DS     1D                     
 MULTIR   DS     1D                     
 DIVIDER  DS     1D                     


Storage Dump
00007FB8 +001A0  00000000 00000000 E2E3C1D9 E3C9D5C7  ........STARTING
00007FC8 +001B0  00000000 7FFFFFFF 41200000 00000000  ...."...........
00007FD8 +001C0  C1100000 00000000 42FF0000 00000000  A...............
00007FE8 +001D0  41200000 7FFFFFFF 3EF00000 00000000  ...."....0......
00007FF8 +001E0  C1100000 00000000                    A.......       
xboss
 
Posts: 79
Joined: Mon Nov 29, 2010 10:55 am
Has thanked: 0 time
Been thanked: 0 time

Re: Grande 64 bit Operation

 

Re: Grande 64 bit Operation

Postby enrico-sorichetti » Sat Feb 04, 2012 2:16 am

You did nothing wrong... You just did not do it :geek:
reading the manuals in HLASM bookshelf ???
http://publibz.boulder.ibm.com/cgi-bin/ ... s/ASMSH030

and specifically the
V1Rx Language Ref
http://publibz.boulder.ibm.com/cgi-bin/ ... 0711003624
at the paragraph
http://publibz.boulder.ibm.com/cgi-bin/ ... 3624&CASE=
were it is spelt in clear letters that ...

Code    Constant Type       Machine Format
----    ----------------    -------------------------------------------------
D       Floating-point      Long floating-point format; normally a doubleword                                 

AND

Type    Type Extension      Description                                 
----    ----------------    -------------------------------------------------
F       D                   Doubleword fixed-point constant             
 


so

000000 00000001                       3 A        DC    F'1'                     
000004 00000000                                                                 
000008 0000000000000001               4 A1       DC    FD'1'                   
000010 04                             5 LA       DC    AL1(L'A)                 
000011 08                             6 LA1      DC    AL1(L'A1)               
                      00004           7 ELA      EQU   L'A                     
                      00008           8 ELA1     EQU   L'A1                     
Last edited by enrico-sorichetti on Sat Feb 04, 2012 2:25 am, edited 2 times in total.
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Grande 64 bit Operation

Postby steve-myers » Sat Feb 04, 2012 2:23 am

Well, to start: you need to do more research on how to define 64-bit integers. D'2' defines a 64-bit hexadecimal floating point 2, not a 64-bit integer 2.
steve-myers
Global moderator
 
Posts: 1885
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 197 times

Re: Grande 64 bit Operation

Postby xboss » Sat Feb 04, 2012 4:47 am

Thank you, both for you time and links. Sometime to get up to correct resources is itself a research if you don't know the correct keyword. :(
xboss
 
Posts: 79
Joined: Mon Nov 29, 2010 10:55 am
Has thanked: 0 time
Been thanked: 0 time

Re: Grande 64 bit Operation

Postby steve-myers » Sat Feb 04, 2012 8:12 am

Enrico - you should not have given xboss the solution; better he finds it himself! Not only is there a better chance it will stick, but learning how to do the research is probably more valuable. I recall an incident back in the 1970s when IBM would provide on site a software support. Anyway, I was working with our support on some issue - can't remember what it was, when he volunteered, "There's a couple of things I like about you; you usually admit it when you don't know something rather than try to convince me that you do know it, and you usually know where to look to try to resolve something." Now xboss at least has the former quality, but he really needs to acquire the latter.

There is another possible way to specify a 64-bit integer: FL8'value'. I've been using FL8'-1' for nearly as long as I've been writing System/360 Assembler! Granted, it doesn't align properly, but that's something that's not hard to work around if you expect it.

One other thing I noticed in the code xboss showed. I'm not sure his method to save the 64-bit registers is safe. There are two issues
  • He assumes his caller is providing an extension to the standard save area.
  • His general methodolgy is incorrect. I'm giving a freebie link here, something I don't do very often any more to try make our lurkers, and possibly our topic starters training in doing their own research. Technically the link is a little out of date, but I doubt it's changed.
Actually, the few times I've done true 64-bit arithmetic I haven't bothered to save and restore the high order bits of the registers and it hasn't seemed to do any harm.

Much safer, but almost certainly much slower is to use BAKR on entry to save the registers in the linkage stack and PR to restore the registers and return. I did a performance study on this long before 64-bit GPRs, but BAKR did store the access registers. I don't recall the numbers, but it was much slower than regular linkage.
steve-myers
Global moderator
 
Posts: 1885
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 197 times

Re: Grande 64 bit Operation

Postby xboss » Mon Feb 06, 2012 11:30 pm

Steve,
Thanks for both compliments and critics, I am working hard to acquire latter quality as well. :)
Yes, with performance trade off, BAKR/PR can be used to save GR as well as Access register. But being in a learning phase I want to try out all possible ways.

Thanks,
xboss
 
Posts: 79
Joined: Mon Nov 29, 2010 10:55 am
Has thanked: 0 time
Been thanked: 0 time

Re: Grande 64 bit Operation

Postby steve-myers » Tue Feb 07, 2012 2:40 am

xboss wrote:... But being in a learning phase I want to try out all possible ways. ...
Unfortunately, most supervisor types don't understand how important it is for people to experiment. For that matter, most people don't appear to understand this. Far better to screw up something in an experiment than to apply what amounts to an experiment to a production something and break it because the experiment failed.
steve-myers
Global moderator
 
Posts: 1885
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 197 times


Return to Assembler