컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴[jqencode.asm]컴
;
;JQENCODE.ASM - Supertiny/fast Compression/Encryption library - Compressor
;(c) 1998 by Jacky Qwerty/29A.
;

.386p

include jqcoding.inc

_text           segment byte use32 public 'CODE'
                assume cs:_text, ds:_text, ss:_text

;unsigned long
;__stdcall
;jq_encode(void          *out,          /* output stream ptr */
;          const void    *in,           /* input stream ptr */
;          unsigned long  in_len,       /* input stream length */
;          void          *mem64k);      /* work mem ptr */

jq_encode       proc
                sub     edx, edx
                xchg    eax, edx
                pushad
                mov     ebp, esp
                and     ecx, eax
                mov     edi, [_mem64k + ebp]
                cld
                mov     ch, (SizeOf_Mem / 4) / 256
                push    edi
                rep     stosd
                sub     edx, invalid_state
                mov     esi, [_in + ebp]
                .if     zero?
                  dec     edx
                .endif
                push    ecx
                sub     ax, 0AEB6h
                mov     edi, [_out + ebp]
                pop     ebx
                stosw
                xchg    eax, edx
                pop     ebp
                stosd
                push    edi
                xchg    eax, edx
                push    esp
                .repeat
                  test    cl, 7
                  lodsb
                  .if     zero?
                    xchg    edx, [esp]
                    adc     ah, dl
                    pop     edx
                    xchg    edi, [esp]
                    ror     edx, 1
                    mov     [edi], ah
                    .if     !carry?
                      xor     edx, mask0 xor mask1
                    .endif
                    pop     edi
                    mov     ah, 0FFh
                    push    edi
                    xor     edx, mask1
                    inc     edi
                    push    edx
                  .endif
                  _mem64k equ <ebp>
                  cmp     al, [_mem64k + ebx]
                  .if     !zero?
                    ror     edx, 1
                    mov     [_mem64k + ebx], al
                    .if     carry?
                      xor     edx, mask0 xor mask1
                    .endif
                    mov     bh, al
                    xor     edx, mask0
                    adc     al, dl
                    stosb
                    mov     al, bh
                    stc
                  .endif
                  inc     ecx
                  mov     bh, bl
                  rcl     ah, 1
                  cmp     ecx, [_in_len + (2 * _Pushed) + esp]
                  mov     bl, al
                .until  !carry?
                ror     ah, cl
                pop     ebx
                add     ah, bl
                pop     esi
                mov     ebp, esp
                sub     edi, [_out + ebp]
                mov     [_Pushad._edx + ebp], edx
                xchg    [esi], ah
                add     [_Pushad._eax + ebp], edi
                popad
                ret     (_Args * _Pushed)
jq_encode       endp
                public  jq_encode

_text           ends

                end
컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴[jqencode.asm]컴
컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴[jqdecode.asm]컴
;
;JQDECODE.ASM - Supertiny/fast Compression/Encryption library - Decompressor
;(c) 1998 by Jacky Qwerty/29A.
;

.386p

include jqcoding.inc

_text           segment byte use32 public 'CODE'
                assume cs:_text, ds:_text, ss:_text

;unsigned long
;__stdcall
;jq_decode(void          *out,          /* output stream ptr */
;          const void    *in,           /* input stream ptr */
;          unsigned long  in_len,       /* input stream length */
;          void          *mem64k);      /* work mem ptr */

jq_decode       proc
                sub     eax, eax
                pushad
                mov     ebp, esp
                and     ecx, eax
                mov     edi, [_mem64k + ebp]
                cld
                mov     ch, (SizeOf_Mem / 4) / 256
                push    edi
                rep     stosd
                mov     esi, [_in + ebp]
                xchg    ebx, eax
                add     ecx, [_in_len + ebp]
                lodsw
                mov     edi, [_out + ebp]
                add     ecx,-6
                pop     ebp
                lodsd
                xchg    edx, eax
                .repeat
                  test    byte ptr [_Pushad._eax + esp], 7
                  .if     zero?
                    ror     edx, 1
                    jecxz   L0_jq_decode
                    .if     carry?
                      xor     edx, mask0 xor mask1
                    .endif
                    lodsb
                    dec     ecx
                    xor     edx, mask0
                    sbb     al, dl
                    mov     ah, al
                  .endif
                  shl     ah, 1
                  inc     byte ptr [_Pushad._eax + esp]
                  .if     carry?
                    ror     edx, 1
                    jecxz   L0_jq_decode
                    .if     !carry?
                      xor     edx, mask0 xor mask1
                    .endif
                    lodsb
                    dec     ecx
                    xor     edx, mask1
                    sbb     al, dl
                    _mem64k equ <ebp>
                    mov     [_mem64k + ebx], al
                  .endif
                  mov     al, [_mem64k + ebx]
                  mov     bh, bl
                  stosb
                  mov     bl, al
                .until  0
                dec     edx
                push    ecx
              L0_jq_decode:
                sub     edi, [_out + esp]
                mov     [_Pushad._eax + esp], edi
                popad
                ret     (_Args * _Pushed)
jq_decode       endp
                public  jq_decode

_text           ends

                end
컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴[jqdecode.asm]컴
컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴[jqcoding.asm]컴
;
;JQCODING.ASM - Superfast/Supertiny Compression/Encryption library.
;(c) 1998 by Jacky Qwerty/29A.
;

