⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demo.asm

📁 key scan and lcd display file it can run in the computer with sunplus compile
💻 ASM
📖 第 1 页 / 共 3 页
字号:
        R3 = [R4];
        R3 &= 0xF8FF;
        R3 |= R2;
        [R4++] = R3;

        R2 = [BP++];
        R2 &= 0x0600;       //b9,b10

        R3 = [R4];
        R3 &= 0xF9FF;
        R3 |= R2;
        [R4++] = R3;

        CMP     BP,P_Seg39 + 1;
        JNZ     ShiftLeftLoop;

        R2 = [P_Seg37];
        R2 &= 0xF9FF;
        R3 = R2 AND 0xC000;
        R3 = R3 LSR 4;
        R3 = R3 LSR 1;
        [P_Seg37] = R2 OR R3;

        R2 = [P_Seg38];
        R2 &= 0xF8FF;
        R3 = R2 AND 0xE000;
        R3 = R3 LSR 4;
        R3 = R3 LSR 1;
        [P_Seg38] = R2 OR R3;

        R2 = [P_Seg39];
        R2 &= 0xF9FF;
        R3 = R2 AND 0xC000;
        R3 = R3 LSR 4;
        R3 = R3 LSR 1;
        [P_Seg39] = R2 OR R3;

        RETF;

//----------------------------------------------------------------------------//
// Purpose : clear all dots of LCD's number position
//----------------------------------------------------------------------------//
F_ClrAllDigits:
        BP = P_Seg1;
ClrAllDigitsLoop:
        R1 = [BP];
        R1 &= 0xF9FF;
        [BP++] = R1;

        R1 = [BP];
        R1 &= 0xF8FF;
        [BP++] = R1;

        R1 = [BP];
        R1 &= 0xF9FF;
        [BP++] = R1;

        CMP     BP,P_Seg39 + 1;
        JNZ     ClrAllDigitsLoop;

        BP = P_Seg37;
        R1 = [BP];
        R1 &= 0x3FFF;
        [BP++] = R1;

        R1 = [BP];
        R1 &= 0x1FFF;
        [BP++] = R1;

        R1 = [BP];
        R1 &= 0x3FFF;
        [BP] = R1;

        RETF;

//------------------------------------------------------------------------------
// Input  : [LcdYear]
// Output : R3 = 0x8000 represents leap year
//          R3 = 0      represents not leap year
//------------------------------------------------------------------------------
F_JudgeIfLeapYear:
        R3 = [LcdYear];
        CMP     R3,0;
        JZ      LeapYear;

JudgeIfLeapYear_10:
        CMP     R3,400;
        JB      JudgeIfLeapYear_30;
        R3 -= 400;
        JNZ     JudgeIfLeapYear_10;

LeapYear:
        R3 = 0x8000;
        RETF;

JudgeIfLeapYear_30:
        CMP     R3,100;
        JB      JudgeIfLeapYear_40;
        R3 -= 100;
        JNZ     JudgeIfLeapYear_30;
        JMP     NotLeapYear;

JudgeIfLeapYear_40:
        TEST    R3,0x0003;
        JZ      LeapYear;
NotLeapYear:
        R3 = 0;
        RETF;

//------------------------------------------------------------------------------
TB_1900WeekBase:
        .DW     1,4,4,0,2,5,0,3,6,1,4,6;

//----------------------------------------------------------------------------*/
// Input   : R1 - Digit to show
//           BP = address, such as 0,1,...,13
// Change  : R1,R3,R4,BP
//----------------------------------------------------------------------------*/
F_ShowDigit:
        R1 += TB_PatternNull;
        R1 = [R1];
ShowDigit_10:
        R3 = [BP++];
        JZ       ShowDigit_99;

        R3 = [R3];              // read P_Segxx
        R4 = [BP--];            // Com number
        R3 |= R4;
        TEST     R1,0x0001;
        JNZ      ShowDigit_20;
        R4 ^= 0xFFFF;
        R3 &= R4;
ShowDigit_20:
        R4 = [BP++];
        [R4] = R3;
        BP += 1;
        R1 = R1 LSR 1;
        JMP      ShowDigit_10;

ShowDigit_99:
        RETF;

