🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.asm370
Article #432

RE: Writing double word binary numbers on screen

#432
From: "Steve Bacher ", Batchman
Date: Tue, 25 Sep 1990 12:16
56 lines
2871 bytes
>Hi 370 Assemblers..
>I have a double word binary number, and I want to write it on screen in
>decimal form. How can I write it ? Any help would be appreciated.
> -Suleyman Kutlu
>System Programmer

Try this...

*
* Some code to take the contents of a binary doubleword and convert
* to decimal display format.
*
* This code works for non-negative numbers only.
*
         LM    R4,R5,DBLWORD        Load double word integer
         LTR   R4,R4                If number is negative
         BM    ...                  (sorry, I haven't done this path)
         D     R4,=F'1000000000'    Divide double-int by 10^9
*
* We know that the quotient cannot be greater than 2147483647, so
* a program check is not possible.
*                                   R4 = remainder
*                                   R5 = quotient
         CVD   R5,CVDAREA           Convert quotient to decimal
         UNPK  DSPAREA(9),CVDAREA   Get 9 digits of decimal number
         OI    DSPAREA+8,X'F0'      Fix up sign
         CVD   R4,CVDAREA           Convert remainder to decimal
         UNPK  DSPAREA+9(9),CVDAREA Get 9 digits of decimal number
         OI    DSPAREA+9+8,X'F0'    Fix up sign
*
* Now the dumped integer is at DSPAREA.
* We have 18 digits.  Now get rid of leading blanks.
*
         LA    R1,DSPAREA          Start pointer at start of digits
         LA    R15,17              Set loop count
DLZLOOP  CLI   0(R1),C'0'          Loop until nonzero digit found
         BNE   DLZEND              or last digit found
         MVI   0(R1),C' '          Blank out each leading zero
         LA    R1,1(,R1)           bumping R1 each time
         BCT   R15,DLZLOOP
DLZEND   DS    0H                  R15 contains # of significant
*                                  decimal digits, R1 points to num
         B     FINISHED
         ...
DBLWORD  DS    D                   Here's where your number lives
DSPAREA  DS    CL18                Here's where you put the display
CVDAREA  DS    D                   Conversion work area
         ...


I hope this helps.  Although this code is a slightly-edited extract of a
working double-precision-float display routine that works, I have not
actually tested this excerpt.  Good luck!

				- Steve Bacher
				- Charles Stark Draper Laboratory
Technical Details
Message-ID: <9009251438.AA09452@ucbvax.Berkeley.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!ucsd!ucbvax!ccfvx3.draper.COM!SEB1525

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!ucsd!ucbvax!ccfvx3.draper.COM!SEB1525
From: SEB1525@ccfvx3.draper.COM ("Steve Bacher ", Batchman)
Newsgroups: comp.lang.asm370
Subject: RE: Writing double word binary numbers on screen
Message-ID: <9009251438.AA09452@ucbvax.Berkeley.EDU>
Date: 25 Sep 90 12:16:00 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Reply-To: IBM 370 Assembly Programming Discussion List
              <ASM370@OHSTVMA.BITNET>
Distribution: inet
Organization: The Internet
Lines: 56