wok-next rev 13287

memtest: lzma compression
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Aug 26 00:21:22 2012 +0200 (2012-08-26)
parents b7e579c4b595
children 1d5a6d3ed1f5
files memtest/receipt memtest/stuff/pack memtest/stuff/unlzma.S syslinux/receipt
line diff
     1.1 --- a/memtest/receipt	Sat Aug 25 11:17:45 2012 +0200
     1.2 +++ b/memtest/receipt	Sun Aug 26 00:21:22 2012 +0200
     1.3 @@ -10,7 +10,7 @@
     1.4  WEB_SITE="http://www.memtest.org/"
     1.5  WGET_URL="${WEB_SITE}download/$VERSION/$TARBALL"
     1.6  
     1.7 -BUILD_DEPENDS="lz4"
     1.8 +BUILD_DEPENDS="lzma"
     1.9  
    1.10  # Rules to configure and make the package.
    1.11  compile_rules()
     2.1 --- a/memtest/stuff/pack	Sat Aug 25 11:17:45 2012 +0200
     2.2 +++ b/memtest/stuff/pack	Sun Aug 26 00:21:22 2012 +0200
     2.3 @@ -17,19 +17,17 @@
     2.4  	done | xargs echo -en | dd conv=notrunc bs=1 of=$2 seek=$3
     2.5  }
     2.6  
     2.7 -setup="$(dd bs=1 count=1 if=$1 skip=497 | hexdump -e '"" 1/1 "%d" "\n"')"
     2.8 -syssize="$(dd bs=1 count=2 if=$1 skip=500 | hexdump -e '"" 1/2 "%d" "\n"')"
     2.9 -
    2.10  compress()
    2.11  {
    2.12 -	lz4demo -c1 stdin stdout
    2.13 -	echo -en "\x00\x00\x00\x00"
    2.14 +	lzma e -si -so
    2.15  }
    2.16  
    2.17  main()
    2.18  {
    2.19  	dd if=$1 bs=512 count=1 >$2
    2.20  	uudecode | gunzip >>$2
    2.21 +	setup="$( echo $(od -j 497 -N 1 -dAn $1))"
    2.22 +	syssize="$(echo $(od -j 500 -N 2 -dAn $1))"
    2.23  	dd if=$1 bs=512 count=$setup skip=1 | compress >>$2
    2.24  	dd if=$1 bs=16 count=$syssize skip=$((32*(1+$setup))) | compress >>$2
    2.25  	size=$(stat -c %s $2)
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/memtest/stuff/unlzma.S	Sun Aug 26 00:21:22 2012 +0200
     3.3 @@ -0,0 +1,822 @@
     3.4 +// #define RC_NORMALIZE if (Range < kTopValue) { Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; }
     3.5 +//
     3.6 +// #define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound)
     3.7 +// #define UpdateBit0(p) Range = bound; *(p) += (kBitModelTotal - *(p)) >> kNumMoveBits;
     3.8 +// #define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits;
     3.9 +//
    3.10 +//#define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \
    3.11 +//  { UpdateBit0(p); mi <<= 1; A0; } else \
    3.12 +//  { UpdateBit1(p); mi = (mi + mi) + 1; A1; }
    3.13 +//
    3.14 +// #define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;)
    3.15 +//
    3.16 +// #define RangeDecoderBitTreeDecode(probs, numLevels, res) \
    3.17 +//  { int i = numLevels; res = 1; \
    3.18 +//  do { CProb *p = probs + res; RC_GET_BIT(p, res) } while(--i != 0); \
    3.19 +//  res -= (1 << numLevels); }
    3.20 +/*
    3.21 + * Compression with : lzma e src dst -eos -pb2 -lp0 -lc3
    3.22 + */
    3.23 +
    3.24 +#define PROP_PB 2
    3.25 +#define PROP_LP 0
    3.26 +#define PROP_LC 3
    3.27 +#define PROPS (PROP_LC+(PROP_LP*9)+(PROP_PB*45))
    3.28 +
    3.29 +// static const Byte *Buffer;
    3.30 +// static UInt32 bound, Code, Range;
    3.31 +
    3.32 +/*
    3.33 + * Buffer register DS:SI
    3.34 + * all var based ws=ss:bp
    3.35 + */
    3.36 +
    3.37 +rep0		=	-4		// long
    3.38 +rep1		=	rep0-4		// long
    3.39 +rep2		=	rep0-8		// long
    3.40 +rep3		=	rep0-12		// long
    3.41 +state		=	-17		// byte, 0..11
    3.42 +posState 	=	state-1		// byte, 0..15
    3.43 +posState2 	=	posState-1	// byte, 0..15
    3.44 +scratched	=	rep0-16		// byte = 1
    3.45 +Code		=	-24		// long
    3.46 +outStream	=	-28		// long
    3.47 +nowPos		=	outStream	// long
    3.48 +Range		=	Code-8		// long
    3.49 +#define LOCALS		32
    3.50 +
    3.51 +// int LzmaDecode(CLzmaDecoderState *vs,
    3.52 +//     const unsigned char *inStream, 
    3.53 +//     unsigned char *outStream)
    3.54 +// {
    3.55 +//   CProb *p = vs->Probs;
    3.56 +//   SizeT nowPos = 0;
    3.57 +//   #define posStateMask = (1 << (vs->Properties.pb)) - 1;
    3.58 +//   #define literalPosMask = (1 << (vs->Properties.lp)) - 1;
    3.59 +//   int lc = vs->Properties.lc, state = 0, len = 0;
    3.60 +//   UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
    3.61 +// 
    3.62 +//   {
    3.63 +//     UInt32 i, numProbs = Literal /*1846*/
    3.64 +// 	    + ((UInt32)LZMA_LIT_SIZE /*768*/ << (lc + vs->Properties.lp));
    3.65 +//     for (i = 0; i < numProbs; i++) p[i] = kBitModelTotal /*2048*/ >> 1;
    3.66 +
    3.67 +#define WS (1846+(768<<(PROP_LC+PROP_LP)))
    3.68 +#if (WS+WS+LOCALS) >= 65000
    3.69 +/* MAX WS = (1846+(768<<(8+4))) > 3MB! */
    3.70 +#error invalid (lc,lp,pb) : out of memory
    3.71 +#endif
    3.72 +
    3.73 +ws1	=	WS
    3.74 +ws2	=	ws1*2
    3.75 +ws	=	ws2+LOCALS+15
    3.76 +
    3.77 +#ifndef FLAT32
    3.78 +#define	AX	%ax
    3.79 +#define	BX	%bx
    3.80 +#define	CX	%cx
    3.81 +#define	DX	%dx
    3.82 +#define	SI	%si
    3.83 +#define	DI	%di
    3.84 +#define	BP	%bp
    3.85 +#define	SP	%sp
    3.86 +#define CWD	cwd
    3.87 +#else
    3.88 +#define	AX	%eax
    3.89 +#define	BX	%ebx
    3.90 +#define	CX	%ecx
    3.91 +#define	DX	%edx
    3.92 +#define	SI	%esi
    3.93 +#define	DI	%edi
    3.94 +#define	BP	%ebp
    3.95 +#define	SP	%esp
    3.96 +#define CWD	cdq
    3.97 +#endif
    3.98 +/*
    3.99 + * LzmaDecode:
   3.100 +#ifndef FLAT32
   3.101 + *   input   ds:si=inStream, es:di=outStream
   3.102 + *   output  outStream[], ds:si, es:di
   3.103 + 	.code 16
   3.104 +#else
   3.105 + *   input   esi=inStream, edi=outStream
   3.106 + *   output  outStream[], esi, edi
   3.107 + 	.code 32
   3.108 +#endif
   3.109 + */
   3.110 + 
   3.111 +	mov	$ws1, CX
   3.112 +lzd1:
   3.113 +	pushw	$2048/2
   3.114 +	loop	lzd1
   3.115 +	mov	SP, BP
   3.116 +	movb	$((LOCALS+3)/4)*2, %cl
   3.117 +initlocals:
   3.118 +	pushl	$1
   3.119 +	loop	initlocals
   3.120 +
   3.121 +#ifndef FLAT32
   3.122 +	movb	$4, %cl
   3.123 +	movw	%es, %bx
   3.124 +	shrw	%cl, %bx
   3.125 +	movw	%es, %dx
   3.126 +	shlw	%cl, %dx
   3.127 +	addw	%dx, %di
   3.128 +	movw	%di, outStream(%bp)
   3.129 +	adcb	%bh, outStream+2(%bp)
   3.130 +	incw	%cx
   3.131 +#else
   3.132 +	movb	$5, %cl
   3.133 +	movl	%edi, outStream(%ebp)
   3.134 +#endif
   3.135 +
   3.136 +//   Byte previousByte = 0;
   3.137 +	xor	BX, BX
   3.138 +
   3.139 +// #define RC_INIT(buffer) 
   3.140 +//    Buffer = buffer; Code = 0; Range = 0xFFFFFFFF; 
   3.141 +//    { int i; for(i=0; i<5; i++) { Code = (Code<<8) | RC_READ_BYTE; }}
   3.142 +//   }
   3.143 +//   RC_INIT(inStream);
   3.144 +
   3.145 +	add	$13, SI		// skip header
   3.146 +setrep:
   3.147 +	call	RC_LOAD_BYTE
   3.148 +	decb	Range(BP)
   3.149 +	loop	setrep
   3.150 +
   3.151 +lzdmainlp:
   3.152 +//   while(1) {
   3.153 +//     CProb *prob;
   3.154 +//     int posState = (int)((nowPos) & posStateMask);
   3.155 +// 
   3.156 +//     prob = p + IsMatch /*0*/ + (state << kNumPosBitsMax /*4*/) + posState;
   3.157 +//     if (Bit0(prob)) { /* char */
   3.158 +
   3.159 +	xor	DX, DX
   3.160 +	call	Bit1state	// Bit1(dx + (state << kNumPosBitsMax /*4*/) + posState)
   3.161 +	mov	$state, DI
   3.162 +	jc	lzdstring
   3.163 +
   3.164 +//       prob = p + Literal /*1846*/ + (LZMA_LIT_SIZE /*768*/ * 
   3.165 +// 	((((nowPos) & literalPosMask) << lc) + (previousByte >> (8 - lc))));
   3.166 +
   3.167 +#if PROP_LC != 0
   3.168 +	shrb	$8-PROP_LC, %bl
   3.169 +#endif
   3.170 +
   3.171 +#if PROP_LP != 0
   3.172 +	movb	posState2(BP), %dl
   3.173 +	shl	$PROP_LC, DX
   3.174 +	movb	$0, %bh
   3.175 +	add	BX, DX
   3.176 +#endif
   3.177 +
   3.178 +	movb	$3, %ah
   3.179 +	mul	BX		// dx = 3*bh
   3.180 +	add	$1846, AX
   3.181 +
   3.182 +//       int symbol = 1;
   3.183 +
   3.184 +	CWD
   3.185 +	inc	DX		// symbol = 1
   3.186 +	xchg	AX, CX		// save prob
   3.187 +
   3.188 +//       if (state >= kNumLitStates /*7*/) { /* previous was string */
   3.189 +//       if (state < 4) state = 0;
   3.190 +
   3.191 +lzd6z:
   3.192 +	subb	$3, (BP, DI)
   3.193 +
   3.194 +//       if (state < 4) state = 0;
   3.195 +
   3.196 +	jnc	lzd6
   3.197 +	movb	%dh, (BP, DI)	// %dh = 0
   3.198 +
   3.199 +lzd6:
   3.200 +//       else if (state < 10) state -= 3;
   3.201 +
   3.202 +	cmpb	$10-3, (BP, DI)
   3.203 +	
   3.204 +//       else state -= 6;
   3.205 +
   3.206 +	jnb	lzd6z
   3.207 +	cmpb	$7-3-1, (BP, DI)
   3.208 +	jbe	lzd3
   3.209 +	
   3.210 +//         int matchByte = outStream[nowPos - rep0];
   3.211 +
   3.212 +	call	DicoRep02ESDI	// %bl = outStream[nowPos - rep0];
   3.213 +	
   3.214 +//         do {
   3.215 +//           int bit;
   3.216 +//           CProb *probLit;
   3.217 +//           matchByte <<= 1; bit = (matchByte & 0x100);
   3.218 +
   3.219 +	movb	$1, %bh
   3.220 +lzd4:
   3.221 +	shlb	$1, %bl			// matchByte <<= 1
   3.222 +	sbb	DI, DI			// save bit=C
   3.223 +
   3.224 +//           probLit = prob + 0x100 + bit + symbol;
   3.225 +
   3.226 +	mov	CX, AX			// restore prob
   3.227 +	adcb	%bh, %ah		// + bit + 0x100
   3.228 +	
   3.229 +//           RC_GET_BIT2(probLit, symbol, if (bit) break, if (!bit) break)
   3.230 +
   3.231 +	call	Bit1axdx		// C,%ax = Bit1(prob+%ax)
   3.232 +	rclb	$1, %dl			// symbol <<= 1; symbol |= C
   3.233 +	jc	lzd5			// if symbol >= 0x100
   3.234 +	cmp	DI, AX
   3.235 +	jz	lzd4			// if bit == Bit1(prob+%ax)
   3.236 +
   3.237 +//         } while (symbol < 0x100);
   3.238 +//       }
   3.239 +lzd3:
   3.240 +//       while (symbol < 0x100) {
   3.241 +//         CProb *probLit = prob + symbol;
   3.242 +//         RC_GET_BIT(probLit, symbol)
   3.243 +//       }
   3.244 +
   3.245 +	xor	BX, BX
   3.246 +	jmp	lzd4
   3.247 +lzd5:
   3.248 +
   3.249 +//       outStream[nowPos++] = previousByte = (Byte)symbol;
   3.250 +
   3.251 +	xchg	AX, DX
   3.252 +	call	outchar		// %bl = outStream[nowPos++] = %al;
   3.253 +	jmp	lzdmainlp
   3.254 +
   3.255 +//     }
   3.256 +
   3.257 +lzdstring:
   3.258 +	mov	$1, CX
   3.259 +
   3.260 +//     else { /* string */
   3.261 +//       prob = p + IsRep /*192*/ + state;
   3.262 +
   3.263 +	movb	$192, %dl
   3.264 +	addb	(BP, DI), %dl
   3.265 +	mov	$rep0, DI
   3.266 +
   3.267 +//       if (Bit0(prob)) {
   3.268 +
   3.269 +	call	Bit1dx		// Bit1(prob)
   3.270 + 	jc	lzd8
   3.271 +
   3.272 +//         rep3 = rep2; rep2 = rep1; rep1 = rep0;
   3.273 +//         state = (state < kNumLitStates /*7*/) ? 0 : 3;
   3.274 +
   3.275 +	stc
   3.276 +
   3.277 +//         prob = p + LenCoder /*818*/;
   3.278 +
   3.279 +	mov	$818, DX
   3.280 +
   3.281 +//       }
   3.282 +
   3.283 +	jmp	lzd11a
   3.284 +
   3.285 +//       else {
   3.286 +lzd8:
   3.287 +//         prob += kNumStates /*12*/;
   3.288 +//         if (Bit0(prob)) {
   3.289 +	call	Bit1dx12	// prob += 12; Bit1(prob)
   3.290 +	jc	lzd11
   3.291 +//           prob = p + IsRep0Long /*240*/ + (state << kNumPosBitsMax /*4*/) 
   3.292 +// 		   + posState;
   3.293 +	movb	$240, %dl	// dh=0
   3.294 +
   3.295 +//           if (Bit0(prob)) {
   3.296 +
   3.297 +	call	Bit1state	// Bit1(dx + (state << kNumPosBitsMax /*4*/) + posState)
   3.298 +	jc	lzd12
   3.299 +
   3.300 +//             // if (nowPos == 0) return LZMA_RESULT_DATA_ERROR;
   3.301 +//             state = (state < kNumLitStates /*7*/) ? 9 : 11;
   3.302 +
   3.303 +	movb	$9, %dl
   3.304 +
   3.305 +//             len++; goto string;
   3.306 +	jmp	lzd13string	// ax = 0
   3.307 +//           }
   3.308 +//         }
   3.309 +//         else {
   3.310 +lzd11:
   3.311 +//           UInt32 distance = rep1;
   3.312 +//           prob += kNumStates /*12*/;
   3.313 +//           if (!Bit0(prob)) {
   3.314 +
   3.315 +	call	Bit1dx12	// prob += 12; Bit1(prob)
   3.316 +	jnc	lzd11z
   3.317 +
   3.318 +//             prob += kNumStates /*12*/;
   3.319 +//             if (Bit0(prob)) distance = rep2;
   3.320 +
   3.321 +	call	Bit1dx12	// prob += 12; Bit1(prob)
   3.322 +lzd11a:
   3.323 +	adcb	%cl, %cl
   3.324 +	
   3.325 +//             else { distance = rep3; rep3 = rep2; }
   3.326 +//             rep2 = rep1;
   3.327 +//           }
   3.328 +//           rep1 = rep0; rep0 = distance;
   3.329 +
   3.330 +lzd11z:
   3.331 +	shl	$2, CX		// 8->32 bits
   3.332 +	sub	CX, DI		// &rep[cx]
   3.333 +	movl	(BP, DI), %eax
   3.334 +rotreplp:
   3.335 +	movb	4(BP, DI), %bl
   3.336 +	movb	%bl, (BP, DI)
   3.337 +	inc	DI
   3.338 +	loop	rotreplp
   3.339 +	testb	%dh, %dh
   3.340 +	jnz	lzd10
   3.341 +	movl	%eax, (BP, DI)
   3.342 +
   3.343 +//         }
   3.344 +lzd12:
   3.345 +//         state = (state < kNumLitStates /*7*/) ? 8 : 11;
   3.346 +
   3.347 +	movb	$0x08, %cl
   3.348 +
   3.349 +//         prob = p + RepLenCoder /*1332*/;
   3.350 +
   3.351 +	mov	$1332, DX
   3.352 +
   3.353 +//       }
   3.354 +lzd10:
   3.355 +	push	CX		// CX = 0
   3.356 +
   3.357 +//       { /* get len */
   3.358 +//         int numBits, offset;
   3.359 +//         CProb *probLen = prob + LenChoice /*0*/;
   3.360 +//         numBits = kLenNumLowBits /*3*/;
   3.361 +
   3.362 +	movb	$8, %cl		// numBits : 3,3,8
   3.363 +
   3.364 +//         if (Bit0(probLen)) {
   3.365 +
   3.366 +	call	Bit1dx		// Bit1(prob)
   3.367 +	xchg	AX, BX
   3.368 +	inc	DX
   3.369 +	jnc	lzd15		// bx=0
   3.370 +
   3.371 +//           probLen = prob + LenLow/*2*/ + (posState << kLenNumLowBits/*3*/);
   3.372 +//           offset = 0;
   3.373 +//         }
   3.374 +//         else {
   3.375 +//           probLen = prob + LenChoice2 /*1*/;
   3.376 +
   3.377 +	call	Bit1dx		// Bit1(prob)
   3.378 +	add	AX, BX
   3.379 +
   3.380 +#if PROP_PB != 0
   3.381 +	inc	AX		// ah=0
   3.382 +#endif
   3.383 +	jc	lzd16		// %ax=0, %bx=-2 
   3.384 +lzd15:
   3.385 +#if PROP_PB != 0
   3.386 +	movb	$8, %al
   3.387 +	mulb	posState(BP)
   3.388 +#endif
   3.389 +
   3.390 +//           if (Bit0(probLen)) {
   3.391 +//             probLen = prob + LenMid/*130*/ + (posState << kLenNumMidBits/*3*/);
   3.392 +
   3.393 +	movb	$3, %cl		// numBits : 3,3,8
   3.394 +lzd16:
   3.395 +#if PROP_PB != 0
   3.396 +	add	$2-128-1, AX	// probLen : 2,130,258
   3.397 +#else
   3.398 +	mov	$2-128-1, AX	// probLen : 2,130,258
   3.399 +#endif
   3.400 +	add	DX, AX
   3.401 +	mov	$-8+1, DX	// offset  : 0,8,16
   3.402 +lzdargslp:
   3.403 +	add	$8, DX
   3.404 +	add	$128, AX
   3.405 +	inc	BX
   3.406 +	jle	lzdargslp	// leave with bx=1
   3.407 +
   3.408 +//             offset = kLenNumLowSymbols /*8*/;
   3.409 +//             //numBits = kLenNumMidBits /*3*/;
   3.410 +//           }
   3.411 +//           else {
   3.412 +//             probLen = prob + LenHigh /*258*/;
   3.413 +//             offset = kLenNumLowSymbols /*8*/ + kLenNumMidSymbols /*8*/;
   3.414 +//             numBits = kLenNumHighBits /*8*/;
   3.415 +//           }
   3.416 +//         }
   3.417 +//         RangeDecoderBitTreeDecode(probLen, numBits, len); len += offset;
   3.418 +
   3.419 +	push	DX
   3.420 +	call	RangeDecoder	// %ax=probs, %cx=numLevels, %ax=res
   3.421 +	pop	DX
   3.422 +	add	DX, AX		// offset
   3.423 +	pop	DX		// 0
   3.424 +lzd13string:
   3.425 +	push	AX
   3.426 +
   3.427 +// state = (state < kNumLitStates /*7*/) ? dl : dl|3;
   3.428 +
   3.429 +	movb	$7, %cl
   3.430 +	cmpb	%cl, state(BP)
   3.431 +	jb	new_state
   3.432 +	orb	$3, %dl
   3.433 +new_state:
   3.434 +	movb	%dl, state(BP)
   3.435 +
   3.436 +//       } /* get len */
   3.437 +//       if (state < 4) {
   3.438 +
   3.439 +	cmpb	$4-1, %dl
   3.440 +	ja	lzd19
   3.441 +
   3.442 +//         int posSlot;
   3.443 +//         state += kNumLitStates /*7*/;
   3.444 +
   3.445 +	addb	%cl, state(BP)
   3.446 +
   3.447 +//         prob = p + PosSlot /*432*/ + (((len < kNumLenToPosStates /*4*/) ? 
   3.448 +// 		len : kNumLenToPosStates - 1) << kNumPosSlotBits /*6*/);
   3.449 +
   3.450 +	cmp	$4+1, AX
   3.451 +	jb	lzd21
   3.452 +	mov	$3+1, AX
   3.453 +	//??movb	$3+1, %al
   3.454 +
   3.455 +lzd21:
   3.456 +
   3.457 +	dec	CX		// cx = 6
   3.458 +	shl	%cl, AX
   3.459 +	add	$432-64, AX
   3.460 +
   3.461 +//         RangeDecoderBitTreeDecode(prob, kNumPosSlotBits /*6*/, posSlot);
   3.462 +
   3.463 +	call	RangeDecoder	// %ax=probs, %cx=numLevels, %ax=res
   3.464 +
   3.465 +//         if (posSlot >= kStartPosModelIndex /*4*/) {
   3.466 +//           int numDirectBits = ((posSlot >> 1) - 1);
   3.467 +
   3.468 +#ifndef FLAT32
   3.469 +	movw	%cx, 2(%bp, %di)	// %cx = 0
   3.470 +#endif
   3.471 +	mov	AX, (BP, DI)
   3.472 +	mov	AX, CX
   3.473 +	shrw	$1, CX
   3.474 +	dec	CX
   3.475 +	cmpb	$4, %al
   3.476 +	jb	lzd22
   3.477 +
   3.478 +//           rep0 = (2 | ((UInt32)posSlot & 1));
   3.479 +
   3.480 +	andb	%bl, (BP, DI)		// %bx=1
   3.481 +	orb	$2, (BP, DI)
   3.482 +
   3.483 +//           if (posSlot < kEndPosModelIndex /*14*/) {
   3.484 +
   3.485 +	cmpb	$14, %al
   3.486 +	jnb	lzd23
   3.487 +
   3.488 +//             rep0 <<= numDirectBits;
   3.489 +
   3.490 +	neg	AX
   3.491 +	shll	%cl, (BP, DI)
   3.492 +	add	(BP, DI), AX
   3.493 +
   3.494 +//             prob = p + SpecPos /*688*/ + rep0 - posSlot - 1;
   3.495 +
   3.496 +	add	$687, AX
   3.497 +	jmp	lzd24
   3.498 +
   3.499 +//           }
   3.500 +//           else {
   3.501 +lzd23:
   3.502 +//             numDirectBits -= kNumAlignBits /*4*/;
   3.503 +//             do {
   3.504 +//               RC_NORMALIZE; Range >>= 1; rep0 <<= 1;
   3.505 +//               if (Code >= Range) { Code -= Range; rep0 |= 1; }
   3.506 +
   3.507 +lzd23z:
   3.508 +	call	RC_NORMALIZE
   3.509 +	shrl	$1, Range(BP)
   3.510 +	movl	Range(BP), %eax
   3.511 +	cmpl	Code(BP), %eax
   3.512 +	ja	lzd25
   3.513 +	subl	%eax, Code(BP)
   3.514 +	stc
   3.515 +lzd25:
   3.516 +	rcll	$1, (BP, DI)
   3.517 +
   3.518 +//             } while (--numDirectBits != 0);
   3.519 +
   3.520 +	cmp	$4+1, CX
   3.521 +	loopne	lzd23z
   3.522 +
   3.523 +//             prob = p + Align /* 802 */; numDirectBits = kNumAlignBits /*4*/;
   3.524 +//             rep0 <<= numDirectBits;
   3.525 +
   3.526 +	shll	%cl, (BP, DI)
   3.527 +	mov	$802, AX
   3.528 +//           }
   3.529 +
   3.530 +lzd24:
   3.531 +	call	RangeDecoder	// %ax=probs, %cx=numLevels, %ax=res
   3.532 +
   3.533 +//           {
   3.534 +//             int i = 1, mi = 1;
   3.535 +//             do {
   3.536 +//               CProb *prob3 = prob + mi;
   3.537 +//               RC_GET_BIT2(prob3, mi, ; , rep0 |= i);
   3.538 +
   3.539 +	orb	%dh, (BP, DI)	// update rep0 with DirectBits
   3.540 +
   3.541 +//               i <<= 1;
   3.542 +//             } while(--numDirectBits != 0);
   3.543 +//           }
   3.544 +//         } else rep0 = posSlot;
   3.545 +lzd22:
   3.546 +//         if (++rep0 == (UInt32)(0)) break; /* EOF */
   3.547 +
   3.548 +	incl	(BP, DI)
   3.549 +
   3.550 +lzd19:
   3.551 +	pop	CX
   3.552 +	jz	lzdone
   3.553 +
   3.554 +//       }
   3.555 +//       len += kMatchMinLen;/*2*/
   3.556 +
   3.557 +	inc	CX
   3.558 +
   3.559 +//     string: // if (rep0 > nowPos) return LZMA_RESULT_DATA_ERROR;
   3.560 +//       do {
   3.561 +lzd13z:
   3.562 +//         previousByte = outStream[nowPos - rep0];
   3.563 +//         outStream[nowPos++] = previousByte;
   3.564 +
   3.565 +	call	outcharDico 	// %bl = outStream[nowPos++] = outStream[nowPos - rep0]
   3.566 +
   3.567 +//       } while(--len != 0);
   3.568 +
   3.569 +	loop	lzd13z
   3.570 +
   3.571 +//     } /* char/string */
   3.572 +//   }
   3.573 +
   3.574 +	jmp	lzdmainlp
   3.575 +
   3.576 +lzdone:
   3.577 +//   //RC_NORMALIZE;
   3.578 +//   //*inSizeProcessed = (SizeT)(Buffer - inStream); *outSizeProcessed = nowPos;
   3.579 +//   return LZMA_RESULT_OK;
   3.580 +	call	Dico2ESDI	// set es & di (rep0 = 0)
   3.581 +	lea	ws2(BP), SP	// dealloc
   3.582 +	ret	
   3.583 +// }
   3.584 +
   3.585 +// al = outStream[nowPos - rep0];
   3.586 +
   3.587 +/*
   3.588 + * output  es:di, al
   3.589 + * scratch bh, cl, flags
   3.590 + */
   3.591 +
   3.592 +DicoRep02ESDI:
   3.593 +	stc
   3.594 +
   3.595 +// bl = outStream[nowPos];
   3.596 +
   3.597 +/*
   3.598 + * output  es:di, bl
   3.599 + * scratch bh, cl, flags
   3.600 + */
   3.601 + 
   3.602 +Dico2ESDI:
   3.603 +#ifndef FLAT32
   3.604 +	movl	nowPos(%bp), %ebx
   3.605 +	jnc	Dico2ESDIz
   3.606 +	subl	rep0(%bp), %ebx
   3.607 +Dico2ESDIz:
   3.608 +	movw	%bx, %di
   3.609 +	xorw	%bx, %bx
   3.610 +	shrl	$4, %ebx
   3.611 +	movw	%bx, %es
   3.612 +	movb	%es:(%di), %bl
   3.613 +#else
   3.614 +	movl	nowPos(%bp), %edi
   3.615 +	jnc	Dico2ESDIz
   3.616 +	subl	rep0(%bp), %edi
   3.617 +Dico2ESDIz:
   3.618 +	movb	(%edi), %bl
   3.619 +#endif
   3.620 +	ret
   3.621 +
   3.622 +outcharDico:
   3.623 +
   3.624 +// bl = outStream[nowPos++] = outStream[nowPos - rep0]
   3.625 +
   3.626 +/*
   3.627 + * output  es:di, bl
   3.628 + * update  nowPos
   3.629 + * scratch ax, dx, bh, cl, flags
   3.630 + */
   3.631 +
   3.632 +	call	DicoRep02ESDI	// %bl = outStream[nowPos - rep0]
   3.633 +	xchg	AX, BX
   3.634 +outchar:
   3.635 +
   3.636 +// bl = outStream[nowPos++] = previousByte = al;
   3.637 +
   3.638 +/*
   3.639 + * output  bl
   3.640 + * update  nowPos
   3.641 + * scratch ax, dx, bh, di, cl, flags
   3.642 + */
   3.643 +
   3.644 +	clc
   3.645 +	call	Dico2ESDI
   3.646 +	stosb
   3.647 +	xchg	AX, BX		// previous byte
   3.648 +
   3.649 +//	int posState = (int)((nowPos) & posStateMask);
   3.650 +
   3.651 +#if PROP_PB != 0 && PROP_LP != 0
   3.652 +	addw	$0x0101, posState2(BP)
   3.653 +	andb	$(((1 << PROP_PB) -1)<<8)+((1 << PROP_LP) -1), posState2(BP)
   3.654 +#else
   3.655 +# if PROP_PB != 0
   3.656 +	incb	posState(BP)
   3.657 +	andb	$((1 << PROP_PB) -1), posState(BP)
   3.658 +# endif
   3.659 +# if PROP_LP != 0
   3.660 +	incb	posState2(BP)
   3.661 +	andb	$((1 << PROP_LP) -1), posState2(BP)
   3.662 +# endif
   3.663 +#endif
   3.664 +	incl	nowPos(BP)
   3.665 +	ret
   3.666 +
   3.667 +//  
   3.668 +// #define RC_NORMALIZE if (Range < kTopValue) 
   3.669 +//    { Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; }
   3.670 +
   3.671 +/*
   3.672 + * update  Range, Code, ds:si
   3.673 + * scratch flags
   3.674 + */
   3.675 +
   3.676 +RC_NORMALIZE:
   3.677 +	cmpb	$0, Range+3(BP)
   3.678 +	jne	RC_NORMALIZE_1
   3.679 +RC_LOAD_BYTE:
   3.680 +	push	AX
   3.681 +	shll	$8, Range(BP)
   3.682 +	shll	$8, Code(BP)
   3.683 +#ifndef FLAT32
   3.684 +	testw	%si, %si
   3.685 +	jns	RC_READ_BYTE
   3.686 +	movw	%ds, %ax
   3.687 +	incw	%ax
   3.688 +	movw	%ax, %ds
   3.689 +	addw	$-16, %si
   3.690 +RC_READ_BYTE:
   3.691 +#endif
   3.692 +	lodsb
   3.693 +	movb	%al, Code(BP)
   3.694 +	pop	AX
   3.695 +RC_NORMALIZE_1:
   3.696 +	ret
   3.697 +
   3.698 +// Bit1(dx + (state << kNumPosBitsMax /*4*/) + posState)
   3.699 +
   3.700 +Bit1state:
   3.701 +	movb	$16, %al
   3.702 +	mulb	state(BP)
   3.703 +# if PROP_PB != 0
   3.704 +	addb	posState(BP), %al
   3.705 +# endif
   3.706 +Bit1axdx:
   3.707 +	add	DX, AX
   3.708 +	jmp	Bit1
   3.709 +
   3.710 +// prob += 12; Bit1(prob)
   3.711 +
   3.712 +Bit1dx12:
   3.713 +	add	$12, DX
   3.714 +Bit1dx:
   3.715 +	mov	DX, AX
   3.716 +
   3.717 +// static int Bit1(CProb *p)
   3.718 +
   3.719 +Bit1:
   3.720 +/*
   3.721 + * input   ax=p
   3.722 + * output  C, ax
   3.723 + * update  bound, Range, Code, ds:si
   3.724 + * scratch flags
   3.725 + */
   3.726 + 
   3.727 +// {
   3.728 +// 	RC_NORMALIZE;
   3.729 +
   3.730 +	call  RC_NORMALIZE		// kill %ax, update %si
   3.731 +
   3.732 +	pushal		// FIXME pushaw?
   3.733 +
   3.734 +	xchg	AX, DI
   3.735 +	add	DI, DI			// short *
   3.736 +	
   3.737 +
   3.738 +// 	bound = (Range>>kNumBitModelTotalBits /*11*/) * *(p);
   3.739 +
   3.740 +	movl	Range(BP), %eax
   3.741 +	shrl	$11, %eax
   3.742 +	movzwl	(BP, DI), %edx
   3.743 +	mull	%edx
   3.744 +
   3.745 +// 	if (Code < bound) {
   3.746 +
   3.747 +	cmpl	Code(BP), %eax
   3.748 +	jbe	Bit1_1
   3.749 +
   3.750 +//    		Range = bound;
   3.751 +
   3.752 +	movl	%eax, Range(BP)
   3.753 +
   3.754 +// 		*(p) += (kBitModelTotal /*2048*/ - *(p)) >> kNumMoveBits /*5*/;
   3.755 +
   3.756 +	movw	$2048, %ax
   3.757 +
   3.758 +// 		return 0;
   3.759 +
   3.760 +	jmp	Bit1_2
   3.761 +
   3.762 +//	}
   3.763 +// 	else {
   3.764 +
   3.765 +Bit1_1:
   3.766 +
   3.767 +//    		Range -= bound; Code -= bound;
   3.768 +
   3.769 +	subl	%eax, Range(BP)
   3.770 +	subl	%eax, Code(BP)
   3.771 +
   3.772 +// 		*(p) -= (*(p)) >> kNumMoveBits /*5*/;
   3.773 +
   3.774 +	movw	$31, %ax
   3.775 +
   3.776 +// 		return 1;
   3.777 +
   3.778 +	stc
   3.779 +Bit1_2:
   3.780 +	pushf
   3.781 +	subw	(BP, DI), %ax
   3.782 +	sarw	$5, %ax
   3.783 +	addw	%ax, (BP, DI)
   3.784 +	popf
   3.785 +	popal		// FIXME popaw?
   3.786 +	sbb	AX, AX
   3.787 +
   3.788 +// 	}
   3.789 +// }
   3.790 +
   3.791 +	ret
   3.792 +
   3.793 +RangeDecoder:
   3.794 +
   3.795 +/*
   3.796 + * input   ax=probs cx=numLevels (< 8) bx=1
   3.797 + * output  ax=res (backward), dh (forward)
   3.798 + * update  bound, Range, Code, ds:si
   3.799 + * scratch flags, cx=0, dl
   3.800 + */
   3.801 + 
   3.802 +	push	BX
   3.803 +	
   3.804 +//   { int i = numLevels; res = 1; 
   3.805 +	mov	BX, DX		// res = 1
   3.806 +	
   3.807 +//   do { CProb *p = probs + res; RC_GET_BIT(p, res) } while(--i != 0); 
   3.808 +
   3.809 +RangeDecoder_1:
   3.810 +	push	AX
   3.811 +	call	Bit1axdx		// C,%ax = Bit1(prob+%ax)
   3.812 +	rclb	$1, %dl			// res <<= 1; res |= C
   3.813 +	andb	%bl, %al		// current bit
   3.814 +	orb	%al, %bh		// store in bh
   3.815 +	shlb	$1, %bl			// update max
   3.816 +	pop	AX
   3.817 +	loop	RangeDecoder_1
   3.818 +
   3.819 +//   res -= (1 << numLevels); }
   3.820 +
   3.821 +	xchg	AX, BX			// move bh to dh
   3.822 +	xchg	AX, DX			// and dl to al
   3.823 +	sub	%dl, %al		// sub max
   3.824 +	pop	BX
   3.825 +	ret
     4.1 --- a/syslinux/receipt	Sat Aug 25 11:17:45 2012 +0200
     4.2 +++ b/syslinux/receipt	Sun Aug 26 00:21:22 2012 +0200
     4.3 @@ -48,6 +48,7 @@
     4.4  	        [ -e $src/$i.kbd ] || continue
     4.5  		cat >> $fs/boot/isolinux/i18n.cfg <<EOT
     4.6  
     4.7 +# ${kbd/,/.kbd or }.kbd keyboard
     4.8  LABEL $label
     4.9  	MENU LABEL $menu
    4.10  	com32 c32box.c32