//----------------------------------------------------------------------------*/
// LCD digit block pattern
//----------------------------------------------------------------------------*/

// --b6--
//|      |
//b2    b5
//|      |
// --b4--
//|      |
//b1    b3
//|      |
// --b0--

TB_PatternNull:   .DW      0x0000;
TB_Pattern1:      .DW      0x0028;
TB_Pattern2:      .DW      0x0073;
TB_Pattern3:      .DW      0x0079;
TB_Pattern4:      .DW      0x003C;
TB_Pattern5:      .DW      0x005D;
TB_Pattern6:      .DW      0x005F;
TB_Pattern7:      .DW      0x0068;
TB_Pattern8:      .DW      0x007F;
TB_Pattern9:      .DW      0x007D;
TB_Pattern0:      .DW      0x00EF;
TB_PatternStar:   .DW      0x0016;
TB_PatternPound:  .DW      0x003F;
TB_PatternP:      .DW      0x0076;
TB_PatternDash:   .DW      0x0010;
TB_PatternLDash:  .DW      0x0001;

//----------------------------------------------------------------------------*/
// LCD dots mapping for Phone Digits
//----------------------------------------------------------------------------*/
Digit0:  .DW      P_Seg2,B_Com10,P_Seg1,B_Com10,P_Seg1,B_Com9;
         .DW      P_Seg3,B_Com10,P_Seg2,B_Com9,P_Seg3,B_Com9,P_Seg2,B_Com8,0;
Digit1:  .DW      P_Seg5,B_Com10,P_Seg4,B_Com10,P_Seg4,B_Com9;
         .DW      P_Seg6,B_Com10,P_Seg5,B_Com9,P_Seg6,B_Com9,P_Seg5,B_Com8,0;
Digit2:  .DW      P_Seg8,B_Com10,P_Seg7,B_Com10,P_Seg7,B_Com9;
         .DW      P_Seg9,B_Com10,P_Seg8,B_Com9,P_Seg9,B_Com9,P_Seg8,B_Com8,0;
Digit3:  .DW      P_Seg11,B_Com10,P_Seg10,B_Com10,P_Seg10,B_Com9;
         .DW      P_Seg12,B_Com10,P_Seg11,B_Com9,P_Seg12,B_Com9,P_Seg11,B_Com8,0;
Digit4:  .DW      P_Seg14,B_Com10,P_Seg13,B_Com10,P_Seg13,B_Com9;
         .DW      P_Seg15,B_Com10,P_Seg14,B_Com9,P_Seg15,B_Com9,P_Seg14,B_Com8,0;
Digit5:  .DW      P_Seg17,B_Com10,P_Seg16,B_Com10,P_Seg16,B_Com9;
         .DW      P_Seg18,B_Com10,P_Seg17,B_Com9,P_Seg18,B_Com9,P_Seg17,B_Com8,0;
Digit6:  .DW      P_Seg20,B_Com10,P_Seg19,B_Com10,P_Seg19,B_Com9;
         .DW      P_Seg21,B_Com10,P_Seg20,B_Com9,P_Seg21,B_Com9,P_Seg20,B_Com8,0;
Digit7:  .DW      P_Seg23,B_Com10,P_Seg22,B_Com10,P_Seg22,B_Com9;
         .DW      P_Seg24,B_Com10,P_Seg23,B_Com9,P_Seg24,B_Com9,P_Seg23,B_Com8,0;
Digit8:  .DW      P_Seg26,B_Com10,P_Seg25,B_Com10,P_Seg25,B_Com9;
         .DW      P_Seg27,B_Com10,P_Seg26,B_Com9,P_Seg27,B_Com9,P_Seg26,B_Com8,0;
Digit9:  .DW      P_Seg29,B_Com10,P_Seg28,B_Com10,P_Seg28,B_Com9;
         .DW      P_Seg30,B_Com10,P_Seg29,B_Com9,P_Seg30,B_Com9,P_Seg29,B_Com8,0;
Digit10: .DW      P_Seg32,B_Com10,P_Seg31,B_Com10,P_Seg31,B_Com9;
         .DW      P_Seg33,B_Com10,P_Seg32,B_Com9,P_Seg33,B_Com9,P_Seg32,B_Com8,0;
