flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > DOS > tiny .ZIP viewers (122 and 254 bytes)

Goto page Previous  1, 2

Is this useless?
yes
27%
 27%  [ 6 ]
no
54%
 54%  [ 12 ]
kinda sorta
18%
 18%  [ 4 ]
it ain't gfx oriented enough!
0%
 0%  [ 0 ]
Total Votes : 22

Author
Thread Post new topic Reply to topic
rugxulo



Joined: 09 Aug 2005
Posts: 2112
Location: Usono (aka, USA)
ATV, are your changes (e.g., 106-byte version) public domain? GPL? Just curious. BTW, I'm not necessarily trying to avoid using your optimizations, but I'm just somewhat busy with other things.

I've now written a (buggy) 249-byte .LZH viewer, BUT it doesn't handle dirs plus I need to really handle header #2, LHA/Unix, etc ... in other words, I wrote it based on incorrect/outdated info and should *hopefully* correct it ... eventually (??). (But, it kinda sorta works ... doh).

<EDIT #2>

BTW, I've noticed that .LZHs (usually?) have smaller headers than .ZIPs, and are thus better for storing smaller files. -lh5- didn't compress the 249-byte .COM at all, but -lh1- (i.e., lha m -o lc02 lc02.com) compressed the .COM by five bytes (and the resulting .LZH was eight bytes smaller, too!). Plus, Gmail won't whine about executables in .LZH files (as it will with .ZIPs or even .ZIPs in .ZIPs). Also, ZOO and LZH are both based upon AR002 and hence often produce identical compressed data. So, just as you could probably convert .GZ <-> .ZIP without decompressing, you could probably do the same w/ .LZH <-> .ZOO. Just FYI.

In my original C02.ASM, I incorrectly assumed zero-byte files were always directories (usually true but not always). I've now fixed that. Razz

P.S. Even though data descriptor is somewhat rare, it seems Java .JAR files are really .ZIPs, and they seem to (almost) always use the data descriptor bit. Here's an example (jlha.jar) and here's a comp.compression thread about a supposed proper way to read .ZIP files.
</EDIT>


Last edited by rugxulo on 18 Jul 2007, 23:09; edited 5 times in total
Post 10 Nov 2006, 17:37
View user's profile Send private message Visit poster's website Reply with quote
ATV



Joined: 31 Aug 2004
Posts: 109
Location: Finland
rugxulo, my code is free to use. So go ahead and copy paste if you find something useful, but there is not any big secrets inside 106 bytes.
Post 13 Nov 2006, 08:03
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2112
Location: Usono (aka, USA)
ATV, better safe than sorry: I didn't want to assume anything. Thanks, though! When I find time, I will tweak 'em some more. No big secrets maybe, but I found this bit extremely clever! Wink


Code:

        mov bx,0080h
        add bl,[bx]                 ; Get command line length
        mov [bx+1],bh               ; Make filename into ASCIIZ format.


Post 16 Nov 2006, 02:17
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2112
Location: Usono (aka, USA)
Warning! More useless information:

Okay, I also wrote a version of C02 in C, just for comparison's sake. The source is about 5k (compared to 10k for the .ASM, both liberally commented). Compiled with Turbo C++ 1.01 (smaller than either OpenWatcom 1.5 or DJGPP/GCC 3.4.4 or CC386 3.23) in tiny model and then packed w/ UPX 2.03 (--brute --8086), the .COM is about 6k. That's approximately 25 times the size of the assembly .COM (254 bytes). Now, I know that's not really a fair comparison, but it's probably true that no C compiler actually compiles stuff that small (well, Micro-C/PC 3.23 doesn't support longs so I had to tweak it, and that (compiled in tiny model, then compressed via UPX) results in 2,582 bytes, still 10x the assembly version's .COM size ... but Micro C/PC uses an assembler for basically everything, and even the libraries were written in ASM, I think). Obviously, though, the C version could be compiled natively for Windows without changes (unlike the .ASM version ... unless I port it to FASMLIB? Laughing), but I can't think of any major reasons why you'd want to.

