home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / mac / programm / 18692 < prev    next >
Encoding:
Text File  |  1992-11-19  |  7.7 KB  |  224 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!apple!mumbo.apple.com!gallant.apple.com!nuntius
  3. From: Steve Christensen <stevec@apple.com>
  4. Subject: Re: Help! making an assembly routine faster
  5. Sender: news@gallant.apple.com
  6. Message-ID: <1992Nov20.040608.25002@gallant.apple.com>
  7. X-Useragent: Nuntius v1.1
  8. Date: Fri, 20 Nov 1992 04:06:08 GMT
  9. References: <1992Nov18.010815.6649@cs.uoregon.edu>
  10. Organization: Apple Computer, Inc.
  11. Lines: 211
  12.  
  13. I took a pass at the code and here's what I came up with (changed lines
  14. will have a * in the comment field).
  15.  
  16.         MOVE.W     h, D0               ; put height loop variable in D0
  17.         MOVEA.L    src, A0             ; put the source pixmap address in
  18. A0
  19.         MOVEA.L    dst, A1             ; put the destination address in A1
  20.         MOVEA.L    mask, A2            ; put the mask address in A2
  21.         CLR.L      D2                  ; clear the mask register
  22.     @1:                                ; copy the next row
  23.         MOVE.W     w, D1
  24.     @2:                                ; copy the next eight bytes in the
  25. row
  26.         MOVE.B     (A2)+, D2           ; copy the next mask byte
  27.         BEQ.S      @nocopy             ;*if zero, don't copy anything
  28.         
  29.         CMPI.B     #0xFF, D2
  30.         BNE.S      @hardway            ;*don't copy everything
  31.         
  32.         MOVE.L     (A0)+, (A1)+        ; copy all bytes
  33.         MOVE.L     (A0)+, (A1)+
  34.         DBF        D1, @2
  35.         BRA.S      @endloop            ;*
  36.     
  37.     @nocopy:                           ; copy no bytes
  38.         ADDQ.L     #8, A0
  39.         ADDQ.L     #8, A1
  40.         DBF        D1, @2
  41.         BRA.S      @endloop            ;*
  42.     
  43.     @hardway:
  44.         MOVEQ      #0xF, D3            ;*mask off the lower nibble for
  45. later
  46.         AND.B      D2, D3              ;*
  47.         LSR.W      #4, D2              ; shift bits 4-7 into bits 0-3
  48.         ADD.W      D2, D2              ; double the index
  49.         MOVE.W     @table(D2.W), D2    ;*calculate the address
  50.         LEA        @rts1, A3           ; save the return address
  51.         JMP        @table(D2.W)        ; plot four pixels
  52.     @rts1:
  53.         
  54. ;*******MOVE.B     -1(A2), D2          ; copy the next mask byte
  55. ;*******ANDI.B     #0xF, D2            ; mask off the high four bits
  56.         ADD.W      D2, D2              ; double the index
  57.         MOVE.W     @table(D3.W), D2    ;*calculate the address
  58.         LEA        @rts2, A3           ; save the return address
  59.         JMP        @table(D2.W)        ; plot four pixels
  60.     @rts2:
  61.         DBF        D1, @2
  62.         
  63.     @endloop:
  64.     
  65.         MOVE.W     e, D1               ;*
  66.         BLT.S      @4                  ;*continue if e is less than 0
  67.     
  68.         MOVE.B     (A2)+, D2           ; copy the next mask byte
  69. ;*******MOVE.W     e, D1               ; initialize the loop counter
  70.         MOVEQ.L    #7, D3              ; initialize the bit counter
  71.     
  72.     @3:                                ; copy the next byte
  73.         BTST       D3, D2              ; test the next bit in the mask
  74.         BEQ.S      @skip               ;*if zero, continue
  75.         MOVE.B     (A0)+, (A1)+        ; else copy the pixel
  76.         SUBQ.L     #1, D3              ; decrement the bit counter
  77.         DBF        D1, @3
  78.         BRA.S      @4                  ;*
  79.     @skip:
  80.         ADDQ.L     #1, A0
  81.         ADDQ.L     #1, A1
  82.         SUBQ.L     #1, D3              ; decrement the bit counter
  83.         DBF        D1, @3
  84.     
  85.     @4:
  86.         ADDA.L     srcNewline, A0      ; bring the src pointer to the
  87. start of the next row
  88.         ADDA.L     dstNewline, A1      ; bring the dst pointer to the
  89. start of the next row
  90.         
  91.         DBF        D0, @1
  92.         
  93.         JMP        @end                ; skip to the end
  94.         
  95.     @table:
  96.         DC.W       @sub0-@table        ;*
  97.         DC.W       @sub1-@table        ;*
  98.         DC.W       @sub2-@table        ;*
  99.         DC.W       @sub3-@table        ;*
  100.         DC.W       @sub4-@table        ;*
  101.         DC.W       @sub5-@table        ;*
  102.         DC.W       @sub6-@table        ;*
  103.         DC.W       @sub7-@table        ;*
  104.         DC.W       @sub8-@table        ;*
  105.         DC.W       @sub9-@table        ;*
  106.         DC.W       @sub10-@table       ;*
  107.         DC.W       @sub11-@table       ;*
  108.         DC.W       @sub12-@table       ;*
  109.         DC.W       @sub13-@table       ;*
  110.         DC.W       @sub14-@table       ;*
  111.         DC.W       @sub15-@table       ;*
  112.     
  113.     @sub0:                            ; mask = 0000, draw nothing
  114.         ADDQ.L     #4, A0
  115.         ADDQ.L     #4, A1
  116.         JMP        (A3)               ; RTS
  117.     
  118.     @sub1:                            ; mask = 0001
  119.         ADDQ.L     #3, A0
  120.         ADDQ.L     #3, A1
  121.         MOVE.B     (A0)+, (A1)+
  122.         JMP        (A3)               ; RTS
  123.     
  124.     @sub2:                            ; mask = 0010
  125.         ADDQ.L     #2, A0
  126.         ADDQ.L     #2, A1
  127.         MOVE.B     (A0), (A1)
  128.         ADDQ.L     #2, A0
  129.         ADDQ.L     #2, A1
  130.         JMP        (A3)               ; RTS
  131.     
  132.     @sub3:                            ; mask = 0011
  133.         ADDQ.L     #2, A0
  134.         ADDQ.L     #2, A1
  135.         MOVE.W     (A0)+, (A1)+
  136.         JMP        (A3)               ; RTS
  137.     
  138.     @sub4:                            ; mask = 0100
  139.         ADDQ.L     #1, A0
  140.         ADDQ.L     #1, A1
  141.         MOVE.B     (A0), (A1)
  142.         ADDQ.L     #3, A0
  143.         ADDQ.L     #3, A1
  144.         JMP        (A3)               ; RTS
  145.     
  146.     @sub5:                            ; mask = 0101
  147.         ADDQ.L     #1, A0
  148.         ADDQ.L     #1, A1
  149.         MOVE.B     (A0), (A1)
  150.         ADDQ.L     #2, A0
  151.         ADDQ.L     #2, A1
  152.         MOVE.B     (A0)+, (A1)+
  153.         JMP        (A3)               ; RTS
  154.     
  155.     @sub6:                            ; mask = 0110
  156.         ADDQ.L     #1, A0
  157.         ADDQ.L     #1, A1
  158.         MOVE.W     (A0), (A1)
  159.         ADDQ.L     #3, A0
  160.         ADDQ.L     #3, A1
  161.         JMP        (A3)               ; RTS
  162.     
  163.     @sub7:                            ; mask = 0111
  164.         ADDQ.L     #1, A0
  165.         ADDQ.L     #1, A1
  166.         MOVE.B     (A0)+, (A1)+
  167.         MOVE.W     (A0)+, (A1)+
  168.         JMP        (A3)               ; RTS
  169.     
  170.     @sub8:                            ; mask = 1000
  171.         MOVE.B     (A0), (A1)
  172.         ADDQ.L     #4, A0
  173.         ADDQ.L     #4, A1
  174.         JMP        (A3)               ; RTS
  175.     
  176.     @sub9:                            ; mask = 1001
  177.         MOVE.B     (A0), (A1)
  178.         ADDQ.L     #3, A0
  179.         ADDQ.L     #3, A1
  180.         MOVE.B     (A0)+, (A1)+
  181.         JMP        (A3)               ; RTS
  182.     
  183.     @sub10:                           ; mask = 1010
  184.         MOVE.B     (A0), (A1)
  185.         ADDQ.L     #2, A0
  186.         ADDQ.L     #2, A1
  187.         MOVE.B     (A0), (A1)
  188.         ADDQ.L     #2, A0
  189.         ADDQ.L     #2, A1
  190.         JMP        (A3)               ; RTS
  191.     
  192.     @sub11:                           ; mask = 1011
  193.         MOVE.B     (A0), (A1)
  194.         ADDQ.L     #2, A0
  195.         ADDQ.L     #2, A1
  196.         MOVE.W     (A0)+, (A1)+
  197.         JMP        (A3)               ; RTS
  198.     
  199.     @sub12:                           ; mask = 1100
  200.         MOVE.W     (A0), (A1)
  201.         ADDQ.L     #4, A0
  202.         ADDQ.L     #4, A1
  203.         JMP        (A3)               ; RTS
  204.     
  205.     @sub13:                           ; mask = 1101
  206.         MOVE.W     (A0), (A1)
  207.         ADDQ.L     #3, A0
  208.         ADDQ.L     #3, A1
  209.         MOVE.B     (A0)+, (A1)+
  210.         JMP        (A3)               ; RTS
  211.     
  212.     @sub14:                           ; mask = 1110
  213.         MOVE.W     (A0)+, (A1)+
  214.         MOVE.B     (A0), (A1)
  215.         ADDQ.L     #2, A0
  216.         ADDQ.L     #2, A1
  217.         JMP        (A3)               ; RTS
  218.     
  219.     @sub15:                           ; mask = 1111
  220.         MOVE.L     (A0)+, (A1)+
  221.         JMP        (A3)               ; RTS
  222.     
  223.     @end:
  224.