Digit11: .DW      P_Seg35,B_Com10,P_Seg34,B_Com10,P_Seg34,B_Com9;
         .DW      P_Seg36,B_Com10,P_Seg35,B_Com9,P_Seg36,B_Com9,P_Seg35,B_Com8,0;
Digit12: .DW      P_Seg38,B_Com10,P_Seg37,B_Com10,P_Seg37,B_Com9;
         .DW      P_Seg39,B_Com10,P_Seg38,B_Com9,P_Seg39,B_Com9,P_Seg38,B_Com8,0;
Digit13: .DW      P_Seg38,B_Com15,P_Seg37,B_Com15,P_Seg37,B_Com14;
         .DW      P_Seg39,B_Com15,P_Seg38,B_Com14,P_Seg39,B_Com14,P_Seg38,B_Com13,0;

//----------------------------------------------------------------------------*/
// LCD dots mapping for Hour,Min,Mon,Day,Total,New,Seq
//----------------------------------------------------------------------------*/
.const  P_SegX     = P_Seg3;
.const  B_ComX     = B_Com8;

//----------------------------------------------------------------------------*/
Month:
MonHigh:
        .DW      P_SegX, B_ComX, P_SegX, B_ComX, P_SegX, B_ComX;
        .DW      P_Seg12,B_Com8, P_SegX, B_ComX, P_Seg12,B_Com8, P_SegX, B_ComX,0;
MonLow:
        .DW      P_Seg15,B_Com8, P_Seg14,B_Com5, P_Seg14,B_Com6;
        .DW      P_Seg16,B_Com5, P_Seg15,B_Com5, P_Seg16,B_Com6, P_Seg15,B_Com6,0;

//----------------------------------------------------------------------------*/
Day:
DayHigh:
        .DW      P_Seg18,B_Com8, P_Seg17,B_Com5, P_Seg17,B_Com6;
        .DW      P_Seg19,B_Com5, P_Seg18,B_Com5, P_Seg19,B_Com6, P_Seg18,B_Com6,0;
DayLow:
        .DW      P_Seg21,B_Com8, P_Seg20,B_Com5, P_Seg20,B_Com6;
        .DW      P_Seg22,B_Com5, P_Seg21,B_Com5, P_Seg22,B_Com6, P_Seg21,B_Com6,0;

//----------------------------------------------------------------------------*/
Hour:
HrHigh:
        .DW      P_Seg1, B_Com6, P_Seg1, B_Com8, P_SegX, B_ComX;
        .DW      P_Seg2, B_Com5, P_Seg1, B_Com6, P_Seg2, B_Com6, P_Seg1, B_Com6,0;
HrLow:
        .DW      P_Seg4, B_Com8, P_Seg3, B_Com5, P_Seg3, B_Com6;
        .DW      P_Seg5, B_Com5, P_Seg4, B_Com5, P_Seg5, B_Com6, P_Seg4, B_Com6,0;

//----------------------------------------------------------------------------*/
Minute:
MinHigh:
        .DW      P_Seg7, B_Com8, P_Seg6, B_Com5, P_Seg6, B_Com6;
        .DW      P_Seg8, B_Com5, P_Seg7, B_Com5, P_Seg8, B_Com6, P_Seg7, B_Com6,0;
MinLow:
        .DW      P_Seg10,B_Com8, P_Seg9, B_Com5, P_Seg9, B_Com6;
        .DW      P_Seg11,B_Com5, P_Seg10,B_Com5, P_Seg11,B_Com6, P_Seg10,B_Com6,0;

//----------------------------------------------------------------------------*/
Total:
TotalHigh:
        .DW      P_Seg24,B_Com8, P_Seg23,B_Com5, P_Seg23,B_Com6;
        .DW      P_Seg25,B_Com5, P_Seg24,B_Com5, P_Seg25,B_Com6, P_Seg24,B_Com6,0;
TotalLow:
        .DW      P_Seg27,B_Com8, P_Seg26,B_Com5, P_Seg26,B_Com6;
        .DW      P_Seg28,B_Com5, P_Seg27,B_Com5, P_Seg28,B_Com6, P_Seg27,B_Com6,0;

