User Tools

Site Tools


base:int16_and_uint16_conversion_to_string

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
base:int16_and_uint16_conversion_to_string [2019-08-16 23:24] verzbase:int16_and_uint16_conversion_to_string [2019-08-18 09:35] (current) verz
Line 3: Line 3:
 _UtoA converts an unsigned number\\ _UtoA converts an unsigned number\\
 The conversion is obtained via a BCD intermediate value. The conversion is obtained via a BCD intermediate value.
-<code>+<code 6502acme>
 bcd     = $61    ; system Fac, 3 bytes bcd     = $61    ; system Fac, 3 bytes
 int16   = $64    ; system Fac, 2 bytes int16   = $64    ; system Fac, 2 bytes
Line 22: Line 22:
  
 _ItoA _ItoA
-        lda int16+1           ; is it positive+        ldy #$0 
 +        lda int16+1           ; is it positive?
         bpl _pos         bpl _pos
  
Line 34: Line 35:
         adc #0         adc #0
         sta int16+1         sta int16+1
-        lda #'-'              ; prepares the sign value +        ldy #'-'              ; prepares the sign value
-        sta sgn+
  
-_pos    jsr _UtoA             ; the work is done by _UtoA routine+_pos    sty sgn 
 +        jsr _UtoA             ; the work is done by _UtoA routine
  
-        lda sgn               ; if the sign was negative+        ldy sgn               ; if the sign was negative
         beq _enditoa                   beq _enditoa          
         dex                   ; adds '-' before the number         dex                   ; adds '-' before the number
Line 113: Line 114:
 ;       needs the pos of the first digit in .X  ;       needs the pos of the first digit in .X 
 ;       result in CnvTrm ;       result in CnvTrm
 +;       if the result is to be in CnvStr then change CnvTrm to CnvStr
 ;------------------------------- ;-------------------------------
 _TrimNum _TrimNum
Line 119: Line 121:
         beq _rts         beq _rts
 _trmlp  lda CnvStr,x _trmlp  lda CnvStr,x
-        sta CnvTrm,y+        sta CnvTrm,     ; Change to "sta CnvStr,y" to put the trimmed string in CnvStr
         beq _rts         beq _rts
         inx         inx
Line 129: Line 131:
  
 ;------------------------------- ;-------------------------------
-; Converts a 16bit number in BCD+; Converts a 16bit number to BCD
 ;------------------------------- ;-------------------------------
 BINBCD16 BINBCD16
Line 196: Line 198:
  
 usage example: usage example:
-<code>+<code 6502tasm >
 Example Example
-        lda #0 
-        sta sgn 
         lda #$c0         lda #$c0
         sta int16         sta int16
Line 211: Line 211:
  
  
-        lda #0 
-        sta sgn 
         lda #$c0         lda #$c0
         sta int16         sta int16
base/int16_and_uint16_conversion_to_string.1565990680.txt.gz · Last modified: 2019-08-16 23:24 by verz