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

📄 demo.a51

📁 Free 8051 asm compiler for win new host platforms: Win32 and Linux macro processing dramaticall
💻 A51
📖 第 1 页 / 共 2 页
字号:
;                      Demo Program for ASEM-51 V1.3
;                      =============================
;
;                         W.W. Heinz, 25. 6. 2002


; 1. Primary Controls:
; --------------------

$DATE(June 2002)      ;set date string

$DEBUG                ;generate debug information (OMF-51 output only)

$PAGELENGTH (60)      ;set list file page length to 60 lines

$PAGEWIDTH (110)      ;set list file line width to 110 columns

$NOTABS               ;expand all tab characters to blanks

; $NOPAGING           ;no page formatting in list file

$NOSYMBOLS            ;don't generate a symbol table

$XREF                 ;generate a cross reference listing

; $PHILIPS            ;switch to the reduced Philips 83C75x instruction set

; $NOMACRO            ;suppress macro expansion

$NOBUILTIN            ;do not list predefined symbols (SFR)

$NOMOD51              ;disable predefined standard 8051 SFR symbols


; 2. General Controls:
; --------------------

$TITLE(The original ASEM-51 Demo Program!)      ;set page header title

$NOLIST               ;listing off

$INCLUDE (8052.mcu)   ;include 8052 SFR symbol definitions

$LIST                 ;listing on

$EJECT                ;start new page in list file

$NOGEN                ;list macro calls only
$GENONLY              ;list macro expansion lines only
$GEN                  ;list macro calls and expansion lines

$NOCOND               ;don't list lines in false IFxx branches
$CONDONLY             ;list assembled lines in IFxx constructions only
$COND                 ;list full IFxx .. ENDIF constructions

$SAVE                 ;save current $LIST/$GEN/$COND state
$RESTORE              ;restore old $LIST/$GEN/$COND state


; 3. Symbol Definitions:
; ----------------------

        NAME       ASEM_51_DEMO         ;module name

        TARZAN     EQU  -1              ;constant number
        INDEXREG   EQU   R1             ;invariant register

        JANE       SET   10             ;number
        JANE       SET   65535          ;(may be redefined)
        COUNTREG   SET   R5             ;register
        COUNTREG   SET   A              ;(may be redefined)

        CHEETA     DATA  30H            ;DATA address

        JONES      IDATA 90H            ;IDATA address

        MICKEY     XDATA 5000H          ;XDATA address

        GOOFY      BIT   080H.3         ;BIT address

        DONALD     CODE  0f000h         ;CODE address

?ABCDEFGHIJKLMNopqrstuvwxyz_0123456789: ;label (31 significant characters)


; 4. Constants and other Operands
; -------------------------------

        KONST1  EQU   1774      ;decimal
        KONST1d EQU   1774d     ;decimal again
        KONST2  EQU   1774H     ;hex
        KONST3  EQU   1774Q     ;octal
        KONST3o EQU   1774o     ;octal again
        KONST4  EQU   10101010B ;binary
        KONST5  EQU   '@~'      ;ASCII (1 or 2 characters)

        KONST12 EQU   KONST1    ;symbol
        KONST20 EQU   AR0       ;register 0
        KONST21 EQU   AR1       ;   .
        KONST22 EQU   AR2       ;   .
        KONST23 EQU   AR3       ;   .
        KONST24 EQU   AR4       ;   .
        KONST25 EQU   AR5       ;   .
        KONST26 EQU   AR6       ;   .
        KONST27 EQU   AR7       ;register 7
        KONST29 EQU   $         ;location counter


; 5. Operators and Expressions
; ----------------------------

; Operator Precedance:
;
;       ( )                                                   ^   highest
;       + - NOT HIGH LOW                       (unary)        |
;       .                                                     |
;       * / MOD                                               |
;       SHL SHR                                               |
;       + -                                    (binary)       |
;       EQ = NE <> LT < LE <= GT > GE >=                      |
;       AND                                                   |
;       OR XOR                                                v   lowest


        POSITIV EQU      +5193          ;unary plus
        NEGATIV EQU      -5193          ;unary minus
        KOMPLEM EQU  NOT  05555H        ;logical complement
        HIBYTE  EQU  HIGH 01234H        ;high byte
        LOBYTE  EQU  LOW  01234H        ;low byte

        BITNO5  EQU  0B8H.5             ;bit operator

        PRODUC  EQU  83 * 67            ;multiplication
        QUOTIE  EQU  84 / 4             ;division
        MODULO  EQU  83 MOD 8           ;remainder

        SHIFTL  EQU  1234H SHL  4       ;shift left
        SHIFTR  EQU  1234H SHR  4       ;shift right

        SUMME   EQU  83 + 67            ;addition       (binary plus)
        DIFFER  EQU  83 - 67            ;subtraction    (binary minus)

        EQUAL1  EQU   827  EQ  827      ;equal to
        EQUAL2  EQU   827  =  -827      ;equal to

        NOTEQ1  EQU   235  NE  235      ;not equal to
        NOTEQ2  EQU   235  <> -235      ;not equal to

        LESS1   EQU   367  LT  597      ;less than
        LESS2   EQU  -367  <   597      ;less than

        LESSEQ1 EQU   367  LE  597      ;less or equal
        LESSEQ2 EQU  -367  <=  597      ;less or equal

        GREAT1  EQU   367  GT  597      ;greater than
        GREAT2  EQU  -367  >   597      ;greater than

        GREQ1   EQU   367  GE  597      ;greater or equal
        GREQ2   EQU  -367  >=  597      ;greater or equal

        LOGAND  EQU  0AAAAH AND 05555H  ;logical and
        LOGOR   EQU  0AAAAH  OR 05555H  ;logical or
        LOGXOR  EQU  055AAH XOR 05555H  ;exclusive or

        KONST30 EQU  5*(JANE-$+AR5 OR 2) AND 0FFH    ;expression (=30)


