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

📄 sys.asm

📁 完整的方案
💻 ASM
字号:
PenDataIn:
         R1=[P_IOA_Dir]
         R1&=PDatB_
         [P_IOA_Dir]=R1
         R1=[P_IOA_Buffer]
         R1|=PAckB
         [P_IOA_Buffer]=R1
         RETF

PcDataIn:
         R1=0xfe00
         [P_IOB_Dir]=R1
         RETF

PcDataOut:
         R1=0xfeff
         [P_IOB_Dir]=R1
         RETF

En24C02:
         R1=[P_IOA_Buffer]
         R1&=C02B_
         [P_IOA_Buffer]=R1
         RETF

ClrPlayCE:
SetPlayCE:
         RETF


ClearWatchDog:
         R1=[_RandomBase]
         R1+=1
         [_RandomBase]=R1
         R1=0x0001
         [P_Watchdog_Clear]=R1
         RETF

UnitOff:
         CALL PrOff
         R1=[P_IOA_Buffer]
         R1|=C02B
         R1&=POWB_
         [P_IOA_Buffer]=R1

         R1=[P_IOB_Buffer]
         R1|=Bit9
         [P_IOB_Buffer]=R1
         [P_IOB_Data]=R1

         R1=[P_IOB_Dir]
         R1&=Bit9_
         [P_IOB_Dir]=R1

         R1=[P_IOB_Attrib]
         R1&=Bit9_
         [P_IOB_Attrib]=R1



UnitOff0:
         R1=0x0001
         [P_Watchdog_Clear]=R1
         JMP UnitOff0
Stop:
         R1=0x0001
         [P_Watchdog_Clear]=R1
         JMP Stop

EnUart:
         R1 = 0x006b                   // serious communication
         [P_UART_BaudScalarLow]=R1
         R1 = 0x0000
         [P_UART_BaudScalarHigh]=R1
         R1=[P_IOB_Buffer]
         R1|=BitA
         [P_IOB_Buffer] = R1
         R1 = 0x0040
         [P_UART_Command2]=R1
         R1=0x300
         JMP Delay0

DiUart:
         R1=0x300
DiUart0:
         R1-=1
         JNZ DiUart0
         RETF

Delay16ms:
        R1=0
        JMP Delay0
Delay10ms:
        R1=0xa000
        JMP Delay0
Delay5ms:
        R1=0x5000
        JMP Delay0
Delay2ms:
        R1=0x2000
        JMP Delay0
Delay1ms:
        R1=0x1000
Delay0:
        R1-=1
        JNE Delay0
        RETF
//DelayN:
        R1=0x48
        JMP Delay0

Delay50ms:           
        R2=5
        JMP Delay_10ms0
Delay100ms:
        R2=10
        JMP Delay_10ms0
Delay200ms:           
        R2=20
Delay_10ms0:
        CALL Delay10ms
        R2-=1
        JNE Delay_10ms0
        RETF
        
TxMNull:
         CALL TxNull
         R2-=1
         JNE TxMNull
         RETF

TxHex:
         R2=R1
         JMP TxWord3
Tx3Nibble:
         R2=R1
         JMP TxWord2

TxSWord:
         TEST R1, BitF
         JNE TxSWord2
TxSWord1:
         R2=R1
         CALL TxNull
         JMP TxWord1
TxSWord2:
         R2=0
         R2-=R1
         CALL TxLine
         JMP TxWord1
TxWord:
         R2=R1
TxWord1:
         R1=R2 LSR 4
         R1=R1 LSR 4
         R1=R1 LSR 4
         CALL TxHex1
TxWord2:
         R1=R2 LSR 4
         R1=R1 LSR 4
         CALL TxHex1
TxWord3:
         R1=R2 LSR 4
         CALL TxHex1
TxWord4:
         R1=R2
         CALL TxHex1
TxWordSpace:
         R1=0x20
         JMP TxByte

TxEQU:
         R1='='
         JMP TxByte
TxLine:
         R1='-'
         JMP TxByte
TxDD:
         R1=':'
         JMP TxByte
TxChg:
         R1=0x0d
         JMP TxByte
TxNull:
         R1=' '
         JMP TxByte
TxHex1:
         R1=R1&0x000f
         R1+=0x30
         CMP R1,0x39
         JNG TxByte
         R1+=7
TxByte:
         [P_UART_Data]=R1
TxByte0:
         R1=0x0040
         TEST R1,[P_UART_Command2]
         JZ TxByte0
         RETF

ClearRam:
         [R2++]=R1
         R3-=1
         JNE ClearRam
         RETF


DealSysError:
         [_Tmp1]=R1
         R1=[_Tmp1]
         CALL PrintErr
         R1=[_CardMode]
         JE DealSysError1
         CMP R1, CoordMode
         JE DealSysError1
         CMP R1, NormalMode
         JE DealSysError1
         CMP R1, ContinousMode
         JNB DealSysError1
         CALL SoundAllStop
         R1=[_Tmp1]
PlayErrSound:
         R1+=SysErrSound
         R1+=[_SoundIndex]
         CALL _PlaySound
         CALL WaitSoundEnd
         PC=UnitOff
DealSysError1:
         CALL SoundAllStop
         PC=UnitOff

GetWord:
         R1=[R5++]
         R1&=0xff
         R5=[R5]
         R5=R5 LSL 4
         R5=R5 LSL 4
         R1|=R5
         RETF

GetAddr3:
         R4=[R5++]
         R4&=0xff
         R3=[R5++]
         R3=R3 LSL 4
         R3=R3 LSL 4
         R3|=R4
         R4=[R5]
         R4&=0xff
         RETF

GetAddr4:
         R4=[R5++]
         R4&=0xff
         R3=[R5++]
         R3=R3 LSL 4
         R3=R3 LSL 4
         R3|=R4
         R4=[R5++]
         R4&=0xff
         R5=[R5]
         R5=R5 LSL 4
         R5=R5 LSL 4
         R4|=R5
         RETF


GetRandomData:
         R2=[P_TimerB_Data]
         R2+=[_RandomBase]
GetMod:
         CMP R1, 1
         JA GetMod0
         R1=0
         RETF
GetMod0:
         R2&=0x0ff
         CMP R2, R1
         JNB GetMod1
         R1=R2
         RETF
GetMod1:
         R1=R1 LSL 4
         R1=R1 LSL 4
GetMod2:
         CMP R2, R1
         JB  GetMod3
         R2-=R1
         JMP GetMod0
GetMod3:
         R1=R1 LSR 1
         CMP R2, R1
         JB  GetMod4
         R2-=R1
         R1=R1 LSR 1
GetMod4:
         R1=R1 LSR 1
         CMP R2, R1
         JB  GetMod5
         R2-=R1
GetMod5:
         R1=R1 LSR 1
         CMP R2, R1
         JB  GetMod6
         R2-=R1
GetMod6:
         R1=R1 LSR 1
         CMP R2, R1
         JB  GetMod7
         R2-=R1
GetMod7:
         R1=R1 LSR 1
         CMP R2, R1
         JB  GetMod8
         R2-=R1
GetMod8:
         R1=R1 LSR 1
         CMP R2, R1
         JB  GetMod9
         R2-=R1
GetMod9:
         R1=R1 LSR 1
         CMP R2, R1
         JB  GetModA
         R2-=R1
GetModA:
         R1=R1 LSR 1
         CMP R2, R1
         JB  GetModB
         R2-=R1
GetModB:
         R1=R2
         RETF

⌨️ 快捷键说明

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