emmanuel-marty / unzx0_68000 Goto Github PK
View Code? Open in Web Editor NEWFree, zlib licensed ZX0 decompressor for the 68000
License: zlib License
Free, zlib licensed ZX0 decompressor for the 68000
License: zlib License
Hi there,
thank you for your implementation of the zx0 decompressor. Much appreciated!
I just noticed that both .copy_lits
and .copy_match
are using dbra
for looping over the literal/match length in d0
, which is assumed to be a long word as can be seen from the preceding subq.l #1,d0
instruction and the addx.l d0,d0
in .get_elias
. However, dbra
only uses word size for d0, and thus the decoder would not work correctly if a block has a length >65535.
I know this is a very unlikely thing to happen except for storing large blocks of random noise or e.g. very large duplicated or empty blocks of data. But if this edge case is unsupported anyway, the operations on d0
could be cut down to word size, halving the number of cycles on 68000 for these operations.
An easy fix is to move the subq.l #1,d0
inside the loop and use a bne.s
instead of dbra
at the cost of performance (same code size).
More complicated solutions would keep the dbra and test the upper word of d0 for zero. For example:
swap d0
tst.w d0
beq.s .copy_lits_done
swap d0
bra.s .copy_lits
.copy_lits_done
or
.copy_lits_next_64k
subq.l #1,d0 ; dbf will loop until d0 is -1, not 0
.copy_lits
move.b (a0)+,(a1)+ ; copy literal byte
dbra d0,.copy_lits ; loop for all literal bytes
addq.l #1,d0
bne.s .copy_lits_next64k
(I do like the latter solution, it looks elegant and only adds 2 * 4 bytes to your version and 16 cycles per block).
... error removed ...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.