#include <reg51.h>
#define uchar unsigned char #define uint unsigned int
code const uint DaiMaTab[]= { //....... };
code const uchar NumTab[]= { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' }; code const uchar *FsrReg[]= { "INDF ", "T0CNT ", "PCL ", "STATUS ", "FSR ", "PAD ", "PBD ", "PCD ", "CLKCON ", "WDTE ", "PWRDN ", "INTCON ", "INPND ", "PINTD ", "T0CON ", "T0DATA ", "PWM0CON", "PWM0DAT", "PWM1CON", "PWM1DAT", "BZCON ", "PACONL ", "PACONH ", "PBCON ", "PCCONL ", "PCCONH ", "ADCCON ", "ADCDATL", "ADCDATH", " ", "GPR0 ", "GPR1 " }; void IntCom(void) { PCON=0x00; SCON=0x50; TMOD=0x20; TH1=0xFD; TL1=0xFD; TR1=1; ES=0; EA=0; }
void SendByte(uchar Byte) { SBUF=Byte; while(!TI); TI=0; }
void SendMany(uchar *String,Count) { uchar i; for(i=0;i<Count;i++) { SendByte(String); } }
void Delayms(uint ms) { uint i,j; for(i=0;i<ms;i++) for(j=0;j<120;j++) ; }
void main(void) { uchar Temp,Temp1; uint Addr=0; uint TempInt; IntCom(); Delayms(100); SendMany("INDF EQU 00H ",20); SendMany("\r",2); Delayms(100); SendMany("T0CNT EQU 01H ",20); SendMany("\r",2); Delayms(100); SendMany("PCL EQU 02H ",20); SendMany("\r",2); Delayms(100); SendMany("STATUS EQU 03H ",20); SendMany("\r",2); Delayms(100); SendMany("FSR EQU 04H ",20); SendMany("\r",2); Delayms(100); SendMany("PAD EQU 05H ",20); SendMany("\r",2); Delayms(100); SendMany("PBD EQU 06H ",20); SendMany("\r",2); Delayms(100); SendMany("PCD EQU 07H ",20); SendMany("\r",2); Delayms(100); SendMany("CLKCON EQU 08H ",20); SendMany("\r",2); Delayms(100); SendMany("WDTE EQU 09H ",20); SendMany("\r",2); Delayms(100); SendMany("PWRDN EQU 0AH ",20); SendMany("\r",2); Delayms(100); SendMany("INTCON EQU 0BH ",20); SendMany("\r",2); Delayms(100); SendMany("INPND EQU 0CH ",20); SendMany("\r",2); Delayms(100); SendMany("PINTD EQU 0DH ",20); SendMany("\r",2); Delayms(100); SendMany("T0CON EQU 0EH ",20); SendMany("\r",2); Delayms(100); SendMany("T0DATA EQU 0FH ",20); SendMany("\r",2); Delayms(100); SendMany("PWM0CON EQU 10H ",20); SendMany("\r",2); Delayms(100); SendMany("PWM0DAT EQU 11H ",20); SendMany("\r",2); Delayms(100); SendMany("PWM1CON EQU 12H ",20); SendMany("\r",2); Delayms(100); SendMany("PWM1DAT EQU 13H ",20); SendMany("\r",2); Delayms(100); SendMany("BZCON EQU 14H ",20); SendMany("\r",2); Delayms(100); SendMany("PACONL EQU 15H ",20); SendMany("\r",2); Delayms(100); SendMany("PACONH EQU 16H ",20); SendMany("\r",2); Delayms(100); SendMany("PBCON EQU 17H ",20); SendMany("\r",2); Delayms(100); SendMany("PCCONL EQU 18H ",20); SendMany("\r",2); Delayms(100); SendMany("PCCONH EQU 19H ",20); SendMany("\r",2); Delayms(100); SendMany("ADCCON EQU 1AH ",20); SendMany("\r",2); Delayms(100); SendMany("ADCDATL EQU 1BH ",20); SendMany("\r",2); Delayms(100); SendMany("ADCDATH EQU 1CH ",20); SendMany("\r",2); Delayms(100); SendMany("GPR0 EQU 1EH ",20); SendMany("\r",2); Delayms(100); SendMany("GPR1 EQU 1FH ",20); SendMany("\r",2); Delayms(100); SendMany(" ORG 000H ",20); SendMany("\r",2); Delayms(100); while(1) { if(Addr<1052) { TempInt=Addr; } else { if(Addr==1052) { SendMany(" ORG 700H ",20); SendMany("\r",2); Delayms(100); } TempInt=(Addr+740); } SendMany("_",1); Temp=(uchar)((TempInt&0x0F00)>>8); SendMany(&NumTab[Temp],1); Temp=(uchar)((TempInt&0x00F0)>>4); SendMany(&NumTab[Temp],1); Temp=(uchar)((TempInt&0x000F)); SendMany(&NumTab[Temp],1); SendMany(": ",2); Temp=(uchar)(DaiMaTab[Addr]>>12); if(Temp>1) { if(Temp==3) { SendMany("GOTO ",5); SendMany("_",1); Temp=(uchar)((DaiMaTab[Addr]&0x0FFF)>>8); SendMany(&NumTab[Temp],1); Temp=(uchar)((DaiMaTab[Addr]&0x00FF)>>4); SendMany(&NumTab[Temp],1); Temp=(uchar)(DaiMaTab[Addr]&0x000F); SendMany(&NumTab[Temp],1); SendMany(" ",3); } else if(Temp==2) { SendMany("CALL ",5); SendMany("_",1); Temp=(uchar)((DaiMaTab[Addr]&0x0FFF)>>8); SendMany(&NumTab[Temp],1); Temp=(uchar)((DaiMaTab[Addr]&0x00FF)>>4); SendMany(&NumTab[Temp],1); Temp=(uchar)(DaiMaTab[Addr]&0x000F); SendMany(&NumTab[Temp],1); SendMany(" ",3); } } else { Temp=(uchar)(DaiMaTab[Addr]>>8); Temp1=(uchar)(DaiMaTab[Addr]&0x00FF); switch(Temp) { case 0x00: if((Temp1&0x80)>0) { SendMany("MOVWF ",6); if((Temp1&0x7F)>0x1F) { SendMany(&NumTab[(Temp1&0x70)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x7F],7); } //SendMany(" ",3); } else if(Temp1==0x00) SendMany("NOP ",12); else if(Temp1==0x40) SendMany("RET ",12); else if(Temp1==0x60) SendMany("RETI ",12); else if(Temp1==0x89) SendMany("CLRWDT ",12); else if(Temp1==0x1A) SendMany("SLEEP ",12); break;
case 0x01: if(Temp1==0x40) { SendMany("CLRW ",12); } else if((Temp1&0x80)>0) { SendMany("CLRF ",5); if((Temp1&0x7F)>0x1F) { SendMany(&NumTab[(Temp1&0x70)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x7F],7); } //SendMany(" ",4); } break; case 0x02: SendMany("SUBWF ",6); if((Temp1&0x7F)>0x1F) { SendMany(&NumTab[(Temp1&0x70)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x7F],7); } SendMany(",",1); if((Temp1&0x80)==0) SendMany("0",1); else SendMany("1",1); //SendMany(" ",1); break; case 0x03: SendMany("DECF ",5); if((Temp1&0x7F)>0x1F) { SendMany(&NumTab[(Temp1&0x70)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x7F],7); } SendMany(",",1); if((Temp1&0x80)==0) SendMany("0",1); else SendMany("1",1); //SendMany(" ",2); break; case 0x04: SendMany("IORWF ",6); if((Temp1&0x7F)>0x1F) { SendMany(&NumTab[(Temp1&0x70)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x7F],7); } SendMany(",",1); if((Temp1&0x80)==0) SendMany("0",1); else SendMany("1",1); //SendMany(" ",1); break; case 0x05: SendMany("ANDWF ",6); if((Temp1&0x7F)>0x1F) { SendMany(&NumTab[(Temp1&0x70)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x7F],7); } SendMany(",",1); if((Temp1&0x80)==0) SendMany("0",1); else SendMany("1",1); //SendMany(" ",1); break; case 0x06: SendMany("XORWF ",6); if((Temp1&0x7F)>0x1F) { SendMany(&NumTab[(Temp1&0x70)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x7F],7); } SendMany(",",1); if((Temp1&0x80)==0) SendMany("0",1); else SendMany("1",1); //SendMany(" ",1); break; case 0x07: SendMany("ADDWF ",6); if((Temp1&0x7F)>0x1F) { SendMany(&NumTab[(Temp1&0x70)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x7F],7); } SendMany(",",1); if((Temp1&0x80)==0) SendMany("0",1); else SendMany("1",1); //SendMany(" ",1); break; case 0x08: if((Temp1&0x80)==0) { SendMany("MOVFW ",6); if((Temp1&0x7F)>0x1F) { SendMany(&NumTab[(Temp1&0x70)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x7F],7); } //SendMany(" ",3); } else { SendMany("TESTZ ",6); if((Temp1&0x7F)>0x1F) { SendMany(&NumTab[(Temp1&0x70)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x7F],7); } SendMany(" ",3); } break; case 0x09: SendMany("COMF ",5); if((Temp1&0x7F)>0x1F) { SendMany(&NumTab[(Temp1&0x70)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x7F],7); } SendMany(",",1); if((Temp1&0x80)==0) SendMany("0",1); else SendMany("1",1); //SendMany(" ",2); break; case 0x0A: SendMany("INCF ",5); if((Temp1&0x7F)>0x1F) { SendMany(&NumTab[(Temp1&0x70)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x7F],7); } SendMany(",",1); if((Temp1&0x80)==0) SendMany("0",1); else SendMany("1",1); //SendMany(" ",2); break; case 0x0B: SendMany("DECFSZ ",7); if((Temp1&0x7F)>0x1F) { SendMany(&NumTab[(Temp1&0x70)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x7F],7); } SendMany(",",1); if((Temp1&0x80)==0) SendMany("0",1); else SendMany("1",1); break; case 0x0C: SendMany("RRF ",4); if((Temp1&0x7F)>0x1F) { SendMany(&NumTab[(Temp1&0x70)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x7F],7); } SendMany(",",1); if((Temp1&0x80)==0) SendMany("0",1); else SendMany("1",1); //SendMany(" ",3); break; case 0x0D: SendMany("RLF ",4); if((Temp1&0x7F)>0x1F) { SendMany(&NumTab[(Temp1&0x70)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x7F],7); } SendMany(",",1); if((Temp1&0x80)==0) SendMany("0",1); else SendMany("1",1); //SendMany(" ",3); break; case 0x0E: SendMany("SWAPF ",6); if((Temp1&0x7F)>0x1F) { SendMany(&NumTab[(Temp1&0x70)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x7F],7); } SendMany(",",1); if((Temp1&0x80)==0) SendMany("0",1); else SendMany("1",1); //SendMany(" ",1); break; case 0x0F: SendMany("INCFSZ ",7); if((Temp1&0x7F)>0x1F) { SendMany(&NumTab[(Temp1&0x70)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x7F],7); } SendMany(",",1); if((Temp1&0x80)==0) SendMany("0",1); else SendMany("1",1); break; case 0x10: SendMany("BCF ",4); if((Temp1&0x3F)>0x1F) { SendMany(&NumTab[(Temp1&0x30)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x3F],7); } SendMany(",",1); SendMany(&NumTab[(Temp1>>6)],1); //SendMany(" ",3); break; case 0x11: SendMany("BCF ",4); if((Temp1&0x3F)>0x1F) { SendMany(&NumTab[(Temp1&0x30)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x3F],7); } SendMany(",",1); SendMany(&NumTab[((Temp1>>6)|0x04)],1); //SendMany(" ",3); break; case 0x12: SendMany("BSF ",4); if((Temp1&0x3F)>0x1F) { SendMany(&NumTab[(Temp1&0x30)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x3F],7); } SendMany(",",1); SendMany(&NumTab[(Temp1>>6)],1); //SendMany(" ",3); break; case 0x13: SendMany("BSF ",4); if((Temp1&0x3F)>0x1F) { SendMany(&NumTab[(Temp1&0x30)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x3F],7); } SendMany(",",1); SendMany(&NumTab[((Temp1>>6)|0x04)],1); //SendMany(" ",3); break; case 0x14: SendMany("BTFSC ",6); if((Temp1&0x3F)>0x1F) { SendMany(&NumTab[(Temp1&0x30)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x3F],7); } SendMany(",",1); SendMany(&NumTab[(Temp1>>6)],1); //SendMany(" ",1); break; case 0x15: SendMany("BTFSC ",6); if((Temp1&0x3F)>0x1F) { SendMany(&NumTab[(Temp1&0x30)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x3F],7); } SendMany(",",1); SendMany(&NumTab[((Temp1>>6)|0x04)],1); //SendMany(" ",1); break; case 0x16: SendMany("BTFSS ",6); if((Temp1&0x3F)>0x1F) { SendMany(&NumTab[(Temp1&0x30)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x3F],7); } SendMany(",",1); SendMany(&NumTab[(Temp1>>6)],1); //SendMany(" ",1); break; case 0x17: SendMany("BTFSS ",6); if((Temp1&0x3F)>0x1F) { SendMany(&NumTab[(Temp1&0x30)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); } else { SendMany(FsrReg[Temp1&0x3F],7); } SendMany(",",1); SendMany(&NumTab[(Temp1>>6)|0x04],1); //SendMany(" ",1); break; case 0x18: SendMany("RETLW ",6); SendMany(&NumTab[(Temp1&0xF0)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); SendMany(" ",3); break; case 0x19: SendMany("MOVLW ",6); SendMany(&NumTab[(Temp1&0xF0)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); SendMany(" ",3); break; case 0x1A: SendMany("IORLW ",6); SendMany(&NumTab[(Temp1&0xF0)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); SendMany(" ",3); case 0x1B: SendMany("ANDLW ",6); SendMany(&NumTab[(Temp1&0xF0)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); SendMany(" ",3); break; case 0x1C: SendMany("ADDLW ",6); SendMany(&NumTab[(Temp1&0xF0)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); SendMany(" ",3); break; case 0x1F: SendMany("XORLW ",6); SendMany(&NumTab[(Temp1&0xF0)>>4],1); SendMany(&NumTab[(Temp1&0x0F)],1); SendMany("H",1); SendMany(" ",3); break; default: SendMany("ERROOR//////",12); P0=0; do{}while(1); break; } } //SendMany(" ",8); SendMany(" ;",2); /*Temp=(uchar)((DaiMaTab[Addr]&0xF000)>>12); SendMany(&NumTab[Temp],1); Temp=(uchar)((DaiMaTab[Addr]&0x0F00)>>8); SendMany(&NumTab[Temp],1); Temp=(uchar)((DaiMaTab[Addr]&0x00F0)>>4); SendMany(&NumTab[Temp],1); Temp=(uchar)((DaiMaTab[Addr]&0x000F)); SendMany(&NumTab[Temp],1);*/ //SendMany(" ",5); //SendMany(" ",36); SendMany("\r",2); Delayms(100); Addr++; if(Addr>1161) { SendMany("END",3); do{}while(1); Addr=0; } } }
|