【正文】
allshoutjcx46 abort if no acknowledge Call Current Address Read function.mova, b get programmable addresscallread_currentjmpx47 exitx46:callstopx47:popbretstart: Send START, defined as hightolow SDA with SCL high. Return with SCL, SDA low. Returns CY set if bus is not available.setbSDAsetbSCL Verify bus available.jnbSDA, x40 jump if not highjnbSCL, x40 jump if not highnop enforce setup delay and cycle delayclrSDAnop enforce hold delaynopnopnopnopclrSCLclrc clear error flagjmpx41x40:setbc set error flagx41:retstop: Send STOP, defined as lowtohigh SDA with SCL high. SCL expected low on entry. Return with SCL, SDA high.clrSDAnop enforce SCL low and data setupnopsetbSCLnop enforce setup delaynopnopnopnopsetbSDAretshout: Shift out a byte to the AT24Cxx, most significant bit first. SCL, SDA expected low on entry. Return with SCL low. Called with data to send in A. Returns CY set to indicate failure by slave to acknowledge. Destroys A.pushbmovb, 8 bit counterx42:rlca move bit into CYmovSDA, c output bitnop enforce SCL low and data setupsetbSCL raise clocknop enforce SCL highnopnopnopclrSCL drop clockdjnzb, x42 next bitsetbSDA release SDA for ACKnop enforce SCL low and tAAnopsetbSCL raise ACK clocknop enforce SCL highnopnopnopmovc, SDA get ACK bitclrSCL drop ACK clockpopbretshin: Shift in a byte from the AT24Cxx, most significant bit first. SCL expected low on entry. Return with SCL low. Returns received data byte in A.setbSDA make SDA an inputpushbmovb, 8 bit countx43:nop enforce SCL low and data setupnopnopsetbSCL raise clocknop enforce SCL highnopmovc, SDA input bitrlca move bit into byteclrSCL drop clockdjnzb, x43 next bitpopbretACK: Clock out an acknowledge bit (low). SCL expected low on entry. Return with SCL, SDA low.clrSDA ACK bitnop enforce SCL low and data setupnopsetbSCL raise clocknop enforce SCL highnopnopnopclrSCL drop clockretNAK: Clock out a negative acknowledge bit (high). SCL expected low on entry. Return with SCL low, SDA high.setbSDA NAK bitnop enforce SCL low and data setupnopsetbSCL raise clocknop enforce SCL highnopnopnopclrSCL drop clockretEND