lzma for dos/exe works!
This commit is contained in:
@@ -58,9 +58,11 @@ typedef unsigned short hsize_t;
|
|||||||
|
|
||||||
// pia - pointer add
|
// pia - pointer add
|
||||||
hptr __cdecl pia(hptr a, hsize_t d) { return a + d; }
|
hptr __cdecl pia(hptr a, hsize_t d) { return a + d; }
|
||||||
|
hptr __cdecl pia1(hptr a) { return a + 1; }
|
||||||
|
|
||||||
// pis - pointer subtract
|
// pis - pointer subtract
|
||||||
hptr __cdecl pis(hptr a, hsize_t d) { return a - d; }
|
hptr __cdecl pis(hptr a, hsize_t d) { return a - d; }
|
||||||
|
hptr __cdecl pis1(hptr a) { return a - 1; }
|
||||||
|
|
||||||
// pts - pointer diff
|
// pts - pointer diff
|
||||||
hptrdiff_t __cdecl pts(hptr a, hptr b) { return a - b; }
|
hptrdiff_t __cdecl pts(hptr a, hptr b) { return a - b; }
|
||||||
@@ -85,10 +87,17 @@ int16_t __cdecl i2m(int16_t a, int16_t b) { return a * b; }
|
|||||||
uint32_t __cdecl u2m4(uint16_t a, uint16_t b) { return a * b; }
|
uint32_t __cdecl u2m4(uint16_t a, uint16_t b) { return a * b; }
|
||||||
int32_t __cdecl i2m4(int16_t a, int16_t b) { return a * b; }
|
int32_t __cdecl i2m4(int16_t a, int16_t b) { return a * b; }
|
||||||
|
|
||||||
|
uint16_t __cdecl u2shl8 (uint16_t a) { return a << 8; }
|
||||||
|
uint32_t __cdecl u4shl8 (uint32_t a) { return a << 8; }
|
||||||
uint16_t __cdecl u2shl12(uint16_t a) { return a << 12; }
|
uint16_t __cdecl u2shl12(uint16_t a) { return a << 12; }
|
||||||
uint32_t __cdecl u4shl14(uint32_t a) { return a << 12; }
|
uint32_t __cdecl u4shl12(uint32_t a) { return a << 12; }
|
||||||
|
uint32_t __cdecl u4shl16(uint32_t a) { return a << 16; }
|
||||||
|
uint32_t __cdecl u4shl24(uint32_t a) { return a << 24; }
|
||||||
uint16_t __cdecl u2shlv(uint16_t a, unsigned v) { return a << v; }
|
uint16_t __cdecl u2shlv(uint16_t a, unsigned v) { return a << v; }
|
||||||
uint32_t __cdecl u4shlv(uint32_t a, unsigned v) { return a << v; }
|
uint32_t __cdecl u4shlv(uint32_t a, unsigned v) { return a << v; }
|
||||||
|
|
||||||
|
hptrdiff_t __cdecl hptr2int(hptr a) { return (hptrdiff_t) a; }
|
||||||
|
hptr __cdecl int2hptr(hptrdiff_t a) { return (hptr) a; }
|
||||||
|
|
||||||
|
|
||||||
/* vim:set ts=4 et: */
|
/* vim:set ts=4 et: */
|
||||||
|
|||||||
@@ -223,8 +223,8 @@ def main(argv):
|
|||||||
continue
|
continue
|
||||||
#
|
#
|
||||||
if inst in [
|
if inst in [
|
||||||
"call", "ja", "jae", "jb", "jbe", "jcxz",
|
"call", "ja", "jae", "jb", "jbe", "jcxz", "je",
|
||||||
"je", "jge", "jl", "jmp", "jne", "loop",
|
"jg", "jge", "jl", "jle", "jmp", "jne", "loop",
|
||||||
]:
|
]:
|
||||||
k, v = parse_label(inst, args)
|
k, v = parse_label(inst, args)
|
||||||
olines[i][2] = None
|
olines[i][2] = None
|
||||||
|
|||||||
+107
-29
@@ -38,6 +38,56 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
// override generic macros with special versions
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
// huge pointer diff: dx:ax = dx:ax - cx:bx
|
||||||
|
// !!! this version does nothing !!!
|
||||||
|
.macro M_WCC_PTS_lzma
|
||||||
|
.endm
|
||||||
|
|
||||||
|
#define M_WCC_PTS M_WCC_PTS_lzma
|
||||||
|
|
||||||
|
|
||||||
|
// huge pointer compare: set zero and carry flags: dx:ax cmp cx:bx
|
||||||
|
// !!! this version does not normalize pointers !!!
|
||||||
|
.macro M_WCC_PTC_lzma
|
||||||
|
local L1
|
||||||
|
cmp dx, cx
|
||||||
|
jnes L1
|
||||||
|
cmp ax, bx
|
||||||
|
L1:
|
||||||
|
.endm
|
||||||
|
|
||||||
|
#define M_WCC_PTC M_WCC_PTC_lzma
|
||||||
|
|
||||||
|
|
||||||
|
// umul32: dx:ax = dx:ax * 00:bx
|
||||||
|
.macro M_WCC_U4M_dxax_00bx
|
||||||
|
// mult high-word
|
||||||
|
xchg cx, ax // cx: save ax
|
||||||
|
xchg ax, dx
|
||||||
|
mul bx
|
||||||
|
xchg ax, cx // save high-word result, get orig ax
|
||||||
|
// mult low-word
|
||||||
|
mul bx // dx:ax := ax * bx
|
||||||
|
// add high-word
|
||||||
|
add dx, cx // add high-word result
|
||||||
|
.endm
|
||||||
|
|
||||||
|
// umul32: dx:ax = ax:cx * 00:bx
|
||||||
|
.macro M_WCC_U4M_axcx_00bx
|
||||||
|
// mult high-word
|
||||||
|
mul bx
|
||||||
|
xchg ax, cx // save high-word result, get low
|
||||||
|
// mult low-word
|
||||||
|
mul bx
|
||||||
|
// add high-word
|
||||||
|
add dx, cx // add high-word result
|
||||||
|
.endm
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// support code (see cleanasm.py)
|
// support code (see cleanasm.py)
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
@@ -51,26 +101,42 @@ __PIA_V04:
|
|||||||
mov WORD PTR [bp-4],dx
|
mov WORD PTR [bp-4],dx
|
||||||
__PIA_V03:
|
__PIA_V03:
|
||||||
mov ax,WORD PTR [bp-12]
|
mov ax,WORD PTR [bp-12]
|
||||||
// FIXME: need optimized version here
|
|
||||||
movw dx,ds
|
movw dx,ds
|
||||||
|
#if 0
|
||||||
mov bx,0x1
|
mov bx,0x1
|
||||||
xor cx,cx
|
xor cx,cx
|
||||||
M_WCC_PIA
|
M_WCC_PIA
|
||||||
mov WORD PTR [bp-12],ax
|
mov WORD PTR [bp-12],ax
|
||||||
movw ds,dx
|
movw ds,dx
|
||||||
|
#else
|
||||||
|
// optimized version
|
||||||
|
inc ax
|
||||||
|
jnes .L1
|
||||||
|
add dh, (__AHINCR >> 8)
|
||||||
|
movw ds, dx
|
||||||
|
.L1:
|
||||||
|
mov WORD PTR [bp-12],ax
|
||||||
|
#endif
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
#if 1
|
.macro M_WCC_PIA_V02_lzma
|
||||||
.macro lzma_WCC_PIA_V02
|
movw dx, ds
|
||||||
// FIXME: need optimized version here
|
#if 0
|
||||||
movw dx,ds
|
|
||||||
mov bx,0x1
|
mov bx,0x1
|
||||||
xor cx,cx
|
xor cx,cx
|
||||||
M_WCC_PIA
|
M_WCC_PIA
|
||||||
.endm
|
#else
|
||||||
#define WCC_PIA_V02 lzma_WCC_PIA_V02
|
// optimized version
|
||||||
|
local L1
|
||||||
|
inc ax
|
||||||
|
jnes L1
|
||||||
|
add dh, (__AHINCR >> 8)
|
||||||
|
movw ds, dx
|
||||||
|
L1:
|
||||||
#endif
|
#endif
|
||||||
|
.endm
|
||||||
|
#define WCC_PIA_V02 M_WCC_PIA_V02_lzma
|
||||||
|
|
||||||
|
|
||||||
__PIA:
|
__PIA:
|
||||||
@@ -88,30 +154,35 @@ __PTC:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
// FIXME: do we actually need the PTS result ??
|
|
||||||
#define WCC_PTS M_WCC_PTS
|
#define WCC_PTS M_WCC_PTS
|
||||||
#else
|
|
||||||
#define WCC_PTS xor ax,ax; xor dx,dx
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
__U4M_V02:
|
__U4M_V02:
|
||||||
|
#if 0
|
||||||
mov bx,WORD PTR es:[bx]
|
mov bx,WORD PTR es:[bx]
|
||||||
mov ax,WORD PTR [bp-102]
|
mov ax,WORD PTR [bp-102]
|
||||||
mov dx,WORD PTR [bp-100]
|
mov dx,WORD PTR [bp-100]
|
||||||
// FIXME: need optimized version here (cx = 0)
|
|
||||||
xor cx,cx
|
xor cx,cx
|
||||||
M_WCC_U4M
|
M_WCC_U4M
|
||||||
|
#else
|
||||||
|
// optimized version
|
||||||
|
mov bx,WORD PTR es:[bx]
|
||||||
|
mov cx,WORD PTR [bp-102]
|
||||||
|
mov ax,WORD PTR [bp-100]
|
||||||
|
M_WCC_U4M_axcx_00bx
|
||||||
|
#endif
|
||||||
mov WORD PTR [bp-10],ax
|
mov WORD PTR [bp-10],ax
|
||||||
mov WORD PTR [bp-6],dx
|
mov WORD PTR [bp-6],dx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
__U4M_V01:
|
__U4M_V01:
|
||||||
// FIXME: need optimized version here (cx = 0)
|
#if 0
|
||||||
xor cx,cx
|
xor cx,cx
|
||||||
M_WCC_U4M
|
M_WCC_U4M
|
||||||
|
#else
|
||||||
|
M_WCC_U4M_dxax_00bx
|
||||||
|
#endif
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@@ -119,39 +190,42 @@ __U4M_V01:
|
|||||||
//
|
//
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
// init
|
// init
|
||||||
section LZMA_DEC00
|
section LZMA_DEC00
|
||||||
// .byte 0xcc
|
// .byte 0xcc
|
||||||
mov bp, sp
|
mov bp, sp
|
||||||
lea bx, [bp + lzma_stack_adjust]
|
lea bx, [bp + lzma_stack_adjust]
|
||||||
|
#if 0
|
||||||
xor ax, ax
|
xor ax, ax
|
||||||
.clearstack:
|
.clearstack:
|
||||||
push ax
|
push ax
|
||||||
cmp sp, bx
|
cmp sp, bx
|
||||||
jnz .clearstack
|
jnz .clearstack
|
||||||
|
#else
|
||||||
|
mov sp, bx
|
||||||
|
#endif
|
||||||
|
|
||||||
inc si
|
inc si
|
||||||
inc si
|
inc si
|
||||||
|
|
||||||
push ss // outSizeProcessed
|
push ss // &outSizeProcessed
|
||||||
push bx
|
push bx
|
||||||
mov ax, offset lzma_u_len_hi
|
mov ax, offset lzma_u_len_hi // outSize
|
||||||
push ax
|
push ax
|
||||||
mov ax, offset lzma_u_len
|
mov ax, offset lzma_u_len
|
||||||
push ax // outSize
|
push ax
|
||||||
push es
|
push es // out
|
||||||
push di // out
|
push di
|
||||||
|
|
||||||
add bx, 4
|
add bx, 4
|
||||||
push ss // inSizeProcessed
|
push ss // &inSizeProcessed
|
||||||
push bx
|
push bx
|
||||||
mov ax, offset lzma_c_len_hi
|
mov ax, offset lzma_c_len_hi // inSize
|
||||||
push ax
|
push ax
|
||||||
mov ax, offset lzma_c_len
|
mov ax, offset lzma_c_len
|
||||||
push ax // inSize
|
push ax
|
||||||
push ds
|
push ds // in
|
||||||
push si // in
|
push si
|
||||||
|
|
||||||
add bx, 4
|
add bx, 4
|
||||||
push ss
|
push ss
|
||||||
@@ -160,23 +234,23 @@ section LZMA_DEC00
|
|||||||
mov ss:[bx + 2], ax
|
mov ss:[bx + 2], ax
|
||||||
mov ax, offset lzma_properties
|
mov ax, offset lzma_properties
|
||||||
mov ss:[bx], ax
|
mov ss:[bx], ax
|
||||||
call LZMA_DEC10
|
|
||||||
// .byte 0xcc
|
|
||||||
|
|
||||||
mov sp, bp
|
call LZMA_DEC10
|
||||||
jmp LZMA_DEC30
|
jmp LZMA_DEC30
|
||||||
|
|
||||||
|
|
||||||
section LZMA_DEC10
|
section LZMA_DEC10
|
||||||
.arch i8086, nojumps
|
.arch i8086, nojumps
|
||||||
#include "lzma_d_cs.S"
|
#include "lzma_d_cs.S"
|
||||||
section LZMA_DEC20
|
section LZMA_DEC20
|
||||||
.arch i8086, nojumps
|
.arch i8086, nojumps
|
||||||
#include "lzma_d_cf.S"
|
#include "lzma_d_cf.S"
|
||||||
|
|
||||||
.arch i8086, jumps
|
.arch i8086, jumps
|
||||||
|
|
||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
section LZMA_DEC30
|
section LZMA_DEC30
|
||||||
|
mov sp, bp
|
||||||
mov di, offset lzma_u_len
|
mov di, offset lzma_u_len
|
||||||
|
|
||||||
section LZMA_DEC31
|
section LZMA_DEC31
|
||||||
@@ -186,6 +260,10 @@ section LZMA_DEC31
|
|||||||
mov es, ax
|
mov es, ax
|
||||||
|
|
||||||
|
|
||||||
|
#undef M_WCC_PTS
|
||||||
|
#undef M_WCC_PTC
|
||||||
|
#undef M_WCC_U4M
|
||||||
|
|
||||||
#undef WCC_PIA_V02
|
#undef WCC_PIA_V02
|
||||||
#undef WCC_PTS
|
#undef WCC_PTS
|
||||||
|
|
||||||
|
|||||||
@@ -149,6 +149,7 @@
|
|||||||
.endm
|
.endm
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
// huge pointer sub: dx:ax = dx:ax - cx:bx
|
// huge pointer sub: dx:ax = dx:ax - cx:bx
|
||||||
.macro M_WCC_PIS
|
.macro M_WCC_PIS
|
||||||
sub ax, bx
|
sub ax, bx
|
||||||
@@ -158,8 +159,10 @@
|
|||||||
shl bx, cl
|
shl bx, cl
|
||||||
sub dx, bx
|
sub dx, bx
|
||||||
.endm
|
.endm
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
// huge pointer diff: dx:ax = dx:ax - cx:bx
|
// huge pointer diff: dx:ax = dx:ax - cx:bx
|
||||||
.macro M_WCC_PTS
|
.macro M_WCC_PTS
|
||||||
// normalize
|
// normalize
|
||||||
@@ -168,6 +171,7 @@
|
|||||||
sub ax, bx
|
sub ax, bx
|
||||||
sbb dx, cx
|
sbb dx, cx
|
||||||
.endm
|
.endm
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@@ -180,19 +184,17 @@
|
|||||||
cmp ax, bx
|
cmp ax, bx
|
||||||
L1:
|
L1:
|
||||||
.endm
|
.endm
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
// umul32: dx:ax = dx:ax * cx:bx
|
// umul32: dx:ax = dx:ax * cx:bx
|
||||||
.macro M_WCC_U4M
|
.macro M_WCC_U4M
|
||||||
// FIXME
|
// FIXME
|
||||||
// compute high-word
|
|
||||||
// add low-word
|
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
#else
|
|
||||||
# include "tainted.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
; =============
|
; =============
|
||||||
; ============= 16-BIT CALLTRICK & JUMPTRICK
|
; ============= 16-BIT CALLTRICK & JUMPTRICK
|
||||||
|
|||||||
Reference in New Issue
Block a user