//----------------------------------------------------------------------------*/
NewTotal:
NewTotalHigh:
        .DW      P_Seg30,B_Com8, P_Seg29,B_Com5, P_Seg29,B_Com6;
        .DW      P_Seg31,B_Com5, P_Seg30,B_Com5, P_Seg31,B_Com6, P_Seg30,B_Com6,0;
NewTotalLow:
        .DW      P_Seg33,B_Com8, P_Seg32,B_Com5, P_Seg32,B_Com6;
        .DW      P_Seg34,B_Com5, P_Seg33,B_Com5, P_Seg34,B_Com6, P_Seg33,B_Com6,0;

//----------------------------------------------------------------------------*/
SerialNo:
SerialNoHigh:
        .DW      P_Seg36,B_Com5, P_Seg35,B_Com6, P_Seg35,B_Com7;
        .DW      P_Seg37,B_Com5, P_Seg36,B_Com6, P_Seg37,B_Com6, P_Seg36,B_Com7,0;
SerialNoLow:
        .DW      P_Seg39,B_Com5, P_Seg38,B_Com5, P_Seg38,B_Com6;
        .DW      P_Seg39,B_Com7, P_Seg39,B_Com6, P_Seg38,B_Com7, P_Seg37,B_Com7,0;

////////////////////////////////////////////////////////////////////////////////
// Interrupt Service Subroutines
////////////////////////////////////////////////////////////////////////////////
.TEXT

_FIQ:
F_Ioc1Irq:
        PUSH    R1,BP TO [SP];
        R1 = B_Ioc1Int;
        [P_IntClr] = R1;
        POP     R1,BP FROM [SP];
        RETI;

//----------------------------------------------------------------------------*/
_IRQ0:
F_Ioc0RiIrq:
        PUSH    R1,R1 TO [SP];
        R1 = B_Ioc0Int+B_RiInt+B_LineInt;
        [P_IntClr] = R1;
        POP     R1,R1 FROM [SP];
        RETI;

//----------------------------------------------------------------------------*/
_IRQ1:
F_IoaIrq:
        PUSH    R1,R1 TO [SP];

        R1 = 1;
        [KeyIntFlag] = R1;

        R1 = B_IoaInt;
        [P_IntClr] = R1;
        POP     R1,R1 FROM [SP];
        RETI;

//----------------------------------------------------------------------------*/
_IRQ2:
F_TmrAIrq:
        PUSH    R1,R1 TO [SP];
        R1 = B_TmrAInt;
        [P_IntClr] = R1;
        POP     R1,R1 FROM [SP];
        RETI;

//----------------------------------------------------------------------------*/
_IRQ3:
F_TmrBIrq:
        PUSH    R1,R1 TO [SP];
        R1 = B_TmrBInt;
        [P_IntClr] = R1;
        POP     R1,R1 FROM [SP];
        RETI;

//----------------------------------------------------------------------------*/
_IRQ4:
F_T32KHzIrq:
        PUSH    R1,R1 TO [SP];
        R1 = B_T32KHzInt;
        [P_IntClr] = R1;
        POP     R1,R1 FROM [SP];
        RETI;

//----------------------------------------------------------------------------*/
_IRQ5:
F_T2KHzIrq:
        PUSH    R1,R1 TO [SP];

        R1 = [KeyScan512HzTmr];
        JZ      DebounceTimeOver;
        R1 -= 1;
        [KeyScan512HzTmr] = R1;

DebounceTimeOver:
        R1 = B_T2KHzInt;
        [P_IntClr] = R1;
        POP     R1,R1 FROM [SP];
        RETI;

//----------------------------------------------------------------------------*/
_IRQ6:
F_T128HzIrq:
        PUSH    R1,R1 TO [SP];
        R1 = B_T128HzInt;
        [P_IntClr] = R1;
        POP     R1,R1 FROM [SP];
        RETI;

//----------------------------------------------------------------------------*/
_IRQ7:
F_T8HzIrq:
        PUSH    R1,R1 TO [SP];

        R1 = 1;
        [TwoHzIntFlag] = R1;

        R1 = B_T8HzInt;
        [P_IntClr] = R1;
        POP     R1,R1 FROM [SP];
_BREAK:
        RETI;
//----------------------------------------------------------------------------*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -