📄 spack.nas
字号:
;;
;; aPLib compression library - the smaller the better :)
;;
;; NASM safe assembler wrapper for aP_pack
;;
;; Copyright (c) 1998-2002 by Joergen Ibsen / Jibz
;; All Rights Reserved
;;
; define _ELF_ for ELF32 object files
; define _OBJ_ for OMF object files
; header format:
;
; offs size data
; --------------------------------------
; 0 dword tag ('AP32')
; 4 dword header_size (24 bytes)
; 8 dword packed_size
; 12 dword packed_crc
; 16 dword orig_size
; 20 dword orig_crc
bits 32
%include "apnasm.mac"
section aptext
cglobal aPsafe_pack,20
cextern aP_pack,aP_crc32
aplabel aPsafe_pack,20
pushad
mov ebp, esp
mov esi, [ebp + 36] ; esi -> inbuffer
mov edi, [ebp + 40] ; edi -> outbuffer
mov ecx, [ebp + 44] ; ecx = length
sub eax, eax ; eax = 0
test esi, esi ; check parameters
jz short .return_eax ;
test edi, edi ;
jz short .return_eax ;
test ecx, ecx ;
jz short .return_eax ;
mov ebx, 032335041h
mov [edi], ebx ; set header.tag
mov ebx, 24
mov [edi + 4], ebx ; set header.header_size
add ebx, edi ; ebx -> destination for packed data
mov [edi + 16], ecx ; set header.orig_size
push ecx
push esi
call aP_crc32
apadjust 8 ; adjust stack (function is cdecl)
mov [edi + 20], eax ; set header.orig_crc
push dword [ebp + 52] ; callback
push dword [ebp + 48] ; workmem
push ecx ; length
push ebx ; destination
push esi ; source
call aP_pack
apadjust 20 ; adjust stack (function is cdecl)
test eax, eax
jz short .return_eax
mov [edi + 8], eax ; set header.packed_size
mov edx, eax ; edx = packed size
push eax
push ebx
call aP_crc32
apadjust 8 ; adjust stack (function is cdecl)
mov [edi + 12], eax ; set header.packed_crc
lea eax, [edx + 24] ; eax = packed size + header size
.return_eax:
mov [esp + 28], eax ; return unpacked length in eax
popad
apret 20
%ifdef _OBJ_
section apdata
%endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -