Skip to main content


Showing posts from February, 2012

Fast CRC16 in Z8 and Z80 Assembly

I was wondering how few instructions does it really take to update the value of a 16 bit CRC, given an input character, on Zilog's Z8/eZ8 and Z80 architectures. As it turns out, it's only 6 instructions on Z8, and 8 fast instructions on Z80. If you want to preserve the input character, there's an extra load involved (not shown).

The precomputed CRC table must be specially formatted as described below, but first -- the code.

; Z8/eZ8/Encore! architecture
; _crc_table - crc table, 512 bytes long, see text
; RR12 (in/out) - crc to be updated
; R1 (in/out) - input character, clobbered
; R0 (out) - clobbered

ld   r0, #high(_crc_table) ; table is aligned to 256 bytes
xor  r1, r13    ; RR0 = crc_table + (data ^ crc.l)

ldc  r13, @rr0  ; crc.l = crc_table[].l
xor  r13, r12   ; crc.l = crc.h ^ crc_table[].l
inc  r0
ldc  r12, @rr0  ; crc.h = crc_table[].h

; Z80 architecture
; _crc_table - crc table, 512 bytes long, see text
; BC (in/out) - crc to be updated
; A (in/out) - input character, clobbere…

MacPorts texlive Broken by zlib 1.2.6

It's this time of the year - zlib gets updated, and things break. I run texlive latex distribution from MacPorts, and a recent update to zlib (from 1.2.5 to 1.2.6) broke texlua. When trying to activate texlive packages,  mtxrun (executed by texlua) throws the following error:

texlua PANIC: unprotected error in call to Lua API (zlib library version does not match - header: 1.2.5, library: 1.2.6)

Thus, we have to downgrade to zlib 1.2.5. I'll presume you routinely clean your outdated ports, thus it's not a simple matter of deactivating zlib 1.2.6 and reactivating the old one. That's the price one pays on being a bit OCD with that. The root of the problem is, of course, that port clean outdated does not allow selecting packages whose replacements were installed before a certain date. You'd need that functionality to only clean up ports whose upgraded replacements have hung around for a bit to prove their worth.

First, we have to determine the ports repository revision …