home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff339.lzh / PCQ / Runtime.lzh / Runtime / Writers / WriteInt.asm < prev    next >
Assembly Source File  |  1990-03-03  |  1KB  |  48 lines

  1.  
  2. *    WriteInt.asm (of PCQ Pascal runtime library)
  3. *    Copyright (c) 1989 Patrick Quaid
  4.  
  5. *    Write an integer to a text file.
  6.  
  7. *    Upon entry, d0 holds the value to write.  The word on top of
  8. *    the stack holds the minumum field width, and the long word
  9. *    below that holds the file record address
  10. *
  11.  
  12.     SECTION    one
  13.  
  14.     XREF    _p%PadOut
  15.     XREF    i_ldiv
  16.     XREF    outbuffer
  17.     XREF    _p%WriteText
  18.     XREF    _p%IOResult
  19.     XREF    _IntToStr
  20.  
  21.     XDEF    _p%WriteInt
  22. _p%WriteInt
  23.  
  24.     tst.l    _p%IOResult        ; is IO system OK?
  25.     bne    5$            ; if not, leave
  26.  
  27.     sub.l    #16,sp            ; allocate work space
  28.     move.l    sp,-(sp)        ; push this address
  29.     move.l    d0,-(sp)        ; push integer value
  30.     jsr    _IntToStr        ; fill buffer with integer
  31.     addq.l    #8,sp            ; pop stuff off stack
  32.  
  33.     move.l    d0,d3            ; move length into d3
  34.     move.l    22(sp),a0        ; a0 := file record address
  35.     move.w    20(sp),d0        ; get the field width
  36.     ext.l    d0            ; make it an integer
  37.     sub.l    d3,d0            ; how many extras?
  38.     ble    4$            ; if none, skip this
  39.     jsr    _p%PadOut        ; write d0 spaces to a0 file rec
  40. 4$    move.l    sp,a1            ; point to first char
  41.     jsr    _p%WriteText        ; write d3 bytes at a1 to a0
  42.     add.l    #16,sp            ; free work space
  43.  
  44. 5$    rts
  45.  
  46.     END
  47.  
  48.