X/Y/Zmodem Technical Specification by Rob Swindell, Digital Dynamics 1993
-------------------------------------------------------------------------

Definitions:

Acronym 	Decimal Value	Description		X/Ymodem Use
-------------------------------------------------------------------------------
SOH		1		Start of header		Start 128 byte block
STX		2		Start of text		Start 1024 byte block
EOT		4		End of transmission	End of this file
ACK		6		Acknowledge		Received data okay
NAK		21		Negative acknowledge	Error in receiving data
CAN		24		Cancel			Stop transfer now
CPMEOF		26		CP/M End of file	Padding for Xmodem recv


===============================
Xmodem Checksum 128 byte blocks
===============================

Sender					Receiver
-------------------------------------------------------------------------------
<nothing>				NAK

SOH (start of block #1)			<nothing>
Block Number LSB (1)			<nothing>
1's Compliment of Block Number LSB      <nothing>
128 bytes of data (padded w/CPMEOF)	<nothing>
Checksum of data (1 byte)		ACK if Checksum OK, NAK if not

[Wait for ACK or NAK. Re-send if NAK, abort if CAN]

SOH (start of block #2) 		<nothing>
Block Number LSB (2)			<nothing>
1's Compliment of Block Number LSB      <nothing>
128 bytes of data (padded w/CPMEOF)	<nothing>
Checksum of data (1 byte)		ACK if Checksum OK, NAK if not

[Wait for ACK or NAK. Re-send if NAK, abort if CAN]

...

EOT					ACK
-------------------------------------------------------------------------------


==============================
Xmodem CRC-16 1024 byte blocks
==============================

Sender					Receiver
-------------------------------------------------------------------------------
<nothing>				'C' <specifies CRC error detection>

STX (start of block #1) 		<nothing>
Block Number LSB (1)			<nothing>
1's Compliment of Block Number LSB      <nothing>
1024 bytes of data (padded w/CPMEOF)	<nothing>
16-bit CRC of data (2 bytes)		ACK if CRC OK, NAK if not

[Wait for ACK or NAK. Re-send if NAK, abort if CAN]

STX (start of block #2) 		<nothing>
Block Number LSB (2)			<nothing>
1's Compliment of Block Number LSB      <nothing>
1024 bytes of data (padded w/CPMEOF)	<nothing>
16-bit CRC of data (2 bytes)		ACK if CRC OK, NAK if not

[Wait for ACK or NAK. Re-send if NAK, abort if CAN]

...

EOT                                     ACK
-------------------------------------------------------------------------------


==============================
Ymodem CRC-16 1024 byte blocks
==============================

Sender					Receiver
-------------------------------------------------------------------------------
<nothing>				'C' <specifies CRC error detection>

SOH (start of file info block)		<nothing>
Block Number LSB (0)			<nothing>
1's Compliment of Block Number LSB      <nothing>
128 bytes of file info (see below)	<nothing>
16-bit CRC of file info (2 bytes)	ACK if CRC OK, NAK if not

[Wait for ACK or NAK. Re-send if NAK, abort if CAN]

STX (start of block #1) 		<nothing>
Block Number LSB (1)			<nothing>
1's Compliment of Block Number LSB      <nothing>
1024 bytes of data (padded w/CPMEOF)	<nothing>
16-bit CRC of data (2 bytes)		ACK if CRC OK, NAK if not

[Wait for ACK or NAK. Re-send if NAK, abort if CAN]

STX (start of block #2) 		<nothing>
Block Number LSB (2)			<nothing>
1's Compliment of Block Number LSB      <nothing>
1024 bytes of data (padded w/CPMEOF)	<nothing>
16-bit CRC of data (2 bytes)            ACK if CRC OK, NAK if not

[Wait for ACK or NAK. Re-send if NAK, abort if CAN]

...

EOT                                     ACK

SOH (start of terminating block)	<nothing>
Block Number LSB (0)			<nothing>
1's Compliment of Block Number LSB      <nothing>
128 bytes of NULLs			<nothing>
16-bit CRC of NULLs (2 bytes)		<nothing> (sometimes ACK or NAK) 
-------------------------------------------------------------------------------


======================================
Ymodem CRC-16 1024 byte blocks - Batch
======================================

Sender					Receiver
-------------------------------------------------------------------------------
<nothing>				'C' <specifies CRC error detection>

SOH (start of file #1 info block)	<nothing>
Block Number LSB (0)			<nothing>
1's Compliment of Block Number LSB      <nothing>
128 bytes of file info (see below)	<nothing>
16-bit CRC of file info (2 bytes)	ACK if CRC OK, NAK if not

[Wait for ACK or NAK. Re-send if NAK, abort if CAN]

STX (start of block #1) 		<nothing>
Block Number LSB (1)			<nothing>
1's Compliment of Block Number LSB      <nothing>
1024 bytes of data (padded w/CPMEOF)	<nothing>
16-bit CRC of data (2 bytes)		ACK if CRC OK, NAK if not

[Wait for ACK or NAK. Re-send if NAK, abort if CAN]

STX (start of block #2) 		<nothing>
Block Number LSB (2)			<nothing>
1's Compliment of Block Number LSB      <nothing>
1024 bytes of data (padded w/CPMEOF)	<nothing>
16-bit CRC of data (2 bytes)            ACK if CRC OK, NAK if not

[Wait for ACK or NAK. Re-send if NAK, abort if CAN]

...

EOT                                     ACK

SOH (start of file #2 info block)	<nothing>
Block Number LSB (0)			<nothing>
1's Compliment of Block Number LSB      <nothing>
128 bytes of file info (see below)	<nothing>
16-bit CRC of file info (2 bytes)	ACK if CRC OK, NAK if not

[Wait for ACK or NAK. Re-send if NAK, abort if CAN]

STX (start of block #1) 		<nothing>
Block Number LSB (1)			<nothing>
1's Compliment of Block Number LSB      <nothing>
1024 bytes of data (padded w/CPMEOF)	<nothing>
16-bit CRC of data (2 bytes)		ACK if CRC OK, NAK if not

[Wait for ACK or NAK. Re-send if NAK, abort if CAN]

STX (start of block #2) 		<nothing>
Block Number LSB (2)			<nothing>
1's Compliment of Block Number LSB      <nothing>
1024 bytes of data (padded w/CPMEOF)	<nothing>
16-bit CRC of data (2 bytes)            ACK if CRC OK, NAK if not

[Wait for ACK or NAK. Re-send if NAK, abort if CAN]

...

EOT                                     ACK

SOH (start of terminating block)	<nothing>
Block Number LSB (0)			<nothing>
1's Compliment of Block Number LSB      <nothing>
128 bytes of NULLs			<nothing>
16-bit CRC of NULLs (2 bytes)		<nothing> (sometimes ACK or NAK)
-------------------------------------------------------------------------------


================================
Ymodem-G CRC-16 1024 byte blocks
================================

Sender					Receiver
-------------------------------------------------------------------------------
<nothing>				'G' <specifies CRC non-stop>

SOH (start of file info block)		<nothing>
Block Number LSB (0)			<nothing>
1's Compliment of Block Number LSB      <nothing>
128 bytes of file info (see below)	<nothing>
16-bit CRC of file info (2 bytes)	ACK if CRC OK, NAK if not

[If anything incoming and is not ACK, abort]

STX (start of block #1) 		<nothing>
Block Number LSB (1)			<nothing>
1's Compliment of Block Number LSB      <nothing>
1024 bytes of data (padded w/CPMEOF)	<nothing>
16-bit CRC of data (2 bytes)		ACK if CRC OK, NAK if not

[If anything incoming and is not ACK, abort]

STX (start of block #2) 		<nothing>
Block Number LSB (2)			<nothing>
1's Compliment of Block Number LSB      <nothing>
1024 bytes of data (padded w/CPMEOF)	<nothing>
16-bit CRC of data (2 bytes)            ACK if CRC OK, NAK if not

[If anything incoming and is not ACK, abort]

...

EOT                                     ACK

SOH (start of terminating block)	<nothing>
Block Number LSB (0)			<nothing>
1's Compliment of Block Number LSB      <nothing>
128 bytes of NULLs			<nothing>
16-bit CRC of NULLs (2 bytes)		<nothing> (sometimes ACK or NAK)
-------------------------------------------------------------------------------

======================================
Zmodem CRC-32 1024 byte blocks - Batch
======================================

Sender					Receiver
-------------------------------------------------------------------------------
<nothing>				ZPAD,
					ZPAD,
					ZDLE,
					if var hdr    : ZVHEX, "04" (hdrlen),
					if non var hdr: ZHEX,
					ZRINIT ("01"),
					"00" (TP0),
					"00" (TP1),
					"01" (TF1),
					"6f" (TF0),
					send crc high bit in hex,
					send crc low  bit in hex,
					CR,
					 (138),
					ETB (17)
-------------------------------------------------------------------------------

