## Posted By

gfazioli on 09/14/09

# ValueToStringDec

/ Published in: Assembler

`**************************************************************************************** (20-Feb-1995) --- ValueToStringDec(buffer, value, optlen) (A0/D0/D1)***************************************************************************************_LVOValueToStringDecmovem.l d2-d7,-(sp)tst.l d1 * Decido lunghezza della stringa??bne.s ConLen * Usa l'altra routine di conversione.moveq #10,d5 ; 10moveq #"0",d2 ; fast Code "0" \$30tst.l d0 ; Vediamo se Ã¨ negativobpl.s CDD_PLmove.b #"-",(a0)+ ; Se Neg metti un meno nel bufferneg.l d0 ; E trasforma POSCDD_PL cmp.l d5,d0 ; vediamo se Ã¨ <10bhi.s CDD_BHI ; NObne.s CDD_BNE ; <>10?move.w #"10",(a0)+ ; Metti 10 ed escimove.b #0,(a0)movem.l (sp)+,d2-d7rtsCDD_BNE add.b d2,d0 ; Salva il numeromove.b d0,(a0)+ ; visto che Ã¨ <10move.b #0,(a0) ; azzera ed escimovem.l (sp)+,d2-d7 *rts;--------------------------------------------------------------------------------------CDD_BHI lea Tables+4(pc),a1CDD_GT cmp.l (a1)+,d0bge.s CDD_GTsubq.l #8,a1move.l d0,d3DCC_LX move.l (a1),d1bne.s DCC_CTmove.b d1,(a0)+movem.l (sp)+,d2-d7rts;--------------------------------------------------------------------------------------DCC_CT moveq #-1,d4DCC_LP move.l d3,d5addq.w #1,d4sub.l d1,d3bcc.s DCC_LPDC_LAS add.b d2,d4move.b d4,(a0)+move.l d5,d3subq.w #4,a1bra.s DCC_LX;--------------------------------------------------------------------------------------**************************************************************************************** (20-Feb-1995) --- ConLen (Vedi sopra) Stessi INPUTS di ValueToStringDec()***************************************************************************************ConLen move.l a2,-(sp)move.l a0,a2 * Routine che converte con la lunghezza fissamoveq #0,d5 * D5 for len Countmoveq #10,d6move.l d1,d7 * numero di caratteri finalisub.b d7,d6move.l d6,d7subq.b #2,d1move.l d1,d6asl.l #2,d7ConvDec_NoZerolea ConvDec_Table(pc),a0 * Table of TEN (10)lea (a0,d7.w),a0move.l a2,a1moveq #0,d5tst.l d0bpl.s ConvDec_Plusmoveq #1,d5 * Len+1 because there is "-"move.b #"-",(a1)+ * Set Sign Charneg.l d0 * Lo rende positivoConvDec_Plusmove.l d6,d4 * Loop for ....moveq #"0",d7 * For Fasting CODEConvDec_ReStartmoveq #0,d3 * Ending Numbermove.l (a0)+,d2 * 10xxx.. in d2move.l d2,d1 * and save it in d1ConvDec_Ctrlcmp.l d2,d0bmi.s ConvDec_Saveadd.l d1,d2addq.b #1,d3bra.s ConvDec_CtrlConvDec_Saveadd.b d7,d3move.b d3,(a1)+addq.b #1,d5 * Count for Lensub.l d1,d2sub.l d2,d0dbf d4,ConvDec_ReStartadd.b d7,d0move.b d0,(a1)+addq.b #1,d5move.l d5,4(sp) * D1=Lenmove.l (sp)+,a2movem.l (sp)+,d2-d7rts;--------------------------------------------------------------------------------------; Tavole di conversione decimale.;--------------------------------------------------------------------------------------dc.l 0D2V_TableDecdc.l 1Tables dc.l 10dc.l 100dc.l 1000dc.l 10000dc.l 100000dc.l 1000000dc.l 10000000dc.l 100000000dc.l 1000000000ConvDec_Tabledc.l 1000000000dc.l 100000000dc.l 10000000dc.l 1000000dc.l 100000dc.l 10000dc.l 1000dc.l 100dc.l 10dc.l 1`