home *** CD-ROM | disk | FTP | other *** search
/ Carousel / CAROUSEL.cdr / mactosh / unix / unix_dra.hqx / machint.s next >
Text File  |  1987-02-14  |  728b  |  30 lines

  1. rcsid:    .asciz    "$Header: /ful/chris/ctex/lib/RCS/machint.s,v 1.1 84/05/26 01:53:01 chris Exp $"
  2.  
  3. # machint (addr, count)
  4. # char *addr; int count;
  5. #
  6. # Convert "count" 4-byte PXL-style integers at address "addr"
  7. # to and from machine integers.  (Note that calling machint
  8. # twice is effectively a no-op.)
  9.  
  10.     .align    2
  11.     .globl    _machint
  12. _machint:
  13.     .word    0
  14.  
  15.     movl    4(ap),r1        # r1 = addr
  16.     ashl    $2,8(ap),r2
  17.     addl2    r1,r2            # r2 = &addr[count]
  18. 1:    cmpl    r1,r2            # is addr >= end?
  19.     blss    2f
  20.     ret                # return if r1 >= r2
  21. 2:    movl    (r1)+,r0        # r0 = *r1++
  22.     movb    r0,-1(r1)        # byte 0 to byte 3
  23.     ashl    $-8,r0,r0        # r0 >>= 8
  24.     movb    r0,-2(r1)        # byte 1 to byte 2
  25.     ashl    $-8,r0,r0        # etc
  26.     movb    r0,-3(r1)
  27.     ashl    $-8,r0,r0
  28.     movb    r0,-4(r1)
  29.     brb    1b            # and repeat
  30.