1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
; bits.ash -- bit access for decompression
;
; This file is part of the UCL data compression library.
;
; Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
; All Rights Reserved.
;
; The UCL library is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License as
; published by the Free Software Foundation; either version 2 of
; the License, or (at your option) any later version.
;
; The UCL library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with the UCL library; see the file COPYING.
; If not, write to the Free Software Foundation, Inc.,
; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
;
; Markus F.X.J. Oberhumer
; <markus@oberhumer.com>
; http://www.oberhumer.com/opensource/ucl/
;
; ------------- ADDBITS -------------
macro(ADDBITS)
#if (NRV_BB == 8)
add.b d0,d0 ; sets Z, C and X ; 4
#elif (NRV_BB == 32)
add.l d0,d0 ; sets Z, C and X ; 6
#endif
endm
#if 0
macro(ADDXBITS)
#if (NRV_BB == 8)
addx.b d0,d0 ; sets C and X ; 4
#elif (NRV_BB == 32)
addx.l d0,d0 ; sets C and X ; 8
#endif
endm
#endif
; ------------- FILLBYTES_xx -------------
; get 1 byte; then get 1 bit into both C and X
macro(FILLBYTES_8)
; note: we shift the X flag through -> must init d0.b with $80
move.b (a0)+,d0 ; 8
addx.b d0,d0 ; sets C and X ; 4
endm
; get 32 bits in little endian format; then get 1 bit into both C and X
macro(FILLBYTES_LE32)
#if 0
move.b (a0)+,d0 ; 8
ror.l #8,d0 ; 24
move.b (a0)+,d0 ; 8
ror.l #8,d0 ; 24
move.b (a0)+,d0 ; 8
ror.l #8,d0 ; 24
move.b (a0)+,d0 ; 8
ror.l #8,d0 ; 24
add.l d0,d0 ; sets C and X ; 6
bset #0,d0 ; only changes Z ; 12
; -----
; 146
#elif 1
move.b 3(a0),d0 ; 12
lsl.w #8,d0 ; 22
move.b 2(a0),d0 ; 12
swap d0 ; 4
move.b 1(a0),d0 ; 12
lsl.w #8,d0 ; 22
move.b (a0),d0 ; 8
addq.l #4,a0 ; does not affect flags ; 8
add.l d0,d0 ; sets C and X ; 6
bset #0,d0 ; only changes Z ; 12
; -----
; 118
#else
; IMPORTANT: movep is not implemented on the 68060
# error "do not use movep"
; note: we shift the X flag through -> must init d0.l with $80000000
; note: must use dc.l because of a bug in the pasm assembler
; note: may access past the end of the input; this is ok for UPX
dc.l $01080003 ; movep.w 3(a0),d0 ; 16
move.b 2(a0),d0 ; 12
swap d0 ; 4
dc.l $01080001 ; movep.w 1(a0),d0 ; 16
move.b (a0),d0 ; 8
addq.l #4,a0 ; does not affect flags ; 8
addx.l d0,d0 ; sets C and X ; 8
; -----
; 72
#endif
endm
; ------------- FILLBITS -------------
macro(FILLBITS)
#if (NRV_BB == 8)
; no need for a subroutine
FILLBYTES_8
#elif (NRV_BB == 32)
# ifdef SMALL
# define FILLBYTES_SR FILLBYTES_LE32
bsr fillbytes_sr ; 18
# else
FILLBYTES_LE32
# endif
#endif
endm
; ------------- GETBIT -------------
; get one bit into both the Carry and eXtended flag
macro(GETBIT)
#if defined(__A68K__)
ADDBITS ; 4 / 6
bne \@ ; 10 (if jump)
FILLBITS
\@:
#elif defined(__ASL__)
ADDBITS ; 4 / 6
bne done ; 10 (if jump)
FILLBITS
done:
#else
LOCAL done
ADDBITS ; 4 / 6
bne done ; 10 (if jump)
FILLBITS
done:
#endif
endm
; vi:ts=8:et
|