P.S. For fun, I also messed around trying to obfuscate/shorten the C source and see how small it would get while still compiling. (No, I don't intend to enter IOCCC, it ain't nearly quite good enough ... but FYI, max. entry size for them is 1.5k, aka 1536 bytes). I trimmed the (non-MicroC) .C src itself down to about 744 bytes.

EDIT: Check my post #3 for a .ZIP attachment with everything in it.


Last edited by rugxulo on 02 Aug 2007, 23:21; edited 5 times in total
Post 18 Nov 2006, 05:39
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2112
Location: Usono (aka, USA)
Privalov has one-upped me with his Java/ASM .ZIP-listing example (only 3k)! Shocked Kudos! Laughing
Post 16 Dec 2006, 03:52
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2112
Location: Usono (aka, USA)
P.S. Get Octasm for DOS or OctaOS.


Code:

#
C-ZIP.SED  :   converts C.ASMC-ATV.ASMC02.ASM to Octasm 0.15
#
rugxulo AT bellsouth DOT net
FridayDecember 222006   5:50pm
#
# ----------------------------------------------------------------------
Archive:  c-zip.zip
#  Length   Method    Size  Ratio   Date   Time   CRC-32    Name
# --------  ------  ------- -----   ----   ----   ------    ----
#     1984  Defl:X      768  61%  11-06-06 11:41  ab452ae8  c.asm
#    10108  Defl:X     3336  67%  11-15-06 18:58  95c4126a  c02.asm
#     1724  Defl:X      677  61%  11-10-06 11:31  0784a251  c-atv.asm
# --------          -------  ---                            -------
#    13816             4781  65%                            3 files
# ----------------------------------------------------------------------
#
Use the following .BAT to run sed and assemble everything:
#
#     N.B. I assume HHsed (which is small and fast), so you need to
#           `set sed=sedmod' (or `gsed' or whateverfirstif you don't
#            have it.
#
# ======================================================================
@echo off
REM Tested on DR-DOS 7.03 Lite
REM rugxulo AT bellsouth DOT net
REM FridayDecember 222006   5:34pm

if "%SED%"=="" set sed=hhsed

if "%1"=="/asm" goto asmit
if "%1"=="/clean" goto clean
if "%1"=="/cleanall" goto clean
if "%1"=="clean" goto clean
if "%1"=="cleanall" goto clean

