extrn .crc ; ; Compute a CRC16 checksum over the content of buffer hl^. The ; initial CRC checksum value is passed and returned in (bc). It ; should be initialized to 0ffffh. .bcrc entry does not initialize, ; thus allowing the crc checksum to be applied over multiple buffer ; loads. This is intended to be used with large buffered transfers, ; between calls on .bload and the following .bdump. A file re-read ; can then quickly verify an accurate transfer. This code assumes ; the buffer never wraps, i.e. it is used solely for file/file ; transfers, so that it is always loaded from the bottom. If not ; unloaded it should be flushed (use .bflush) before reloading. ; Carry for invalid buffer state ; a,f,b,c .bcrc:: push h push d inx h ! inx h inx h ! inx h; bypass size inx h ! inx h; point to cnt mov a,m ! ani 07fh stc ! jnz bcrc2; assumptions invalid mov e,m ! inx h ! mov d,m; get cnt, multiple of 128 mov a,e ! ora d jz bcrc2; < 128 bytes stored, exit inx h; advance to rptr mov a,m ! inx h ! ora m; rptr should be zero stc ! jnz bcrc2; assumptions invalid, error inx h ! inx h ! inx h; point to buffer start bcrc1: mov a,m ! inx h; buffer known non-empty call .crc dcx d ! mov a,d ! ora e; clears any carry jnz bcrc1; more bcrc2: pop d pop h ret