А это точно побитно-доступный регистр ? В даташите написано:
Not Bit Adressable
page 10 Table 6-1
Моя прога - на С.
Вот она:
<pre>
#if FLASH_TIPE == AT89S8253_INT
data byte *pxdata;
/*-------------------------------------*/
void make_pxdata (word toff)
{
pxdata = (byte *) (0x010000 or ((ad shl 1) + (toff shl 1)));
}
/*-------------------------------------*/
/* читаем внутреннийй EEPROM 8253 */
void read_flash_ (word tabl_off)
{
make_pxdata (tabl_off);
DI
EECON or= 1 << EEMEN;
EI
DATAWH = *pxdata++;
DATAWL = *pxdata;
DI
EECON and= ~(1 << EEMEN);
EI
}
/*-------------------------------------*/
void eeprom_rdy (void)
{
for (;;) {if ((EECON and (1 << EERDY)) != 0) break;}
}
/*-------------------------------------*/
void eeprom_rdy0 (void)
{
for (;;) {if ((EECON and (1 << EERDY)) == 0) break;}
}
/*-------------------------------------*/
/* пишем внутренний EEPROM 8253 */
void write_flash_ (word tabl_off)
{
make_pxdata (tabl_off);
DI
EECON or= (1 << EEMEN) or (1 << EEMWE);
EI
eeprom_rdy (); *pxdata++ = DATAWH; eeprom_rdy0 ();
eeprom_rdy (); *pxdata = DATAWL; eeprom_rdy0 ();
eeprom_rdy ();
DI
EECON and= ~((1 << EEMEN) or (1 << EEMWE));
EI
}
/*-------------------------------------*/
#endif
</pre>
Что привело к следующему ассемблерному воплощению:
<pre>
#if FLASH_TIPE == AT89S8253_INT
; 387. data byte *pxdata;
; 388. /*-------------------------------------*/
; 389. void make_pxdata (word toff)
; 390. {
make_pxdata:
; 391. pxdata = (byte *) (0x010000 or ((ad shl 1) + (toff shl 1)));
CLR C
MOV A,R7
RLC A
MOV R7,A
MOV A,R6
RLC A
MOV R6,A
CLR C
MOV A,ad+1
MOV R3,ad
RLC A
XCH A,R3
RLC A
XCH A,R3
ADD A,R7
MOV R7,A
MOV A,R6
ADDC A,R3
MOV R6,A
CLR A
MOV R5,A
MOV R4,A
MOV R3,#0
MOV R2,#0
MOV R1,#1
MOV R0,#0
LCALL ?L_IOR_L01
MOV pxdata,R5
MOV pxdata+1,R6
MOV pxdata+2,R7
; 392. }
RET
; 393. /*-------------------------------------*/
; 394. /* читаем внутреннийй EEPROM 8253 */
; 395. void read_flash_ (word tabl_off)
; 396. {
read_flash_:
MOV $LOCBD read_flash_+1,R7
MOV $LOCBD read_flash_,R6
; 397. make_pxdata (tabl_off);
MOV R7,$LOCBD read_flash_+1
MOV R6,$LOCBD read_flash_
LCALL $REFFN make_pxdata
; 398.
; 399. DI
CLR IE.7
; 400. EECON or= 1 << EEMEN;
ORL 150,#8
; 401. EI
SETB IE.7
; 402.
; 403. DATAWH = *pxdata++;
MOV R1,pxdata
MOV R2,pxdata+1
INC pxdata+2
MOV A,pxdata+2
JNZ $+4
INC pxdata+1
DEC A
MOV R3,A
LCALL ?C_LD_PTR_L17
MOV w1,R7
; 404. DATAWL = *pxdata;
MOV R3,pxdata+2
MOV R2,pxdata+1
MOV R1,pxdata
LCALL ?C_LD_PTR_L17
MOV w1+1,R7
; 405.
; 406. DI
CLR IE.7
; 407. EECON and= ~(1 << EEMEN);
ANL 150,#247
; 408. EI
SETB IE.7
; 409. }
RET
; 410. /*-------------------------------------*/
; 411. void eeprom_rdy (void)
; 412. {
eeprom_rdy:
?0011:
; 413. for (;;) {if ((EECON and (1 << EERDY)) != 0) break;}
MOV A,150
ANL A,#2
JZ ?0013
?0012:
SJMP ?0010
?0013:
; 414. }
SJMP ?0011
?0010:
RET
; 415. /*-------------------------------------*/
; 416. void eeprom_rdy0 (void)
; 417. {
eeprom_rdy0:
?0015:
; 418. for (;;) {if ((EECON and (1 << EERDY)) == 0) break;}
MOV A,150
ANL A,#2
JNZ ?0017
?0016:
SJMP ?0014
?0017:
; 419. }
SJMP ?0015
?0014:
RET
; 420. /*-------------------------------------*/
; 421. /* пишем внутренний EEPROM 8253 */
; 422. void write_flash_ (word tabl_off)
; 423. {
write_flash_:
MOV $LOCBD write_flash_+1,R7
MOV $LOCBD write_flash_,R6
; 424. make_pxdata (tabl_off);
MOV R7,$LOCBD write_flash_+1
MOV R6,$LOCBD write_flash_
LCALL $REFFN make_pxdata
; 425.
; 426. DI
CLR IE.7
; 427. EECON or= (1 << EEMEN) or (1 << EEMWE);
ORL 150,#24
; 428. EI
SETB IE.7
; 429.
; 430. eeprom_rdy (); *pxdata++ = DATAWH; eeprom_rdy0 ();
LCALL $REFFN eeprom_rdy
MOV R1,pxdata
MOV R2,pxdata+1
INC pxdata+2
MOV A,pxdata+2
JNZ $+4
INC pxdata+1
DEC A
MOV R3,A
MOV R7,w1
LCALL ?C_ST_PTR_L17
LCALL $REFFN eeprom_rdy0
; 431. eeprom_rdy (); *pxdata = DATAWL; eeprom_rdy0 ();
LCALL $REFFN eeprom_rdy
MOV R7,w1+1
MOV R3,pxdata+2
MOV R2,pxdata+1
MOV R1,pxdata
LCALL ?C_ST_PTR_L17
LCALL $REFFN eeprom_rdy0
; 432. eeprom_rdy ();
LCALL $REFFN eeprom_rdy
; 433.
; 434. DI
CLR IE.7
; 435. EECON and= ~((1 << EEMEN) or (1 << EEMWE));
ANL 150,#231
; 436. EI
SETB IE.7
; 437. }
RET
; 438. /*-------------------------------------*/
; 439. #endif
RSEG D_UDATA
pxdata:
DS 3
END
</pre>