Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Last revisionBoth sides next revision | ||
ref:xmodem [2011/07/13 22:28] – Initial import of xmodem.doc digitalman | ref:xmodem [2011/07/13 23:35] – digitalman | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
< | < | ||
- | Please circulate this document anyway that you see | + | |
- | | + | fit without alteration except on the page at the |
- | | + | end titled: "Notes and Comments" |
- | | + | that anyone using these protocols within a commer- |
- | | + | cial product not charge for them as an option or |
- | | + | surcharge, but include XMODEM and its derivations |
- | | + | as part of the basic product. |
- | Peter Boswell | + | Peter Boswell |
- | | + | |
- | | + | |
</ | </ | ||
+ | This document was converted to Wiki syntax by [[person: | ||
===== Preface ===== | ===== Preface ===== | ||
Line 35: | Line 35: | ||
Here are a few people that all of us should thank and I would especially like to recognize: | Here are a few people that all of us should thank and I would especially like to recognize: | ||
- | === Ward Christensen | + | * Ward Christensen |
Ward, a true pioneer in the microcomputer | Ward, a true pioneer in the microcomputer | ||
communications area, is the author of the original Checksum | communications area, is the author of the original Checksum | ||
Xmodem protocol. | Xmodem protocol. | ||
stupid" | stupid" | ||
- | + | ---- | |
- | === Chuck Forsberg | + | |
Chuck has edited perhaps the best work on | Chuck has edited perhaps the best work on | ||
Xmodem and has provided both YMODEM (1K Xmodem) and ZMODEM | Xmodem and has provided both YMODEM (1K Xmodem) and ZMODEM | ||
Line 47: | Line 47: | ||
me a protocol which would deal with the X-On/X-Off problem | me a protocol which would deal with the X-On/X-Off problem | ||
and reminding me that there is such a thing as a DLE character. | and reminding me that there is such a thing as a DLE character. | ||
- | + | ---- | |
- | === Richard (Scott) McGinnis | + | |
Scott is the architect, the moving | Scott is the architect, the moving | ||
force, for the People/Link software system. | force, for the People/Link software system. | ||
Line 54: | Line 54: | ||
you see his visual conference program for the IBM PC! | you see his visual conference program for the IBM PC! | ||
Thanks for showing me how to use a DLE. | Thanks for showing me how to use a DLE. | ||
- | + | ---- | |
- | === Gene Plantz | + | |
Gene operates a major IBM PC bulletin board in | Gene operates a major IBM PC bulletin board in | ||
the Chicago area and has been active in the National SYSOP | the Chicago area and has been active in the National SYSOP | ||
Association. | Association. | ||
performance. | performance. | ||
+ | |||
+ | ---- | ||
In a historical perspective, | In a historical perspective, | ||
Line 158: | Line 160: | ||
simplicity of the protocol is one of the reasons it survived | simplicity of the protocol is one of the reasons it survived | ||
to this day in as many machines and programs as it may be | to this day in as many machines and programs as it may be | ||
- | found in!"((Ward Christensen, | + | found in!" |
+ | | ||
==== Xmodem Hardware Level Protocol ==== | ==== Xmodem Hardware Level Protocol ==== | ||
Line 215: | Line 218: | ||
The Xmodem Packet looks like this: | The Xmodem Packet looks like this: | ||
+ | < | ||
[SOH] [seq] [cmpl [seq] [128 data bytes] [csum] | [SOH] [seq] [cmpl [seq] [128 data bytes] [csum] | ||
Line 238: | Line 241: | ||
| | ||
| | ||
+ | </ | ||
Once Xmodem Initiation has completed, the transmitter sends the | Once Xmodem Initiation has completed, the transmitter sends the | ||
Line 347: | Line 350: | ||
* Once a SOH is found, assume that the next two characters | * Once a SOH is found, assume that the next two characters | ||
- | * Send a NAK if a timeout occurs while attempting to re-synchronize (e.g. continue to process timeouts as | + | * Send a NAK if a timeout occurs while attempting to re-synchronize (e.g. continue to process timeouts as described above). |
- | | + | * If no re-synchronization occurs within 135 characters |
- | | + | |
- | * If no re-synchronization occurs within 135 characters | + | |
=== False EOT condition === | === False EOT condition === | ||
Line 364: | Line 365: | ||
return a NAK for the first EOT received and only assume true | return a NAK for the first EOT received and only assume true | ||
end of transmission after receiving two EOT's. | end of transmission after receiving two EOT's. | ||
+ | < | ||
Transmitter | Transmitter | ||
Line 373: | Line 374: | ||
[EOT] >>>>> | [EOT] >>>>> | ||
<<<<< | <<<<< | ||
+ | </ | ||
Just in case the transmitter was not prepared to resend the | Just in case the transmitter was not prepared to resend the | ||
EOT, it might be wise to set the timeout to about 3 seconds | EOT, it might be wise to set the timeout to about 3 seconds | ||
Line 459: | Line 460: | ||
- | ===== WINDOWED | + | ===== Windowed |
This section assumes that the reader is already familiar with Xmodem and CRC Xmodem presented above. | This section assumes that the reader is already familiar with Xmodem and CRC Xmodem presented above. | ||
Line 472: | Line 473: | ||
A few people began discussing improvements to Xmodem with me in | A few people began discussing improvements to Xmodem with me in | ||
late 1985, over time we developed the following criteria: | late 1985, over time we developed the following criteria: | ||
+ | - The protocol must be as similar as possible to the XMODEM originally developed by Ward Christensen. The popularity of XMODEM, I believe, is based on its conceptual simplicity. | ||
+ | - The protocol must overcome the propagation delay that is characteristic of the public data networks. | ||
+ | - The protocol must overcome the flow control problems which are characteristic in many public data network situations. | ||
+ | - The protocol should improve error recovery by simplifying the manner in which a programmer can determine the beginning of an XMODEM block. | ||
- | - The protocol must be as similar as possible to the | + | ==== Transparency |
- | XMODEM originally developed by Ward Christensen. | + | |
- | The popularity of XMODEM, I believe, is based on | + | |
- | its conceptual simplicity. | + | |
- | are familiar with this protocol than any other. | + | |
- | More files are transferred everyday by this | + | |
- | protocol than any other asynchronous protocol. | + | |
- | Simplicity here implies a limited number of rules | + | |
- | for timing, error recovery | + | |
- | - The protocol must overcome the propagation delay | ||
- | that is characteristic of the public data networks. | ||
- | networks than via the public voice networks, the | ||
- | propagation delays inherent in public data networks | ||
- | both reduces the cost savings and increases the | ||
- | aggravation that occurs while watching a computer | ||
- | slowly perform a file transfer. | ||
- | - The protocol | + | This protocol |
- | problems which are characteristic in many public | + | non-X.25 hosts and PC-Pursuit access to bulletin boards. |
- | data network | + | to accomplish this, the transmitter is not permitted to transmit |
- | situations, the X-On and X-Off characters | + | the X-On and X-Off characters |
- | always be used for flow control and only for flow | + | for this restriction is simple: |
- | control when using public data networks. | + | |
- | | + | |
- | simplifying | + | |
- | determine the beginning | + | |
- | the Start of Header character (SOH) can appear in | + | |
- | the data or CRC, the programmer must use a relatively sophisticated method | + | |
- | actually represents the beginning of a XMODEM | + | |
- | block. | + | |
- | ===== Transparency | + | * To avoid data loss public data networks must always assume that any X-Off and X-On character is a flow control character when supporting PC-Pursuit for bulletin boards and when supporting non-X.25 host systems. |
+ | Since many non-X.25 hosts, bulletin boards and communications | ||
+ | programs use X-On and X-Off as flow control characters, public | ||
+ | data networks must support those X-Off and X-On requests at the | ||
+ | point of connection where the X-Off is received by the public data | ||
+ | network. | ||
+ | up in the network would be transmitted by the public data network | ||
+ | before the X-Off used for flow control reached the transmitter. | ||
+ | The public data network has no way to know whether an X-On/X-Off | ||
+ | protocol or Xmodem is operational at any point in time. Therefore | ||
+ | a Xmodem packet which contains an X-Off character and no succeeding X-On character will cause the public data network to stop | ||
+ | forwarding the ACK or NAK. | ||
- | This protocol provides special public data network support | + | In addition, error recovery requires sophisticated programming |
- | | + | the receiver |
- | to accomplish | + | protocol simplifies |
- | the X-On and X-Off characters in the Xmodem packets. The reason | + | an indicator that an XMODEM packet |
- | for this restriction | + | SYN (synch, decimal 22) character is used for this purpose. |
+ | The presence of one or more SYN characters in a data stream always | ||
+ | indicates that the next non SYN character | ||
+ | XMODEM packet (e.g. SOH). | ||
- | | + | The method used here to handle these situations is through |
- | flow control, buffer overruns and lost data are inevit- | + | insertion |
- | able from time to time at any baud rate. | + | character) as an indicator that the character following the DLE is |
+ | in fact a modified DLE, SYN, X-On, or X-Off character. | ||
- | To avoid data loss public data networks must always | + | === Rules === |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | Since many non-X.25 hosts, bulletin boards and communications | + | |
- | programs use X-On and X-Off as flow control characters, public | + | - The inserted DLE characters are not counted in the 128 byte data length |
- | data networks must support those X-Off and X-On requests at the | + | - Neither the DLE nor the adjusted characters are used in the CRC calculation, |
- | point of connection where the X-Off is received by the public data | + | - When the receiver sees a DLE character, it does not count it in the XMODEM block length calculation, |
- | network. | + | - Prior to transmission of a XMODEM packet, the |
- | up in the network | + | - Except for the character received after a DLE, the |
- | before | + | - The transmitter must support flow control characters (X-On, and X-Off) during transmission of |
- | The public data network has no way to know whether an X-On/X-Off | + | |
- | | + | |
- | | + | |
- | ing X-On character will cause the public data network | + | |
- | forwarding the ACK or NAK. | + | |
- | In addition, error recovery requires sophisticated programming for | + | ==== Initial Handshake Rules ==== |
- | the receiver to determine the start of an XMODEM packet. | + | |
- | protocol simplifies this task by dedicating a special character as | + | |
- | an indicator that an XMODEM packet is about to begin. | + | |
- | SYN (synch, decimal 22) character is used for this purpose. | + | |
- | The presence of one or more SYN characters in a data stream always | + | |
- | indicates that the next non SYN character is the beginning of an | + | |
- | XMODEM packet (e.g. SOH). | + | |
- | The method used here to handle these situations is through the | ||
- | insertion of the DLE character (H010, decimal 16, data link escape | ||
- | character) as an indicator that the character following the DLE is | ||
- | in fact a modified DLE, SYN, X-On, or X-Off character. | ||
- | Rules: | + | An initial handshake |
- | + | indicate | |
- | | + | Xmodem, CRC Xmodem, or Windowed Xmodem: |
- | | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | Xmodem, CRC Xmodem, WXmodem | + | |
- | June 20, 1986 Page 17 | + | |
- | | + | |
- | + | ||
- | | + | |
- | will transmit instead a DLE character followed by | + | |
- | the original character which has been modified by | + | |
- | | + | |
- | + | ||
- | | + | |
- | 128 byte data length of the data portion of the | + | |
- | | + | |
- | have a packet which is physically 264 bytes in | + | |
- | | + | |
- | (or its complement), all of the 128 data characters | + | |
- | and two CRC characters are all either X-On, X-Off, | + | |
- | | + | |
- | + | ||
- | | + | |
- | used in the CRC calculation, | + | |
- | | + | |
+ | - WXMODEM - The receiver will send a character W | ||
+ | - CRC XMODEM - The receiver will send a character C | ||
+ | - Checksum XMODEM - The receivers will send a NAK and wait up to 3 seconds for the beginning of a Xmodem packet. | ||
- | | + | ==== Window Packet Transmission Rules ==== |
- | count it in the XMODEM block length calculation, | + | |
- | nor compute it in the CRC calculation but discards | + | |
- | it and then remembers to exclusive or the next | + | |
- | | + | |
- | | + | |
- | | + | |
- | not one of those four characters) and then include | + | |
- | the character as part of the packet. | + | |
- | | ||
- | | ||
- | | ||
- | | ||
- | | + | In order to overcome |
- | receiver will test each incoming character to see | + | data networks such as Tymnet, Telenet, Datapac, IPSS, Transpac and |
- | if it is a SYN character. | + | dozens more, the protocol must permit |
- | | + | than one packet before receiving an acknowledgement from the |
- | character will be another SYN or SOH. If a SYN | + | receiver. |
- | | + | before stopping transmission if an acknowledgement has not been |
- | the receiver | + | received is called |
- | | + | packets for several reasons. |
- | beginning of a XMODEM packet by the receiver. | + | set of timing rules which would deal reasonably well with a wide |
- | an out of synch condition occurs on incoming | + | range of baud rates (that implied keeping |
- | data, the receiver can just ignore every incoming | + | small). |
- | character until it sees a SYN. | + | to the Xmodem packet sequence number |
- | code which already properly deals with this | + | simplify implementation |
- | situation could just always discard any SYN | + | |
- | | + | |
- | | + | |
+ | === Rules === | ||
+ | 1. The window is always 4 Xmodem packets. | ||
+ | | ||
+ | 2. The receiver will transmit acknowledgements in the form: | ||
- | Xmodem, CRC Xmodem, WXmodem | + | |
- | June 20, 1986 Page 18 | + | |
- | | + | |
+ | The [sequence] field is an 8 bit number where the | ||
+ | high order or most significant 6 bits are always | ||
+ | zero and the low order or least significant 2 bits | ||
+ | are always the same as the low order 2 bits of the | ||
+ | XMODEM block sequence number of the XMODEM packet | ||
+ | being acknowledged (value in decimal may range | ||
+ | from 0 to 3). | ||
- | | + | 3. The receiver does not have to acknowledge every |
- | | + | packet, but must acknowledge at minimum every |
- | | + | fourth packet. |
- | | + | ACK[sequence] for multiple XMODEM packets. |
- | again after 10 seconds or an X-On is received, | + | example, after an unknown number of packets: |
- | | + | < |
- | | + | |
- | | + | |
- | apply to X.25 host computers which use X.25 L2 and | + | |
- | L3 windows for flow control.) | + | |
- | + | ||
- | 6.3. Initial Handshake Rules | + | |
- | + | ||
- | An initial handshake is provided to permit the receiver to | + | |
- | indicate to the transmitter whether it can support checksum | + | |
- | | + | |
- | + | ||
- | | + | |
- | | + | |
- | of a Xmodem packet. | + | |
- | and then the receiver will drop down to CRC Xmodem. | + | |
- | + | ||
- | | + | |
- | | + | |
- | of a Xmodem packet. | + | |
- | and then the receiver will drop down to Checksum | + | |
- | | + | |
- | + | ||
- | | + | |
- | and wait up to 3 seconds for the beginning of a | + | |
- | | + | |
- | if no valid SOH is received, the receiver will | + | |
- | abort the file transfer request. | + | |
- | + | ||
- | 6.4. Window Packet Transmission Rules | + | |
- | + | ||
- | In order to overcome the propagation delays inherent with public | + | |
- | data networks such as Tymnet, Telenet, Datapac, IPSS, Transpac and | + | |
- | dozens more, the protocol must permit the transmitter to send more | + | |
- | than one packet before receiving an acknowledgement from the | + | |
- | receiver. | + | |
- | before stopping transmission if an acknowledgement has not been | + | |
- | received is called the " | + | |
- | packets for several reasons. | + | |
- | set of timing rules which would deal reasonably well with a wide | + | |
- | range of baud rates (that implied keeping the window fairly | + | |
- | small). | + | |
- | to the Xmodem packet sequence number which, hopefully, will | + | |
- | simplify implementation of windowing. | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | Xmodem, CRC Xmodem, WXmodem | + | |
- | June 20, 1986 Page 19 | + | |
- | | + | |
- | + | ||
- | + | ||
- | Rules: | + | |
- | + | ||
- | | + | |
- | the transmitter will send 4 unacknowledged pack- | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | files or at end-of-file. | + | |
- | + | ||
- | | + | |
- | | + | |
- | + | ||
- | ACK[sequence] | + | |
- | + | ||
- | The [sequence] field is an 8 bit number where the | + | |
- | high order or most significant 6 bits are always | + | |
- | zero and the low order or least significant 2 bits | + | |
- | are always the same as the low order 2 bits of the | + | |
- | | + | |
- | being acknowledged (value in decimal may range | + | |
- | from 0 to 3). | + | |
- | + | ||
- | 6.4.3. The receiver does not have to acknowledge every | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
| | ||
Line 727: | Line 591: | ||
| | ||
..... | ..... | ||
- | + | </ | |
- | | + | Since some transmitters must close the window and |
- | | + | cease all communications before doing disk I/O to |
- | | + | read more data, it is suggested that acknowledgements |
- | | + | receiver can easily determine that another packet |
- | | + | is already being received at the point in time that |
- | | + | the ACK[sequence] is about to be sent).3 |
- | | + | |
Line 740: | Line 603: | ||
- | + | 4. The receiver will reject a packet (request | |
- | + | ||
- | Xmodem, CRC Xmodem, WXmodem | + | |
- | June 20, 1986 Page 20 | + | |
- | | + | |
- | + | ||
- | 6.4.4. The receiver will reject a packet (request | + | |
- | | + | |
NAK[sequence] | NAK[sequence] | ||
- | Where [sequence] is then next window sequence | + | Where [sequence] is then next window sequence |
- | | + | number (between H000 and H003) after the [sequence] |
- | | + | of the last good block. |
- | | + | up to 3 Xmodem packets received after the NAK is |
- | | + | transmitted until it receives the packet with the |
- | | + | sequence number that had previously been nak'ed by |
- | | + | the receiver. |
- | | + | NAK until another packet with the same sequence |
- | | + | number is received which is also invalid or a |
- | | + | timeout has occurred. |
- | + | ||
- | | + | |
- | will complete transmission of any XMODEM block | + | |
- | | + | |
- | | + | |
- | | + | |
- | + | ||
- | | + | |
- | count them in the window for purposes of deter- | + | |
- | | + | |
- | | + | |
- | | + | |
- | send an ACK H003 even if the receiver has previous- | + | |
- | ly acked that block. | + | |
- | + | ||
- | | + | |
- | ing are: | + | |
- | + | ||
- | | + | |
- | not yet recognized: | + | |
- | + | ||
- | | + | |
- | has been recognized: | + | |
- | + | ||
- | | + | |
- | the window has closed: | + | |
- | + | ||
- | | + | |
- | the transmitter: | + | |
- | + | ||
- | | + | |
- | or NAK when the window is closed (e.g. four blocks | + | |
- | have been transmitted), | + | |
- | | + | |
- | | + | |
- | + | ||
- | + | ||
- | + | ||
+ | 5. When the transmitter receives a NAK[sequence], | ||
+ | will complete transmission of any XMODEM block | ||
+ | currently being transmitted and then begin re- | ||
+ | transmission starting with the block which was | ||
+ | nak' | ||
- | Xmodem, CRC Xmodem, WXmodem | + | 6. The receiver will discard duplicate packets but |
- | June 20, 1986 Page 21 | + | count them in the window for purposes of deter- |
- | ---------------------------------------------------------------------- | + | mining the maximum receive window without an ACK in |
+ | response. | ||
+ | sequence number 127 four times in a row, it must | ||
+ | send an ACK H003 even if the receiver has previously acked that block. | ||
- | | + | 7. The timeout intervals at various points in processing are: |
- | | + | |
- | | + | Waiting for a character on receive, start of packet |
- | return an ACK[sequence] | + | 15 seconds |
- | least 50% of the Xmodem packets. | + | Waiting |
- | must wait for the window | + | |
- | Xmodem packets without | + | Waiting |
- | some performance benefit will be lost. | + | 15 seconds4 |
+ | Waiting for an X-On after receipt of an X-Off by the transmitter: | ||
+ | 10 seconds | ||
- | If the receiver cannot overlap disk I/O and communications | + | 8. When the transmitter times out waiting for an ACK or NAK when the window is closed (e.g. four blocks |
- | I/O, the receiver can temporarily stop transmission | + | |
- | " | + | 9. Where possible, it is recommended that the receiver |
- | an ACK[sequence]) performing the disk I/O and then sending an | + | |
- | | + | |
- | | + | If the receiver |
- | is ready to resume accepting data. Note that the receiver | + | I/O, the receiver can temporarily stop transmission by either: |
- | | + | |
- | after the X-Off is sent to cover situations where satellite | + | |
- | | + | |
- | would let the computer user set the "X-Off delay time" so | + | |
- | that in the normal case the X-Off delay could be set to 25 | + | |
- | | + | |
- | | + | |
- | based on experience during | + | |
- | Each approach has its advantages, but the X-Off approach will | + | - " |
- | provide the best performance in most cases especially when | + | - Transmitting an X-Off followed by an X-On when the receiver |
- | using a public data network. | + | - Each approach has its advantages, but the X-Off approach will |
- | computers, notably the Commodore 64 and the IBM PC Jr cannot | + | |
- | receive communications data while writing to disk. | + | |
+ | ==== Notes for X.25 Hosts ==== | ||
+ | Host computer systems which utilize the X.25 protocol | ||
+ | (examples: People/ | ||
+ | interface with the various public data networks may send special | ||
+ | control packets which change the manner in which the network will | ||
+ | communicate with the remote personal computer, bulletin board or | ||
+ | terminal. | ||
+ | X.25 host can already support CRC and/or Checksum Xmodem and | ||
+ | present only the changes for WXMODEM. | ||
- | + | | |
- | + | | |
- | Xmodem, CRC Xmodem, WXmodem | + | |
- | June 20, 1986 Page 22 | + | |
- | ---------------------------------------------------------------------- | + | |
- | + | ||
- | 6.5. Notes for X.25 Hosts | + | |
- | + | ||
- | Host computer systems which utilize the X.25 protocol | + | |
- | (examples: People/ | + | |
- | interface with the various public data networks may send special | + | |
- | control packets which change the manner in which the network will | + | |
- | communicate with the remote personal computer, bulletin board or | + | |
- | terminal. | + | |
- | X.25 host can already support CRC and/or Checksum Xmodem and | + | |
- | present only the changes for WXMODEM. | + | |
- | + | ||
- | | + | |
- | sure to set the distant X.3 PAD parameters to | + | |
- | assure that the receiver can use X-Off/X-On for | + | |
- | flow control. | + | |
- | Q-Bit command packet to set X.3 parameter 12 to a 1 | + | |
- | prior to the initial handshake. | + | |
- | receiver cannot support WXMODEM, the X.25 Host must | + | |
- | send the appropriate Q-Bit packet to reset para- | + | |
- | | + | |
- | or Checksum Xmodem packet. | + | |
- | + | ||
- | | + | |
- | mode, it must be sure to set the distant X.3 PAD | + | |
- | parameters to assure that the network will use | + | |
- | X-Off/X-On for flow control between the network and | + | |
- | the transmitter to prevent its buffers from | + | |
- | overflowing. | + | |
- | Q-Bit command packet to set X.3 parameter 5 to a 1 | + | |
- | prior to the initial handshake. | + | |
+ | ===== Appendix A - CRC Calculation Rules ===== | ||
+ | The purpose of this appendix is to give non-technical and non mathematical software writers a cook book approach to calculating the CRC-16 | ||
+ | used in Xmodem. | ||
+ | in the examples below has been tested on an IBM PC and found to work | ||
+ | effectively even at 9600 with compiled Basic. | ||
+ | not offer an XOR function and others do not have MKI$ and CVI functions | ||
+ | which simplified the movement of data between data types. | ||
+ | hope to provide a Commodore C-64/C-128 implementation which simulates | ||
+ | XOR, but not today! | ||
+ | My thanks go to Chuck Forsberg, Joe Noonan, John Byrns and Stephen | ||
+ | Satchell. | ||
+ | have never been possible. | ||
- | Xmodem, CRC Xmodem, WXmodem | + | ==== IBM PC - 8088/8086 Data Structure ==== |
- | June 20, 1986 Page 23 | + | |
- | | + | |
- | + | ||
- | | + | |
- | + | ||
- | The purpose of this appendix is to give non-technical and non mathema- | + | |
- | tical software writers a cook book approach to calculating the CRC-16 | + | |
- | used in Xmodem. | + | |
- | in the examples below has been tested on an IBM PC and found to work | + | |
- | | + | |
- | not offer an XOR function and others do not have MKI$ and CVI functions | + | |
- | which simplified the movement of data between data types. | + | |
- | hope to provide a Commodore C-64/C-128 implementation which simulates | + | |
- | XOR, but not today! | + | |
- | + | ||
- | My thanks go to Chuck Forsberg, Joe Noonan, John Byrns and Stephen | + | |
- | | + | |
- | have never been possible. | + | |
- | 7.1. IBM PC - 8088/8086 Data Structure | ||
- | | + | The Intel 8080 and upward has a feature, convenient only to some |
- | electrical engineer somewhere, which places 2 byte (16) bit | + | electrical engineer somewhere, which places 2 byte (16) bit |
- | integers in BYTE REVERSE order in memory. | + | integers in BYTE REVERSE order in memory. |
- | significant byte is placed in memory before the most significant | + | significant byte is placed in memory before the most significant |
- | byte for integer operations. | + | byte for integer operations. |
- | number 52 and it is assigned to I% using the ASC function, the | + | number 52 and it is assigned to I% using the ASC function, the |
- | binary value (52) ends up in the first byte of I% and the second | + | binary value (52) ends up in the first byte of I% and the second |
- | byte is zero. | + | byte is zero. |
| | ||
Line 927: | Line 708: | ||
| | ||
- | | + | Once this is understood, many problems with these algorithms goes away. |
- | | + | |
- | 7.2. BASIC Implementation of Bit Shift Method | + | ==== BASIC Implementation of Bit Shift Method |
- | The bit shift method here was converted from the " | ||
- | presented in Chuck Forsberg' | ||
- | and from an old IBM two page reference guide that Joe Noonan | ||
- | carries with him in his appointment calendar! | ||
- | + | The bit shift method here was converted from the " | |
+ | presented in Chuck Forsberg' | ||
+ | and from an old IBM two page reference guide that Joe Noonan | ||
+ | carries with him in his appointment calendar! | ||
- | + | === Chucks' | |
- | + | < | |
- | + | ||
- | + | ||
- | Xmodem, CRC Xmodem, WXmodem | + | |
- | June 20, 1986 Page 24 | + | |
- | | + | |
- | + | ||
- | + | ||
- | | + | |
/* | /* | ||
Line 974: | Line 745: | ||
| | ||
} | } | ||
+ | </ | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | Xmodem, CRC Xmodem, WXmodem | ||
- | June 20, 1986 Page 25 | ||
- | | ||
- | |||
- | |||
- | But in IBM PC BASIC, our implementation looks like: | ||
+ | But in IBM PC BASIC, our implementation looks like: | ||
+ | < | ||
100 DEFINT A-Z ' | 100 DEFINT A-Z ' | ||
2000 REM * V$ CONTAINS 133 CHARACTER COMPLETE XMODEM PACKET | 2000 REM * V$ CONTAINS 133 CHARACTER COMPLETE XMODEM PACKET | ||
Line 1014: | Line 776: | ||
4130 CRC$=CHR$(CRCH1)+CHR$(CRCL1) | 4130 CRC$=CHR$(CRCH1)+CHR$(CRCL1) | ||
4140 RETURN 'WHEW | 4140 RETURN 'WHEW | ||
+ | </ | ||
+ | That routine will execute 128 * 7 + 128 * 9 * 8 BASIC statements | ||
+ | for each Xmodem packet or 10112 statements per Xmodem packet! | ||
+ | will work for low baud rates in compiled BASIC, but just is too | ||
+ | much for interpretive BASIC. | ||
- | That routine will execute 128 * 7 + 128 * 9 * 8 BASIC statements | + | ==== BASIC Implementation of the Table Method ==== |
- | for each Xmodem packet or 10112 statements per Xmodem packet! | + | |
- | will work for low baud rates in compiled BASIC, but just is too | + | |
- | much for interpretive BASIC. | + | |
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | Xmodem, CRC Xmodem, WXmodem | ||
- | June 20, 1986 Page 26 | ||
- | | ||
- | |||
- | 7.3. BASIC Implementation of the Table Method | ||
- | |||
- | This method is based on routine M4 in Steven Satchell' | ||
- | "Test of CRC Routines for CRC-CCITT", | ||
- | cant differences. | ||
- | with the bit shift method is used to avoid performing the bit | ||
- | shift during communications. | ||
- | each byte value from 0 to 255 when the original CRC is zero. The | ||
- | result of this calculation is included in the DATA statements in | ||
- | the code. | ||
- | |||
- | The comments are intended to show what is logically happening | ||
- | rather than physically. | ||
- | integers in the 8088, a logical shift of 8 bits to the left is a | ||
- | physical shift of eight bits to the right! | ||
+ | This method is based on routine M4 in Steven Satchell' | ||
+ | "Test of CRC Routines for CRC-CCITT", | ||
+ | cant differences. | ||
+ | with the bit shift method is used to avoid performing the bit | ||
+ | shift during communications. | ||
+ | each byte value from 0 to 255 when the original CRC is zero. The | ||
+ | result of this calculation is included in the DATA statements in | ||
+ | the code. | ||
+ | The comments are intended to show what is logically happening | ||
+ | rather than physically. | ||
+ | integers in the 8088, a logical shift of 8 bits to the left is a | ||
+ | physical shift of eight bits to the right! | ||
+ | < | ||
200 DEFINT A-Z 'ALL INTEGERS | 200 DEFINT A-Z 'ALL INTEGERS | ||
210 DIM CRCTB(256) | 210 DIM CRCTB(256) | ||
Line 1081: | Line 833: | ||
9140 DATA -9219, | 9140 DATA -9219, | ||
9150 DATA 27814, 31879, 19684, 23749, 11298, 15363, 3168, 7233 | 9150 DATA 27814, 31879, 19684, 23749, 11298, 15363, 3168, 7233 | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | Xmodem, CRC Xmodem, WXmodem | ||
- | June 20, 1986 Page 27 | ||
- | | ||
- | |||
9160 DATA -4690, | 9160 DATA -4690, | ||
9170 DATA 32407, 28342, 24277, 20212, 15891, 11826, 7761, 3696 | 9170 DATA 32407, 28342, 24277, 20212, 15891, 11826, 7761, 3696 | ||
Line 1110: | Line 852: | ||
9410 DATA -4321, | 9410 DATA -4321, | ||
9420 DATA 28183, 32310, 20053, 24180, 11923, 16050, 3793, 7920 | 9420 DATA 28183, 32310, 20053, 24180, 11923, 16050, 3793, 7920 | ||
- | + | </ | |
- | + | This method uses 128 * 6 BASIC statements per Xmodem packet or a | |
- | | + | miserly 768 BASIC statements per packet. |
- | miserly 768 BASIC statements per packet. | + | code can be tightened still more. Unfortunately, |
- | code can be tightened still more. Unfortunately, | + | tightening that we could see would eliminate most of the already |
- | tightening that we could see would eliminate most of the already | + | limited readability of the code. |
- | limited readability of the code. | + | |
- | | + | ===== Notes and Comments ===== |
- | June 20, 1986 Page 28 | + | |
- | | + | |
- | 8. NOTES AND COMMENTS | + | Please add your notes and comments here or send them to me and I'll get |
+ | them added to the current copy on People/Link. | ||
- | | + | |
- | them added to the current copy on People/ | + | |
- | + | | |
- | | + | |
- | and SUBTRACT 32 on receive. | + | |
- | logic is the same on transmit and receive. | + | |
- | 2. The use of the SYN character was added at the request of several | + | |
- | | + | |
- | to improve their error recovery routines. | + | |
- | 3. The suggestion that ACK[sequence] be sent for every block received | + | |
- | was added. | + | |
- | 4. The original value for the ACK/NAK timeout was 10 seconds. | + | |
- | was changed to 15 seconds the situation where the receiver is | + | |
- | | + | |
- | | + | |
- | XMODEM and its derivatives have become the primary method for file | + | XMODEM and its derivatives have become the primary method for file |
- | | + | transfer for personal computers and is a popular error recovery type |
- | | + | protocol. Before learning more about Xmodem, it is important to hear |
- | | + | what its author has to say: |
"It was a quick hack I threw together, very unplanned (like | "It was a quick hack I threw together, very unplanned (like | ||
Line 1157: | Line 886: | ||
found in!" | found in!" | ||
- | | + | Ward Christensen, |
- | in 1985. Edited by Chuck Forsberg, " | + | in 1985. Edited by Chuck Forsberg, " |
- | Reference", | + | Reference", |
- | + | ||
- | The protocol is Asynchronous, | + | |
- | bit. | + | |
+ | The protocol is Asynchronous, | ||
===== See Also ===== | ===== See Also ===== | ||
Line 1170: | Line 896: | ||
{{tag> | {{tag> | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||