home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / program / compiler / nasm20b / nasm_src / lib / src / pretty.s65 < prev    next >
Text File  |  1993-01-19  |  2KB  |  93 lines

  1. ;;    THIS IS UNIFINISHED
  2.    .include #macros
  3.    .include #16bit                  /* 1 TAB = three spaces */
  4.                                     /* use 6 for coding     */                 
  5.    .if .not .def TEST
  6.       .vfl_bochum _string1
  7.       .vfl_bochum _string2
  8.    .else
  9.  
  10.       .include #cio
  11.  
  12. _string1 == $F0
  13.  
  14.  
  15. main:
  16.       dpoke    _string1,buffer1
  17.       dpoke    _string2,headbuf
  18.       jsr      pretty
  19.       print    0,header,255,@p1+@p2+@p3
  20.       dpoke    _string1,buffer2
  21.       jsr      pretty
  22.       print    0,header,255,@p1+@p2+@p3
  23.       brk
  24.  
  25.  
  26. header:
  27.       .byte    "Value = "
  28. headbuf:      
  29.       .ds      8
  30.          
  31. buffer1:
  32.       .byte    "12345",0
  33.  
  34. buffer2:
  35.       .byte    "-00123450",0
  36.  
  37.       .endif
  38.  
  39. ;; -------------------------------------------------------------
  40. ;; Pretties up a ASCII integer, this is useful after having
  41. ;; converted something via ITOA. If carry is set, then pretty
  42. ;; assumes that in X there is a character that should be put 
  43. ;; at the end of the string. The integer can't be longer than
  44. ;; 255 characters. This routine does no error checking!!
  45. ;; 
  46. ;; _STRING1 : ASCII integer
  47. ;; -------------------------------------------------------------
  48.       
  49. kill_0lead:
  50.       ldy   #0                ; can't optimize here, sorry
  51.       tya                     ; push EOS append flag on stack
  52.       adc   #0                ; 1 == APPEND, 0 == DON'T
  53.       pha                     
  54.       txa
  55.       pha                     ; push EOS char on stack
  56.       ldx   #0                ; [like to keep STD.L65 ROMamble]
  57.       
  58. :loop
  59.       lda   (_string1),y
  60.       beq   :done
  61. :xloop
  62.       cmp   #'-'              ; ought to be in the front only
  63.       beq   :still
  64.       cmp   #'+'
  65.       beq   :still
  66.       cmp   #'0'        
  67.       beq   :eliminate
  68.       inx  
  69. :still
  70.       sta   (_string2),y
  71.       iny
  72.       bne   :loop
  73.  
  74.            
  75. :eliminate
  76.       cpx   #1                ; still in the header
  77.       bcs   :still            ; nope ->
  78.       iny
  79.       lda   (_string1),y      ; this the last 0 (was 00000 probably...)
  80.       bne   :xloop            ; try next
  81.       
  82. :done
  83.       pla
  84.       tax
  85.       pla
  86.       beq   :donothing
  87.       rtsa
  88.      
  89.       
  90.       
  91.  
  92.             
  93.