; 6. Pseudo Commands:
; -------------------

        ORG  07ff0H    ;set location counter of current segment

        DB   1,7       ;define byte
        DW   2,12,9    ;define word
        DS   3         ;define space

        DSEG           ;switch to DATA segment

        DS   32        ;define space for registers and stack
RAM:    DS   1         ;define space for a variable
RAM1:   DS   1
RAM2:   DS   1

        ISEG AT 080H   ;switch to IDATA segment and set location counter

        DS   10H       ;define space

        XSEG           ;switch to XDATA segment
        ORG  0C000H    ;and set location counter

        DS   5         ;define space

        BSEG AT 040h   ;switch to BIT segment and set location counter
        ORG  050H      ;change location counter

BITAD:  DBIT 4         ;define bits

        CSEG           ;return to CODE segment

STRING: DB 'this is text',0
MIXED:  DB 'a',062H,'cdefghij',06bh,'l',060h+13,'n',MIXED-STRING

        USING 1        ;set register bank


; 7. Instruction Set:
; -------------------

        ;Jumps and Calls:
        ;----------------

PROCED: NOP     ;subroutine
        RET

INTSER: NOP     ;interrupt service routine
        RETI

THERE:  ACALL PROCED
        LCALL PROCED
        CALL  PROCED

        AJMP  THERE
        LJMP  THERE
        SJMP  THERE
        JMP   @A+DPTR
        JMP   THERE

        JZ    THERE
        JNZ   THERE

        JC    THERE
        JNC   THERE

        CJNE A,RAM,THERE
        CJNE A,#KONST4,THERE

        CJNE R0,#KONST4,THERE
        CJNE R1,#KONST4,THERE
        CJNE R2,#KONST4,THERE
        CJNE R3,#KONST4,THERE
        CJNE R4,#KONST4,THERE
        CJNE R5,#KONST4,THERE
        CJNE R6,#KONST4,THERE
        CJNE R7,#KONST4,THERE

        CJNE @R0,#KONST4,THERE
        CJNE @R1,#KONST4,THERE

        DJNZ R0,THERE
        DJNZ R1,THERE
        DJNZ R2,THERE
        DJNZ R3,THERE
        DJNZ R4,THERE
        DJNZ R5,THERE
        DJNZ R6,THERE
        DJNZ R7,THERE

        DJNZ RAM,THERE

        JB BITAD,THERE
        JNB BITAD,THERE
        JBC BITAD,THERE

        ;Arithmetic Instructions:
        ;------------------------

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

        ADD A,RAM

        ADD A,@R0
        ADD A,@R1

        ADD A,#KONST4

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

        ADDC A,RAM

        ADDC A,@R0
        ADDC A,@R1

        ADDC A,#KONST4

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

        SUBB A,RAM

        SUBB A,@R0
        SUBB A,@R1

        SUBB A,#KONST4

        INC A

        INC R0
        INC R1
        INC R2
        INC R3
        INC R4
        INC R5
        INC R6
        INC R7

        INC RAM

        INC @R0
        INC @R1

        DEC A

        DEC R0
        DEC R1
        DEC R2
        DEC R3
        DEC R4
        DEC R5
        DEC R6
        DEC R7

        DEC RAM

        DEC @R0
        DEC @R1

        INC DPTR
        MUL AB
        DIV AB
        DA A

        ;Logical Instructions:
        ;---------------------

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

        ANL A,RAM

        ANL A,@R0
        ANL A,@R1

        ANL A,#KONST4

        ANL RAM,A

        ANL RAM,#KONST4

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

        ORL A,RAM

        ORL A,@R0
        ORL A,@R1

        ORL A,#KONST4

        ORL RAM,A

        ORL RAM,#KONST4

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

        XRL A,RAM

        XRL A,@R0
        XRL A,@R1

⌨️ 快捷键说明

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