单片机汇编吧 关注:121贴子:364
  • 9回复贴,共1
ORG 0000H
JMP START
start_key EQU P2^3
reset_key EQU P2^6
led_port EQU P1
;//////////////////////////////////////
START: MOV R4,#0FFH
MOV R5,#08
CLR C
JB start_key, start
LCALL DELAY2
JB start_key, start
JNB START_KEY,$
L1: MOV A,R4
RLC A
MOV LED_PORT,A
MOV R4,A
JNB reset_key, stop
LCALL DELAY
DJNZ R5,L1
MOV R5,#07
L2: RRC A
MOV LED_PORT,A
MOV R4,A
JNB reset_key, stop
LCALL DELAY
DJNZ R5,L2
MOV R5,#07
MOV 20H,#00
MOV DPTR,#TAB
L3: MOV A,20H
MOVC A,@A+DPTR
MOV LED_PORT,A
JNB reset_key, stop
LCALL DELAY
INC 20H
DJNZ R5,L3
MOV R4,#0FFH
MOV R5,#08
CLR C
JMP L1
stop: MOV LED_PORT,#0FFH
JMP START
;////////////////////////////////////////
DELAY: MOV R6,#3
DELAY0: MOV R2,#150
DELAY1: MOV R3,#248
DJNZ R3,$
DJNZ R2,DELAY1
DJNZ R6,DELAY0
RET
/////////////////////////////////////////
DELAY2: MOV R7,#20
DELAY3: MOV R1,#248
DJNZ R1,$
DJNZ R7,DELAY3
RET
;///////////////////////////////////////
TAB: DB 07EH,0BDH,0DBH,0E7H,0DBH,0BDH,07EH
END


IP属地:广东1楼2015-09-24 11:17回复
    刚学表示看不懂


    来自Android客户端2楼2015-09-25 13:05
    回复
      按启动按键,流水灯就按表里面的模式跑


      IP属地:广东来自iPhone客户端3楼2015-09-25 13:42
      回复
        #include <reg52.h>
        #define uchar unsigned char
        #define uint unsigned int
        void DelayMS(uint x)
        {
        uchar t;
        while(x--)
        {
        for(t=0;t<120;t--);
        }
        }
        void main()
        {
        uchar k,t,Key_State;
        P0 = 0xff;
        P1 = 0xff;
        while(1)
        {
        t = P1;
        {
        DelayMS(10);
        if(t != P1)
        continue;
        Key_State = ~t >> 4;
        k = 0;
        while(Key_State != 0)
        {
        k++;
        Key_State >>= 1;
        }
        switch(k)
        {
        case 1: if(P0 == 0x00)
        P0 = 0xff;
        P0 <<= 1;
        DelayMS(200);
        break;
        case 2: P0 = 0xf0;
        break;
        case 3: P0 = 0x0f;
        break;
        case 4: P0 = 0xff;
        }
        }
        }
        }
        改成汇编可以吗


        IP属地:吉林4楼2016-04-07 14:28
        收起回复
          可以


          IP属地:广东来自iPhone客户端5楼2016-04-07 18:14
          收起回复
            你好,我想弄一个频率计,可以帮一下吗,我做了很久了,都没做出来,p1口,实现秒:分秒


            来自手机贴吧6楼2016-06-21 23:08
            回复
              具体要求


              IP属地:广东来自iPhone客户端7楼2016-06-21 23:15
              收起回复