虫虫首页|资源下载|资源专辑|精品软件
登录|注册

GOTO

  • 大厦游览图,通过命令行来实现 System.out.println("where 显示当前在什么地方") System.out.println("list 列出当前位置的物品") S

    大厦游览图,通过命令行来实现 System.out.println("where 显示当前在什么地方") System.out.println("list 列出当前位置的物品") System.out.println("list allspots 列出大厦内所有地点") System.out.println("list spots 列出当前位置附近的地点") System.out.println("list goods 列出当前位置的物品") System.out.println("GOTO someplace 到另一个地点") System.out.println("look somegoods 查询某个物品是否在当前地点") System.out.println("help 命令行帮助") System.out.println("exit 退出命令行")

    标签: println System out where

    上传时间: 2015-12-08

    上传用户:Miyuki

  • 第三章 程序流程控制 主要内容1、if…else…选择语句。 2、条件运算符。 3、SWITCH开关分支语句。 4、逻辑运算符。 5、循环语句。 6、自增自减运算。 7、break、co

    第三章 程序流程控制 主要内容1、if…else…选择语句。 2、条件运算符。 3、SWITCH开关分支语句。 4、逻辑运算符。 5、循环语句。 6、自增自减运算。 7、break、continue、GOTO语句 8、运算符的优先级、结合性。

    标签: SWITCH break else 运算符

    上传时间: 2016-01-14

    上传用户:stampede

  • 这个C++程序

    这个C++程序,可以转换如Fortran 77程序到C++可用程序,当然,还有一些例外,如Fortan中的FORMAT语句,以及GOTO语句可能使得你的代码很长。你可以通过配置,让转换程序进行批量的语言转换。

    标签: 程序

    上传时间: 2013-12-16

    上传用户:epson850

  • c语言实现

    c语言实现,slr(1)语法分析,语法分析的ation表和GOTO表分别用txt文档保存。

    标签: c语言

    上传时间: 2016-10-10

    上传用户:努力努力再努力

  • gcclib This gcc 1.40 suits for Linux kernel 0.11 - 0.95 Installtion hints -----------------

    gcclib This gcc 1.40 suits for Linux kernel 0.11 - 0.95 Installtion hints ----------------- This suit contains include.taz, local.taz and this README file. You must download the bootimage and rootimage and install them first. The include.taz contains all the include files for using with gcc 1.40. The local.taz contains all the gcc tools & libs stored in two sepearted directories: /usr/local/lib /usr/local/bin You should copy the linux/ asm/ sys/ subdirectories into the include directory from the corresponding kernel source. Installation ------------ GOTO the /usr directory. Untar the include.taz to the directory /usr/include. Untar the local.taz to the directory /usr/local. That s it! Example: -------- cd /usr tar zxvf include.taz tar zxvf local.taz

    标签: Installtion gcclib kernel Linux

    上传时间: 2014-03-12

    上传用户:源码3

  • pic延时子程序

    pic延时子程序,同过.EXE文件取出的值替换下面的代码,就能很好的实现延时。 1层循环例程: movlw 0x00 取值 movwf n0 incfsz n0 GOTO $-1 return 2层循环例程: movlw 0x11 外层 movwf n1 movlw 0x00 里层 movwf n0 incfsz n0 GOTO $-1 incfsz n1 GOTO $-5 return

    标签: pic 延时 程序

    上传时间: 2013-12-19

    上传用户:lixinxiang

  • 垃圾文件清理: 垃圾文件清理: 垃圾文件清理 Clean Windows Programs: :rd_dir if " R:~-2,1 "=="" set R=" R:~1,-2 "

    垃圾文件清理: 垃圾文件清理: 垃圾文件清理 Clean Windows Programs: :rd_dir if " R:~-2,1 "=="\" set R=" R:~1,-2 " if not exist R GOTO :DD cd /d R for /f "delims=" a in ( dir/ad/b ) do rd /s /q " a" del /f /s /q * cdrd /s /q R :DD Clean Windows Programs: :rd_dir if " R:~-2,1 "=="\" set R=" R:~1,-2 " if not exist R GOTO :DD cd /d R for /f "delims=" a in ( dir/ad/b ) do rd /s /q " a" del /f /s /q * cdrd /s /q R :DD

    标签: Programs Windows rd_dir Clean

    上传时间: 2017-04-20

    上传用户:lanhuaying

  • c语言深度剖析

    第一章关键字...................................................................................................................................9 1.1,最宽恒大量的关键字----auto..........................................................................................11 1.2,最快的关键字---- register............................................................................................... 11 1.2.1,皇帝身边的小太监----寄存器............................................................................. 11 1.2.2,使用register 修饰符的注意点.............................................................................11 1.3,最名不符实的关键字----static........................................................................................12 1.3.1,修饰变量...............................................................................................................12 1.3.2,修饰函数...............................................................................................................13 1.4,基本数据类型----short、int、long、char、float、double........................................... 13 1.4.1,数据类型与“模子”............................................................................................... 14 1.4.2,变量的命名规则...................................................................................................14 1.5,最冤枉的关键字----sizeof...............................................................................................18 1.5.1,常年被人误认为函数...........................................................................................18 1.5.2,sizeof(int)*p 表示什么意思?........................................................................18 1.4,signed、unsigned 关键字................................................................................................19 1.6,if、else 组合.................................................................................................................... 20 1.6.1,bool 变量与“零值”进行比较...............................................................................20 1.6.2, float 变量与“零值”进行比较.................................................................................21 1.6.3,指针变量与“零值”进行比较...............................................................................21 1.6.4,else 到底与哪个if 配对呢?...............................................................................22 1.6.5,if 语句后面的分号............................................................................................... 23 1.6.6,使用if 语句的其他注意事项.............................................................................. 24 1.7,switch、case 组合........................................................................................................... 24 1.7.1,不要拿青龙偃月刀去削苹果.............................................................................. 24 1.7.2,case 关键字后面的值有什么要求吗?.............................................................. 25 1.7.3,case 语句的排列顺序...........................................................................................25 1.7.4,使用case 语句的其他注意事项..........................................................................27 1.8,do、while、for 关键字................................................................................................... 28 1.8.1,break 与continue 的区别.....................................................................................28 1.8.2,循环语句的注意点...............................................................................................29 1.9,GOTO 关键字......................................................................................................................30 1.10,void 关键字....................................................................................................................31 1.10.1,void a?............................................................................................................31 1.10,return 关键字................................................................................................................. 34 1.11,const 关键字也许该被替换为readolny....................................................................... 34 1.11.2,节省空间,避免不必要的内存分配,同时提高效率.................................... 35 1.12,最易变的关键字----volatile.......................................................................................... 36 1.13,最会带帽子的关键字----extern.................................................................................... 37 1.14,struct 关键字..................................................................................................................38

    标签: c语言深度剖析

    上传时间: 2015-05-01

    上传用户:cascas

  • 运动会源代码

    #include <malloc.h>       #include <stdio.h>       #include <stdlib.h>       #include <string.h>       #define NULL 0      #define MaxSize 30          typedef struct athletestruct /*运动员*/     {         char name[20];          int score; /*分数*/         int range; /**/         int item; /*项目*/     }ATH;     typedef struct schoolstruct /*学校*/     {         int count; /*编号*/         int serial; /**/          int menscore; /*男选手分数*/         int womenscore; /*女选手分数*/         int totalscore; /*总分*/         ATH athlete[MaxSize]; /**/         struct schoolstruct *next;      }SCH;         int nsc,msp,wsp;      int ntsp;      int i,j;      int overgame;      int serial,range;      int n;      SCH *head,*pfirst,*psecond;      int *phead=NULL,*pafirst=NULL,*pasecond=NULL;     void create();         void input ()     {         char answer;          head = (SCH *)malloc(sizeof(SCH)); /**/         head->next = NULL;         pfirst = head;          answer = 'y';         while ( answer == 'y' )         {         Is_Game_DoMain:         printf("\nGET Top 5 when odd\nGET Top 3 when even");         printf("\n输入运动项目序号 (x<=%d):",ntsp);         scanf("%d",pafirst);         overgame = *pafirst;         if ( pafirst != phead )         {             for ( pasecond = phead ; pasecond < pafirst ; pasecond ++ )             {                 if ( overgame == *pasecond )                 {                     printf("\n这个项目已经存在请选择其他的数字\n");                     GOTO Is_Game_DoMain;                 }             }         }         pafirst = pafirst + 1;         if ( overgame > ntsp )         {             printf("\n项目不存在");             printf("\n请重新输入");             GOTO Is_Game_DoMain;         }         switch ( overgame%2 )         {         case 0: n = 3;break;         case 1: n = 5;break;         }         for ( i = 1 ; i <= n ; i++ )         {         Is_Serial_DoMain:         printf("\n输入序号 of the NO.%d (0<x<=%d): ",i,nsc);                 scanf("%d",&serial);         if ( serial > nsc )          {             printf("\n超过学校数目,请重新输入");             GOTO Is_Serial_DoMain;         }         if ( head->next == NULL )          {             create();         }         psecond = head->next ;          while ( psecond != NULL )          {             if ( psecond->serial == serial )             {                 pfirst = psecond;                 pfirst->count = pfirst->count + 1;                 GOTO Store_Data;             }             else             {                 psecond = psecond->next;             }         }         create();         Store_Data:                 pfirst->athlete[pfirst->count].item = overgame;         pfirst->athlete[pfirst->count].range = i;         pfirst->serial = serial;         printf("Input name:) : ");                 scanf("%s",pfirst->athlete[pfirst->count].name);         }         printf("\n继续输入运动项目(y&n)?");         answer = getchar();         printf("\n");         }     }         void calculate() /**/     {         pfirst = head->next;         while ( pfirst->next != NULL )         {             for (i=1;i<=pfirst->count;i++)             {                 if ( pfirst->athlete[i].item % 2 == 0 )                  {                     switch (pfirst->athlete[i].range)                     {                     case 1:pfirst->athlete[i].score = 5;break;                     case 2:pfirst->athlete[i].score = 3;break;                     case 3:pfirst->athlete[i].score = 2;break;                     }                 }                 else                  {                     switch (pfirst->athlete[i].range)                     {                     case 1:pfirst->athlete[i].score = 7;break;                     case 2:pfirst->athlete[i].score = 5;break;                     case 3:pfirst->athlete[i].score = 3;break;                     case 4:pfirst->athlete[i].score = 2;break;                     case 5:pfirst->athlete[i].score = 1;break;                     }                 }                 if ( pfirst->athlete[i].item <=msp )                  {                     pfirst->menscore = pfirst->menscore + pfirst->athlete[i].score;                 }                 else                  {                     pfirst->womenscore = pfirst->womenscore + pfirst->athlete[i].score;                 }             }             pfirst->totalscore = pfirst->menscore + pfirst->womenscore;             pfirst = pfirst->next;         }     }         void output()     {         pfirst = head->next;         psecond = head->next;         while ( pfirst->next != NULL )          {             // clrscr();              printf("\n第%d号学校的结果成绩:",pfirst->serial);             printf("\n\n项目的数目\t学校的名字\t分数");             for (i=1;i<=ntsp;i++)              {                 for (j=1;j<=pfirst->count;j++)                  {                     if ( pfirst->athlete[j].item == i )                     {                                                                         printf("\n %d\t\t\t\t\t\t%s\n %d",i,pfirst->athlete[j].name,pfirst->athlete[j].score);break;                                             }                 }             }             printf("\n\n\n\t\t\t\t\t\t按任意建 进入下一页");             getchar();             pfirst = pfirst->next;         }     //  clrscr();          printf("\n运动会结果:\n\n学校编号\t男运动员成绩\t女运动员成绩\t总分");         pfirst = head->next;         while ( pfirst->next != NULL )         {             printf("\n %d\t\t %d\t\t %d\t\t %d",pfirst->serial,pfirst->menscore,pfirst->womenscore,pfirst->totalscore);             pfirst = pfirst->next;         }         printf("\n\n\n\t\t\t\t\t\t\t按任意建结束");         getchar();     }         void create()     {                 pfirst = (struct schoolstruct *)malloc(sizeof(struct schoolstruct));         pfirst->next = head->next ;         head->next = pfirst ;                 pfirst->count = 1;         pfirst->menscore = 0;         pfirst->womenscore = 0;         pfirst->totalscore = 0;     }     void Save()     {FILE *fp;     if((fp = fopen("school.dat","wb"))==NULL)     {printf("can't open school.dat\n");     fclose(fp);     return;     }     fwrite(pfirst,sizeof(SCH),10,fp);     fclose(fp);     printf("文件已经成功保存\n");     }         void main()     {         system("cls");         printf("\n\t\t\t 运动会分数统计\n");         printf("输入学校数目 (x>= 5):");         scanf("%d",&nsc);          printf("输入男选手的项目(x<=20):");         scanf("%d",&msp);          printf("输入女选手项目(<=20):");         scanf("%d",&wsp);          ntsp = msp + wsp;                  phead = (int *)calloc(ntsp,sizeof(int));         pafirst = phead;         pasecond = phead;         input();         calculate();          output();         Save();     }             

    标签: 源代码

    上传时间: 2016-12-28

    上传用户:150501

  • 12345

    /****************temic*********t5557***********************************/    #include   <at892051.h>     #include   <string.h>    #include   <intrins.h>     #include   <stdio.h>     #define    uchar    unsigned char     #define    uint     unsigned int     #define    ulong    unsigned long     //STC12C2051AD的SFR定义     sfr  WDT_CONTR = 0xe1;//stc2051的看门狗??????     /**********全局常量************/    //写卡的命令     #define    write_command0       0//写密码     #define    write_command1       1//写配置字     #define    write_command2       2//密码写数据     #define    write_command3       3//唤醒     #define    write_command4       4//停止命令     #define    TRUE       1     #define    FALSE      0     #define    OK         0     #define    ERROR      255     //读卡的时间参数us     #define ts_min          250//270*11.0592/12=249//取近似的整数     #define ts_max          304//330*11.0592/12=304     #define t1_min          73//90*11.0592/12=83:-10调整     #define t1_max          156//180*11.0592/12=166     #define t2_min          184//210*11.0592/12=194     #define t2_max          267//300*11.0592/12=276     //***********不采用中断处理:采用查询的方法读卡时关所有中断****************/     sbit p_U2270B_Standby = P3^5;//p_U2270B_Standby PIN=13     sbit p_U2270B_CFE = P3^3;//p_U2270B_CFE     PIN=6     sbit p_U2270B_OutPut = P3^7;//p_U2270B_OutPut  PIN=2     sbit wtd_sck = P1^7;//SPI总线     sbit wtd_si = P1^3;    sbit wtd_so = P1^2;    sbit iic_data = P1^2;//lcd IIC     sbit iic_clk = P1^7;    sbit led_light = P1^6;//测试绿灯     sbit led_light1 = P1^5;//测试红灯     sbit led_light_ok  = P1^1;//读卡成功标志     sbit fengmingqi = P1^5;    /***********全局变量************************************/       uchar data Nkey_a[4] = {0xA0, 0xA1, 0xA2, 0xA3};//初始密码             //uchar idata card_snr[4];   //配置字     uchar data bankdata[28] = {1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7};     //存储卡上用户数据(1-7)7*4=28     uchar data cominceptbuff[6] = {1,2,3,4,5,6};//串口接收数组ram     uchar command; //第一个命令     uchar command1;//     //uint  temp;     uchar j,i;    uchar myaddr = 8;    //uchar ywqz_count,time_count;             //ywqz jishu:     uchar bdata DATA;    sbit BIT0 = DATA^0;    sbit BIT1 = DATA^1;    sbit BIT2 = DATA^2;    sbit BIT3 = DATA^3;    sbit BIT4 = DATA^4;    sbit BIT5 = DATA^5;    sbit BIT6 = DATA^6;    sbit BIT7 = DATA^7;    uchar bdata DATA1;    sbit BIT10 = DATA1^0;    sbit BIT11 = DATA1^1;    sbit BIT12 = DATA1^2;    sbit BIT13 = DATA1^3;    sbit BIT14 = DATA1^4;    sbit BIT15 = DATA1^5;    sbit BIT16 = DATA1^6;    sbit BIT17 = DATA1^7;    bit i_CurrentLevel;//i_CurrentLevel  BIT 00H(Saves current level of OutPut pin of U2270B)     bit timer1_end;    bit read_ok = 0;    //缓存定时值,因用同一个定时器     union HLint { uint W;    struct   {    uchar H;uchar L;   }   B; };//union HLint idata a     union HLint data a;    //缓存定时值,因用同一个定时器     union HLint0 { uint W;    struct {   uchar H;   uchar L; } B; };//union HLint idata a     union HLint0 data b;    /**********************函数原型*****************/    //读写操作     void f_readcard(void);//全部读出1~7 AOR唤醒     void f_writecard(uchar x);//根据命令写不同的内容和操作     void f_clearpassword(void);//清除密码     void f_changepassword(void);//修改密码     //功能子函数     void write_password(uchar data *data p);//写初始密码或数据     void write_block(uchar x,uchar data *data p);//不能用通用指针     void write_bit(bit x);//写位     /*子函数区*****************************************************/    void delay_2(uint x)    //延时,时间x*10us@12mhz,最小20us@12mhz     {    x--; x--;    while(x)    {      _nop_();      _nop_();      x--;    }    _nop_();//WDT_CONTR=0X3C;不能频繁的复位     _nop_();    }    /////////////////////////////////////////////////////////////////////     void initial(void)    {    SCON = 0x50; //串口方式1,允许接收     //SCON  =0x50;     //01010000B:10位异步收发,波特率可变,SM2=0不用接收到有效停止位才RI=1,     //REN=1允许接收     TMOD = 0x21; //定时器1 定时方式2(8位),定时器0 定时方式1(16位)     TCON = 0x40; //设定时器1 允许开始计时(IT1=1)     TH1 = 0xfD;  //FB 18.432MHz 9600 波特率     TL1 = 0xfD;  //fd 11.0592 9600     IE = 0X90;     //EA=ES=1     TR1 = 1;     //启动定时器     WDT_CONTR = 0x3c;//使能看门狗     p_U2270B_Standby = 0;//单电源     PCON = 0x00;    IP = 0x10;//uart you xian XXXPS PT1 PX1 PT0 PX0     led_light1 = 1;    led_light = 0;    p_U2270B_OutPut = 1;    }    /************************************************/    void f_readcard()//读卡     {    EA = 0;//全关,防止影响跳变的定时器计时     WDT_CONTR = 0X3C;//喂狗     p_U2270B_CFE = 1;//      delay_2(232);  //>2.5ms            /*   //   aor    用唤醒功能来防碰撞   p_U2270B_CFE = 0; delay_2(18);//start gap>150us   write_bit(1);//10=操作码读0页   write_bit(0);       write_password(&bankdata[24]);//密码block7   p_U2270B_CFE =1 ;//    delay_2(516);//编程及确认时间5.6ms   */    WDT_CONTR = 0X3C;//喂狗     led_light = 0;    b.W = 0;    while(!(read_ok == 1))    {             //while(p_U2270B_OutPut);//等一个稳定的低电平?超时判断?              while(!p_U2270B_OutPut);//等待上升沿的到来同步信号检测1       TR0 = 1;      //deng xia jiang       while(p_U2270B_OutPut);//等待下降沿       TR0 = 0;   a.B.H = TH0;   a.B.L = TL0;   TH0 = TL0 = 0;   TR0 = 1;//定时器晚启动10个周期       //同步头       if((324 < a.W) && (a.W < 353)) ;//检测同步信号1                  else     {     TR0 = 0;     TH0 = TL0 = 0;     GOTO read_error;    }      //等待上升沿        while(!p_U2270B_OutPut);   TR0 = 0;   a.B.H = TH0;   a.B.L = TL0;   TH0 = TL0 = 0;   TR0 = 1;//b.N1<<=8;            if(a.B.L < 195);//0.5p       else     {     TR0 = 0;     TH0 = TL0 = 0;     GOTO read_error;    }      //读0~7块的数据       for(j = 0;j < 28;j++)      {       //uchar i;                  for(i = 0;i < 16;i++)//8个位        {        //等待下降沿的到来         while(p_U2270B_OutPut);                TR0 = 0;     a.B.H = TH0;     a.B.L = TL0;     TH0 = TL0 = 0;     TR0 = 1;              if(t2_max < a.W/*)&&(a.W < t2_max)*/)//1P          {         b.W >>= 2;//先左移再赋值          b.B.L += 0xc0;                             i++;        }        else if(t1_min < a.B.L/*)&&(a.B.L < t1_max)*/)//0.5p         {         b.W >>= 1;         b.B.L += 0x80;                           }        else      {      TR0 = 0;      TH0 = TL0 = 0;      GOTO read_error;     }        i++;        while(!p_U2270B_OutPut);//上升                   TR0 = 0;     a.B.H = TH0;     a.B.L = TL0;     TH0 = TL0 = 0;     TR0 = 1;                      if(t2_min < a.W/*)&&(a.W < t2_max)*/)//1P          {         b.W >>= 2;         i++;        }        else if(t1_min < a.B.L/*a.W)&&(a.B.L < t1_max)*/)//0.5P         //else if(!(a.W==0))         {         b.W >>= 1;         //temp+=0x00;          //led_light1=0;led_light=1;delay_2(40000);         }        else      {      TR0 = 0;      TH0 = TL0 = 0;      GOTO read_error;     }        i++;       }       //取出奇位        DATA = b.B.L;       BIT13 = BIT7;    BIT12 = BIT5;    BIT11 = BIT3;    BIT10 = BIT1;       DATA = b.B.H;       BIT17 = BIT7;    BIT16 = BIT5;    BIT15 = BIT3;    BIT14 = BIT1;       bankdata[j] = DATA1;      }              read_ok = 1;//读卡完成了     read_error:    _nop_();    }       }    /***************************************************/    void f_writecard(uchar x)//写卡     {    p_U2270B_CFE = 1;    delay_2(232);  //>2.5ms            //psw=0 standard write     if (x == write_command0)//写密码:初始化密码     {      uchar i;      uchar data *data p;      p = cominceptbuff;      p_U2270B_CFE = 0;   delay_2(31);//start gap>330us       write_bit(1);//写操作码1:10       write_bit(0);//写操作码0       write_bit(0);//写锁定位0       for(i = 0;i < 35;i++)      {       write_bit(1);//写数据位1       }      p_U2270B_CFE = 1;      led_light1 = 0;   led_light = 1;   delay_2(40000);//测试使用       //write_block(cominceptbuff[4],p);       p_U2270B_CFE = 1;      bankdata[20] = cominceptbuff[0];//密码存入       bankdata[21] = cominceptbuff[1];      bankdata[22] = cominceptbuff[2];      bankdata[23] = cominceptbuff[3];    }    else if (x == write_command1)//配置卡参数:初始化     {      uchar data *data p;      p = cominceptbuff;      write_bit(1);//写操作码1:10       write_bit(0);//写操作码0       write_bit(0);//写锁定位0               write_block(cominceptbuff[4],p);      p_U2270B_CFE=  1;    }    //psw=1  pssword mode     else if(x == write_command2)  //密码写数据    {      uchar data*data p;      p = &bankdata[24];      write_bit(1);//写操作码1:10       write_bit(0);//写操作码0       write_password(p);//发口令       write_bit(0);//写锁定位0       p = cominceptbuff;      write_block(cominceptbuff[4],p);//写数据            }    else if(x == write_command3)//aor    //唤醒 {      //cominceptbuff[1]操作码10 X xxxxxB       uchar data *data p;      p = cominceptbuff;      write_bit(1);//10       write_bit(0);             write_password(p);//密码       p_U2270B_CFE = 1;//此时数据不停的循环传出     }    else //停止操作码     {      write_bit(1);//11       write_bit(1);             p_U2270B_CFE = 1;         }    p_U2270B_CFE = 1;    delay_2(560);//5.6ms     }    /************************************/    void f_clearpassword()//清除密码     {    uchar data *data p;    uchar i,x;          p = &bankdata[24];//原密码     p_U2270B_CFE = 0; delay_2(18);//start gap>150us     //操作码10:10xxxxxxB     write_bit(1);    write_bit(0);              for(x = 0;x < 4;x++)//发原密码     {             DATA = *(p++);      for(i = 0;i < 8;i++)      {       write_bit(BIT0);       DATA >>= 1;      }    }    write_bit(0);//锁定位0:0     p = &cominceptbuff[0];    write_block(0x00,p);//写新配置参数:pwd=0             //密码无效:即清除密码     DATA = 0x00;//停止操作码00000000B     for(i = 0;i < 2;i++)    {    write_bit(BIT7);    DATA <<= 1;    }    p_U2270B_CFE = 1;       delay_2(560);//5.6ms     }    /*********************************/    void f_changepassword()//修改密码            {       uchar data *data p;    uchar i,x,addr;    addr = 0x07;//block7     p = &Nkey_a[0];//原密码     DATA = 0x80;//操作码10:10xxxxxxB     for(i = 0;i < 2;i++)    {      write_bit(BIT7);      DATA <<= 1;    }    for(x = 0;x < 4;x++)//发原密码     {             DATA = *(p++);      for(i = 0;i < 8;i++)      {       write_bit(BIT7);       DATA >>= 1;      }    }    write_bit(0);//锁定位0:0     p = &cominceptbuff[0];    write_block(0x07,p);//写新密码     p_U2270B_CFE = 1;    bankdata[24] = cominceptbuff[0];//密码存入     bankdata[25] = cominceptbuff[1];    bankdata[26] = cominceptbuff[2];    bankdata[27] = cominceptbuff[3];    DATA = 0x00;//停止操作码00000000B     for(i = 0;i < 2;i++)    {      write_bit(BIT7);      DATA <<= 1;    }    p_U2270B_CFE = 1;       delay_2(560);//5.6ms     }    /***************************子函数***********************************/    void write_bit(bit x)//写一位     {    if(x)    {      p_U2270B_CFE = 1;   delay_2(32);//448*11.0592/120=42延时448us       p_U2270B_CFE = 0;   delay_2(28);//280*11.0592/120=26写1     }    else    {      p_U2270B_CFE = 1;   delay_2(92);//192*11.0592/120=18       p_U2270B_CFE = 0;   delay_2(28);//280*11.0592/120=26写0     }    }    /*******************写一个block*******************/    void write_block(uchar addr,uchar data *data p)    {    uchar i,j;        for(i = 0;i < 4;i++)//block0数据     {             DATA = *(p++);      for(j = 0;j < 8;j++)      {       write_bit(BIT0);       DATA >>= 1;      }    }    DATA = addr <<= 5;//0地址     for(i = 0;i < 3;i++)    {      write_bit(BIT7);      DATA <<= 1;    }                   }    /*************************************************/    void write_password(uchar data *data p)    {    uchar i,j;        for(i = 0;i < 4;i++)//     {             DATA = *(p++);      for(j = 0;j < 8;j++)      {       write_bit(BIT0);       DATA >>= 1;      }    }        }   /*************************************************/   void main()    {    initial();    TI = RI = 0;    ES = 1;    EA = 1;  delay_2(28);   //f_readcard();     while(1) {   f_readcard();      //读卡   f_writecard(command1);  //写卡    f_clearpassword();   //清除密码     f_changepassword();    //修改密码 } }

    标签: 12345

    上传时间: 2017-10-20

    上传用户:my_lcs