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

📄 demo.a51

📁 一份51的编译程序,dos版本的. 英文名字MCS-51 Microcontroller Family Macro Assembler
💻 A51
📖 第 1 页 / 共 2 页
字号:

        XRL A,#KONST4

        XRL RAM,A

        XRL RAM,#KONST4

        CLR A
        CPL A
        RL A
        RLC A
        RR A
        RRC A
        SWAP A

        ;Move Instructions:
        ;------------------

        MOV A,R0
        MOV A,R1
        MOV A,R2
        MOV A,R3
        MOV A,R4
        MOV A,R5
        MOV A,R6
        MOV A,R7

        MOV A,RAM

        MOV A,@R0
        MOV A,@R1

        MOV A,#KONST4

        MOV R0,A
        MOV R1,A
        MOV R2,A
        MOV R3,A
        MOV R4,A
        MOV R5,A
        MOV R6,A
        MOV R7,A

        MOV R0,RAM
        MOV R1,RAM
        MOV R2,RAM
        MOV R3,RAM
        MOV R4,RAM
        MOV R5,RAM
        MOV R6,RAM
        MOV R7,RAM

        MOV R0,#KONST4
        MOV R1,#KONST4
        MOV R2,#KONST4
        MOV R3,#KONST4
        MOV R4,#KONST4
        MOV R5,#KONST4
        MOV R6,#KONST4
        MOV R7,#KONST4

        MOV RAM,A

        MOV RAM,R0
        MOV RAM,R1
        MOV RAM,R2
        MOV RAM,R3
        MOV RAM,R4
        MOV RAM,R5
        MOV RAM,R6
        MOV RAM,R7

        MOV RAM2,RAM1

        MOV RAM,@R0
        MOV RAM,@R1

        MOV RAM,#KONST4

        MOV @R0,A
        MOV @R1,A

        MOV @R0,RAM
        MOV @R1,RAM

        MOV @R0,#KONST4
        MOV @R1,#KONST4

        MOV DPTR,#KONST5

        MOVC A,@A+DPTR
        MOVC A,@A+PC

        MOVX A,@R0
        MOVX A,@R1
        MOVX A,@DPTR

        MOVX @R0,A
        MOVX @R1,A
        MOVX @DPTR,A

        PUSH RAM
        POP RAM

        XCH A,R0
        XCH A,R1
        XCH A,R2
        XCH A,R3
        XCH A,R4
        XCH A,R5
        XCH A,R6
        XCH A,R7

        XCH A,RAM

        XCH A,@R0
        XCH A,@R1

        XCHD A,@R0
        XCHD A,@R1

        ;Bit Instructions:
        ;-----------------

        CLR C
        CLR BITAD

        SETB C
        SETB BITAD

        CPL C
        CPL BITAD

        ANL C,BITAD
        ANL C,/BITAD

        ORL C,BITAD
        ORL C,/BITAD

        MOV C,BITAD
        MOV BITAD,C


; 8. Register Symbols:
; --------------------

        MOV @R1,A
        MOV @R1,COUNTREG            ;same as:  MOV @R1,A
        MOV @INDEXREG,A             ;same as:  MOV @R1,A
        MOV @INDEXREG,COUNTREG      ;same as:  MOV @R1,A


; 9. Predefined Symbols:
; ----------------------

        ; Special Function Registers:
        ; ---------------------------

        MOV A,B
        MOV R1,ACC
        MOV A,PSW
        MOV A,IP
        MOV A,P3
        MOV A,IE
        MOV A,P2
        MOV A,SBUF
        MOV A,SCON
        MOV A,P1
        MOV A,TH1
        MOV A,TH0
        MOV A,TL1
        MOV A,TL0
        MOV A,TMOD
        MOV A,TCON
        MOV A,PCON
        MOV A,DPH
        MOV A,DPL
        MOV A,SP
        MOV A,P0

        ;SFR Bit Addresses:
        ;------------------

        MOV C,CY        ;PSW
        MOV C,AC
        MOV C,F0
        MOV C,RS1
        MOV C,RS0
        MOV C,OV
        MOV C,P

        MOV C,PS        ;IP
        MOV C,PT1
        MOV C,PX1
        MOV C,PT0
        MOV C,PX0

        MOV C,RD        ;P3
        MOV C,WR
        MOV C,T1
        MOV C,T0
        MOV C,INT1
        MOV C,INT0
        MOV C,TXD
        MOV C,RXD

        MOV C,EA        ;IE
        MOV C,ES
        MOV C,ET1
        MOV C,EX1
        MOV C,ET0
        MOV C,EX0

        MOV C,SM0       ;SCON
        MOV C,SM1
        MOV C,SM2
        MOV C,REN
        MOV C,TB8
        MOV C,RB8
        MOV C,TI
        MOV C,RI

        MOV C,TF1       ;TCON
        MOV C,TR1
        MOV C,TF0
        MOV C,TR0
        MOV C,IE1
        MOV C,IT1
        MOV C,IE0
        MOV C,IT0

        MOV C,P1.0      ;P1
        MOV C,P1.1
        MOV C,P1.2
        MOV C,P1.3
        MOV C,P1.4
        MOV C,P1.5
        MOV C,P1.6
        MOV C,P1.7

        MOV C,P3.0      ;P3
        MOV C,P3.1
        MOV C,P3.2
        MOV C,P3.3
        MOV C,P3.4
        MOV C,P3.5
        MOV C,P3.6
        MOV C,P3.7

        ; ROM Addresses:
        ; --------------

        MOV DPTR,#RESET
        MOV DPTR,#EXTI0
        MOV DPTR,#TIMER0
        MOV DPTR,#EXTI1
        MOV DPTR,#TIMER1
        MOV DPTR,#SINT


; 10. Conditional Assembly:
; -------------------------
; The most important meta instructions for conditional assembly are
; introduced in this section. The general controls $WARNING and $ERROR,
; and the predefined symbols ??ASEM_51 and ??VERSION are also shown here,
; because the make sense in conjunction with conditional assembly only.

; a.) The IF, IFN, ELSE, and ENDIF meta instructions:

        IF NOTEQ1
          DB 'string 1',0
        ELSE
          IFN EQUAL2
            DB 'string 2',0
          ELSE
            DB 'string 3',0
          ENDIF
        ENDIF

; b.) The IFDEF and IFNDEF meta instructions:

        IFDEF GHOST
          DB 'haunting',0
        ELSE
          DB 'nothing',0
          IFNDEF VAMPIRE
            DB 'boring',0
          ELSE
            DB 'sucking',0
          ENDIF
        ENDIF

; c.) The predefined symbols ??ASEM_51 and ??VERSION,
;     and the general controls $WARNING and $ERROR:

        IFDEF ??ASEM_51               ;product identification
          IF ??VERSION < 0130H        ;version number
            ;display a user-defined warning:
$WARNING(Warning: ASEM-51 version 1.3 (or later)) required.)
          ENDIF
        ELSE
          ;fire a user-defined error message:
$ERROR(Fatal: Assembler is not ASEM-51!)
        ENDIF


; 11. Macro Processing:
; ---------------------
; Macro processing is by far too complex, to show all possibilities in a
; small demo program. So, only a few simple (but typical) constructions
; are listed here. Furthermore, some assembler controls and meta
; instructions for conditional assembly are introduced in this section,
; because they make sense in conjunction with macro processing only.

; a.) The MACRO, LOCAL and ENDM meta instructions, macro
;     parameters, and the macro commentary operator ;; :

        ;define macro CJEQ: "compare and jump if equal"

        CJEQ MACRO param1, param2, param3
          LOCAL temp
          CJNE param1, param2, temp   ;;continue if not equal
          JMP param3                  ;;jump otherwise
temp:
        ENDM

        ;CJEQ macro calls:

        CJEQ A, CHEETA, HERE
HERE:   CJEQ @R0, #13, THERE
        CJEQ R4, #DIFFER, HERE

; b.) The REPT meta instruction:

        ;repeat block: "seven NOPs"

        REPT 7
          NOP   ;;short pause
        ENDM

; c.) The EXITM meta instruction, recursive macro calls,
;     and the macro operators % and & :

        ;define macro DEFNSYM: "define n symbols"

        DEFNSYM MACRO symname, count
          IF count
            DEFNSYM symname, %count-1
            symname&count EQU count
          ELSE
            EXITM       ;;stop recursion if count=0
          ENDIF
        ENDM

; d.) The general controls $SAVE, $GENONLY, and $CONDONLY:

$SAVE                              ;save current $GEN/$COND/$LIST state
$GENONLY                           ;list only macro expansion lines
$CONDONLY                          ;list only true IFxx branches

        ;DEFNSYM macro calls:

        DEFNSYM SYMBOL, 5          ;define 5 symbols SYMBOLx
        DEFNSYM CONST, %DIFFER-7   ;define DIFFER-7 symbols CONSTx

; e.) The IFB and ELSEIFB meta instructions, and <...> literal brackets:

        ;define macro PATCH: "concatenate 3 literals"

        PATCH MACRO p1, p2, p3
          IFB <p1>
            PATCH 1_, <p2>, <p3>
          ELSEIFB <p2>
            PATCH <p1>, _2_, <p3>
          ELSEIFB <p3>
            PATCH <p1>, <p2>, _3
          ELSE
            DB '&p1&p2&p3'
          ENDIF
        ENDM

; f.) The general control $GEN:

$GEN                                    ;list macro calls and expansion lines

; g.) Omitting macro parameters, and the literal operator ! :

        ;PATCH macro calls:

        PATCH one, two, three           ;3 literal parameters specified
        PATCH ,two                      ;1st and 3rd parameter omitted
        PATCH one,,three                ;2nd parameter omitted
        PATCH                           ;all parameters omitted
        PATCH first, <, , >, last!;     ;special characters passed literally

; h.) The general control $RESTORE:

$RESTORE                                ;restore old $GEN/$COND/$LIST state


; 12. End of Program:
; -------------------

        END     ;end statement

        ;Only blank and commentary lines are allowed here!

⌨️ 快捷键说明

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