for %%a in (c c-atv c02do call %0 /asm %%a
goto end

# :asmit
shift
if exist %1.asm ren %1.asm %1.as
if not exist %1.as goto end
%SED% -f c-zip.sed %1.as > %1.asm
octasm \%1.asm file_out \%1.com
if exist %1.asm del %1.asm
if exist %1.as ren %1.as %1.asm
goto end

# :clean
for %%a in (c c-atv c02do if exist %%a.com del %%a.com

# :end
if "%SED%"=="hhsed" set sed=
# ======================================================================
#
.BAT endssed script begins here:

1s/.*/LANG OCTASM,0.1\
&/
s/FASM/Octasm/g
/short equ byte/d
s/org 100h/& use16/
s/;;;*/;/g
s/\([bw]\)[yo][tr][ed] \[/\1 [/
/^ *local_header_size *=/d
/^ *dir_msg_size *=.*/s//#dir_msg_end/
s/dir_msg_size/dir_msg_end-dir_msg/
s/local_header_size/buffer-local_header/g
s/^ *\(j[a-z][a-z]*\) short/\1/
s/^ *\([a-zA-Z0-9_][a-zA-Z0-9_]* [dr][bwd] \)/#\1/
s/^ *\([a-zA-Z0-9_][a-zA-Z0-9_]*\):/#\1/
srw \([0-9][0-9]*\)/ rb \1+\1/
s/^ *#local_header/virtual\
&/
s/^ *#buffer/&\
code/

EOF




Last edited by rugxulo on 18 Jul 2007, 23:11; edited 2 times in total
Post 23 Dec 2006, 14:39
View user's profile Send private message Visit poster's website Reply with quote
nvictor



Joined: 17 Feb 2007
Posts: 31
Guys, my dream is to write small version of softwares I usually use in order to be able to bring them on flashusb drives. Here is a small list :

1- multiple source code editor [php,xhtml,css,c,c++,asm,...]. I've seen someone reducing vim's size into a single exe using 7-zip .The genious part is that it automatically create vim's "~" and runtimes folders when launched, but these informations are volatile...

2- a graphic editor ala photoshop Smile why not? there is anima8or (<1MB) out there doing great 3D.

3- 3D game similar to kkrieger http://en.wikipedia.org/wiki/.kkrieger , just admire...

4- animation studio, why not?

5- web browser, why not?

Sell some games, why not? Very Happy
Post 19 Feb 2007, 05:25
View user's profile Send private message Reply with quote
yumka



Joined: 09 Feb 2007
Posts: 38
Location: Tenochtitlan

rugxulo wrote:
ATV, you're just ridiculously talented, that's all. I've noticed that about you (and people on this board in general). Thanks for the tips! Very Happy

Madis, I'm not sure I understand you here, but 7-Zip is definitely worthwhile. Even PKWARE uses(?) LZMA as compression method #14 in .ZIP according to their latest APPNOTE.TXT (6.3.0, Sep. 29, 2006).



Have you tried SBC?

It's fast and extremelly good compresion ratio.

But it's almost unknown for most people.

That kind of archiver would be nice to have in a fasm library.

http://sbcarchiver.netfirms.com/

_________________
rofl eax,eax
Post 19 Feb 2007, 18:09
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2112
Location: Usono (aka, USA)

nvictor wrote:
Guys, my dream is to write small version of softwares I usually use in order to be able to bring them on flashusb drives. Here is a small list :

1- multiple source code editor [php,xhtml,css,c,c++,asm,...]. I've seen someone reducing vim's size into a single exe using 7-zip .The genious part is that it automatically create vim's "~" and runtimes folders when launched, but these informations are volatile...



Try e3: it may not do everything, but it is pretty small, OS portable, and written in NASM. (I'm mainly referring to the Win9x version, which can also run under DOS w/ HXRT)


nvictor wrote:

2- a graphic editor ala photoshop Smile why not? there is anima8or (<1MB) out there doing great 3D.



See Clayworks (Pascal w/ inline ASM).


nvictor wrote:

3- 3D game similar to kkrieger http://en.wikipedia.org/wiki/.kkrieger , just admire...



Check out wolf (256 bytes, no src) and 3dmaze (C w/ inline ASM). It can indeed be done. Smile


nvictor wrote:

4- animation studio, why not?



See link above to Clayworks.


nvictor wrote:

5- web browser, why not?



This might be sorta difficult, but maybe QEmacs (C src) or FreeDOS's HTMLhelp (C w/ bit o' ASM) will show the way. Smile


QEmacs wrote:

Small! Full version (including HTML/XML/CSS2/DocBook rendering): 150KB big. Basic version (without bidir/unicode scripts/input/X11/C/Shell/HTML/dired): 49KB.




nvictor wrote:

Sell some games, why not? Very Happy



Good luck! Smile
Post 20 Feb 2007, 23:02
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2112
Location: Usono (aka, USA)

yumka wrote:

Have you tried SBC?

It's fast and extremelly good compresion ratio.

But it's almost unknown for most people.

That kind of archiver would be nice to have in a fasm library.

http://sbcarchiver.netfirms.com/



It's good, but I think UHarc (or WinUHA) is somewhat better (also closed source, though). If you prefer FOSS, the PAQ8? series (C++ w/ optional MMX or SSE2 .ASM speedup) is also good (if kinda slow). Also see P7ZIP (which now officially supports DOS but needs WATT32), ATV's TASM conversion of lzari/lzhuf/lzss .COMs + .ASM/.C src, and a few FASM/Win32 compression links (or just ASM compression links in general).


Last edited by rugxulo on 18 Jul 2007, 23:14; edited 1 time in total
Post 20 Feb 2007, 23:25
View user's profile Send private message Visit poster's website Reply with quote
Hayden



Joined: 06 Oct 2005
Posts: 132
Some PSP stuff
I noticed the descussion here about INT 20H vs INT 21H to close a file.

AH=4CH JMP/RET to PSP:0 is the same as INT 21H AH=4CH Smile

Microsoft recommends not useing INT 20H for DOS 2+

_________________
New User.. Hayden McKay.
Post 15 Apr 2007, 18:56
View user's profile Send private message Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
This is very interesting.

I'd like to know where do you get information about ZIP format.
Also, do you have any nice tutorial regarding compression?

I've always been fascinated about file compression. This is a beautiful science! Razz

Also, which packer do you consider the best? I've been using 7zip, but you said WinUHA and lZArc. What they offer?
Post 12 Feb 2008, 00:54
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2627
Location: dank orb
http://www.arturocampos.com/ - easy to read beginning.
Post 12 Feb 2008, 02:21
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2112
Location: Usono (aka, USA)

Quote:

http://www.pkware.com/documents/casestudies/APPNOTE.TXT

File: APPNOTE.TXT - .ZIP File Format Specification
Version: 6.3.2
Revised: September 28, 2007
Copyright (c) 1989 - 2007 PKWARE Inc., All Rights Reserved.



7-Zip is probably the best overall (so many archives supported, many useful options), but UHarc is darn good re: size/speed ratio (although closed src). Also, I like PAQ and LPAQ etc. because they are quite good (especially the latter; the former is extremely slow). And there are various other fringe archivers good for some eccentric cases.

IZarc (also closed src) is really just a Win32 GUI interface with .DLLs for various archive and compression types. It's like 7-Zip's file manager but supports other formats too.

There's also PeaZip (FOSS) and Precomp (FOSS soon??), which you may find interesting.
Post 13 Feb 2008, 06:25
View user's profile Send private message Visit poster's website Reply with quote
Raedwulf



Joined: 13 Jul 2005
Posts: 375
Location: United Kingdom
Have a look at FreeArc compression.
http://freearc.sourceforge.net/index.htm

It appears to have a selection of compression algorithms and applies them according to file type.

_________________
Raedwulf
Post 16 Feb 2008, 08:01
View user's profile Send private message MSN Messenger Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1907
> Also, which packer do you consider the best?

ZIP (PKZIP 2.x compatible), 7-ZIP, TAR Shocked

> I've been using 7zip, but you said WinUHA and lZArc. What they offer?

Nothing, except bloat, bugs and not working in DOS. BTW, WingUHA is not a packer, just an empty GUI ... but UH-ARC is an interesting packer. Has a DOS version (crippled because of PMODE/W's 64 MiB limit), and a Win32 one (use HX in DOS Wink ).

> Have a look at FreeArc compression.

Doesn't work in DOS. Sad


Quote:

I noticed the descussion here about INT 20H vs INT 21H to close a file.
AH=4CH JMP/RET to PSP:0 is the same as INT 21H AH=4CH
Macro$oft recommends not useing INT 20H for DOS 2+



1. Terminate application, not close a file
2. Just use always INT $21/AH=$4C and don't cause confusion (works with COM, MZ-RM-EXE and DPMI).

> I'd like to know where do you get information about ZIP format.

Download now : http://board.flatassembler.net/download.php?id=3619

Just to see how PKWARE turned the most compatible archive file format into the most messy and incompatible one Sad
Post 18 Feb 2008, 04:23
View user's profile Send private message Reply with quote
roytam1



Joined: 20 Apr 2004
Posts: 16

rugxulo wrote:
Bugfixed! Very Happy



OT: I forked your C02-mc.c to make it extract stored(uncompressed) contents and creates directories.

http://roy.orz.hm/gpc/files1.rt/exstrzip.zip

I think it may be easy to turn it into assembly within 512 bytes. Wink
Post 05 Mar 2015, 07:54
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.