jq_encode:      sub     edx, edx                ;Encoder/Encryptor
                xchg    eax, edx
                pushad
                mov     ebp, esp
                and     ecx, eax
                mov     edi, [ebp+30h]
                cld
                mov     ch, 40h
                push    edi
                rep     stosd
                sub     edx, 2864E25Ch
                mov     esi, [ebp+28h]
                jnz     jq_e0
                dec     edx
         jq_e0: push    ecx
                sub     ax, 0AEB6h
                mov     edi, [ebp+24h]
                pop     ebx
                stosw
                xchg    eax, edx
                pop     ebp
                stosd
                push    edi
                xchg    eax, edx
                push    esp
         jq_e1: test    cl, 7
                lodsb
                jnz     jq_e3
                xchg    edx, [esp]
                adc     ah, dl
                pop     edx
                xchg    edi, [esp]
                ror     edx, 1
                mov     [edi], ah
                jc      jq_e2
                xor     edx, 2C047C3Eh
         jq_e2: pop     edi
                mov     ah, 0FFh
                push    edi
                xor     edx, 76C52B8Dh
                inc     edi
                push    edx
         jq_e3: cmp     al, [ebx+ebp]
                jz      jq_e5
                ror     edx, 1
                mov     [ebx+ebp], al
                jnc     jq_e4
                xor     edx, 2C047C3Eh
         jq_e4: mov     bh, al
                xor     edx, 5AC157B3h
                adc     al, dl
                stosb
                mov     al, bh
                stc
         jq_e5: inc     ecx
                mov     bh, bl
                rcl     ah, 1
                cmp     ecx, [esp+34h]
                mov     bl, al
                jc      jq_e1
                ror     ah, cl
                pop     ebx
                add     ah, bl
                pop     esi
                mov     ebp, esp
                sub     edi, [ebp+24h]
                mov     [ebp+14h], edx
                xchg    ah, [esi]
                add     [ebp+1Ch], edi
                popad
                ret     10h

jq_decode:      sub     eax, eax                ;Decoder/Decryptor
                pushad
                mov     ebp, esp
                and     ecx, eax
                mov     edi, [ebp+30h]
                cld
                mov     ch, 40h
                push    edi
                rep     stosd
                mov     esi, [ebp+28h]
                xchg    ebx, eax
                add     ecx, [ebp+2Ch]
                lodsw
                mov     edi, [ebp+24h]
                add     ecx,-6
                pop     ebp
                lodsd
                xchg    eax, edx
         jq_d0: test    byte ptr [esp+1Ch], 7
                jnz     jq_d2
                ror     edx, 1
                jecxz   jq_d5
                jnc     jq_d1
                xor     edx, 2C047C3Eh
         jq_d1: lodsb
                dec     ecx
                xor     edx, 5AC157B3h
                sbb     al, dl
                mov     ah, al
         jq_d2: shl     ah, 1
                inc     byte ptr [esp+1Ch]
                jnc     jq_d4
                ror     edx, 1
                jecxz   jq_d5
                jc      jq_d3
                xor     edx, 2C047C3Eh
         jq_d3: lodsb
                dec     ecx
                xor     edx, 76C52B8Dh
                sbb     al, dl
                mov     [ebx+ebp], al
         jq_d4: mov     al, [ebx+ebp]
                mov     bh, bl
                stosb
                mov     bl, al
                jmp     jq_d0
                dec     edx
                push    ecx
         jq_d5: sub     edi, [esp+24h]
                mov     [esp+1Ch], edi
                popad
                ret     10h
컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴[jqcoding.asm]컴
컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴[jqcoding.inc]컴
;
;JQCODING.INC - Supertiny/fast Compression/Encryption library - ASM include
;(c) 1998 by Jacky Qwerty/29A.
;

SizeOf_Mem      equ     10000h  ;64Kb

ifndef mask0
  mask0         equ     5AC157B3h
endif
ifndef mask1
  mask1         equ     76C52B8Dh
endif

invalid_state   equ     2864E25Ch

_Pushed_ret     equ     4
_Pushed         equ     4

_Pushad struc
        _edi    dd      ?
        _esi    dd      ?
        _ebp    dd      ?
        _esp    dd      ?
        _ebx    dd      ?
        _edx    dd      ?
        _ecx    dd      ?
        _eax    dd      ?
_Pushad ends

_out            equ     <_Pushed_ret + size _Pushad +  0>
_in             equ     <_Pushed_ret + size _Pushad +  4>
_in_len         equ     <_Pushed_ret + size _Pushad +  8>
_mem64k         equ     <_Pushed_ret + size _Pushad + 12>

_Args           equ     4

jq_encode       equ     <_jq_encode@16>
jq_decode       equ     <_jq_decode@16>
컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴[jqcoding.inc]컴
컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴[jqcoding.h]컴
/*
 JQCODING.H - Supertiny/fast Compression/Encryption library - C/C++ header
 (c) 1998 by Jacky Qwerty/29A.
 */

unsigned long
__stdcall
jq_encode(void          *out,           /* output stream ptr */
          const void    *in,            /* input stream ptr */
          unsigned long  in_len,        /* input stream length */
          void          *mem64k);       /* work mem ptr */

unsigned long
__stdcall
jq_decode(void          *out,           /* output stream ptr */
          const void    *in,            /* input stream ptr */
          unsigned long  in_len,        /* input stream length */
          void          *mem64k);       /* work mem ptr */
컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴[jqcoding.h]컴
