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

📄 asem_51.doc

📁 用芯片AT89C51做的简单的万年历
💻 DOC
📖 第 1 页 / 共 5 页
字号:
All file names may be specified without extensions. In these cases, the
program adds default extensions as shown below:

        file             extension
        ------------------------------
        <hex>            .HEX
        <bin>            .BIN

If you want a file name to have no extension, terminate it with a '.'!
Instead of file names you may also specify device names to redirect the
output to character I/O ports. Device names may be terminated with a ':'!
It is not checked, whether the device is existing or suitable for the task.

The binary file output can also be controlled with the options /OFFSET,
/FILL and /LENGTH.
Normally the first byte in the binary file is the first byte of the HEX
record with the lowest load address. If a number of dummy bytes is to be
inserted on top of the file (e.g. for alignment in an EPROM image), this
can be performed with the /OFFSET option:

        /OFFSET:1000

would insert 4096 dummy bytes before the first byte of the first HEX record
loaded. The offset must always be specified as a hex number. The default
offset is 0.
Since there may be peepholes between the HEX records, a fill byte value can
be defined with the /FILL option:

        /FILL:0

would fill all peepholes between the HEX records with zero bytes as well as
all the dummy bytes that might have been inserted with the /OFFSET or /LENGTH
option. The fill byte value must always be specified as a hex number.
The default fill byte is the EPROM-friendly FFH.
By default the last byte in the binary file is the last byte of the HEX
record with the highest load address. If the binary file should have a
well defined length, then a number of dummy bytes can be appended to the
file (e.g. for exactly matching an EPROM length), this can be performed
with the /LENGTH option:

        /LENGTH:8000

would append as many dummy bytes behind the last byte of the file, that the
total file length becomes exactly 32768 bytes. The file length must always
be specified as a hex number.
Options may be abbreviated as long as they remain unique!

Examples:

  1.)      HEXBIN PROGRAM

     will convert the Intel-HEX file PROGRAM.HEX to a pure binary image file
     PROGRAM.BIN.

  2.)      HEXBIN TARZAN.OBJ JUNGLE/FILL:E5

     will convert the Intel-HEX file TARZAN.OBJ to a binary image file
     JUNGLE.BIN and fill all peepholes between the HEX file records with
     the binary value E5H.

  3.)      HEXBIN PROJECT EPROM. /off:8000 /length:10000 /f:0

     will convert the Intel-HEX file PROJECT.HEX to a binary image file
     EPROM, insert 32K dummy bytes on top of file, fill all peepholes
     and the dummy bytes with nulls, and extend the file to exactly 64K.

When terminating HEXBIN returns an exit code to the operating system:

     situation                           ERRORLEVEL
     ----------------------------------------------
     no errors                               0
     conversion errors detected              1
     fatal runtime error                     2


II.5 The DEMO Program
---------------------
For getting started with a new assembler, it is always good to have a
program, that can be assembled with it. For this purpose, the 8051
assembler program DEMO.A51 is provided, that can be used for a first
test of ASEM-51. Be sure to have all files of the ASEM-51 package on your
disk! Then simply type

        ASEM DEMO
        HEXBIN DEMO

at the DOS prompt. ASEM and HEXBIN should finish without errors and you
should have the following new files on your disk:

        DEMO.HEX          Intel-HEX file
        DEMO.LST          assembler list file of DEMO.A51
        DEMO.BIN          binary image file of DEMO.HEX

When something goes wrong, there may be files missing in your distribution!
DEMO.A51 may also serve as a sample assembler program that includes
examples for all machine instructions, pseudo instructions and assembler
controls, that have been implemented in ASEM-51. Whenever in doubt how to
use a particular command, DEMO.A51 may be a valuable help.


III.  The ASEM-51 Assembly Language
===================================
The user should be familiar with 8051 microcontrollers and assembly
language programming. This manual will not explain the architecture of
the MCS-51 microcontroller family nor will it discuss the basic concepts
of assembly language programming. It only describes the general syntax
of assembler statements and the assembler instructions that have been
implemented in ASEM-51.


III.1 Statements
----------------
Source files consist of a sequence of statements of one of the forms:

          [symbol:]  [instruction [arguments]]     [;comment]

           symbol     instruction  argument        [;comment]

          $control   [argument]                    [;comment]

Everything that is written in brackets is optional.
The maximum length of source code lines is 255 characters.
Everything from the ';' character to the end of line is assumed to be
commentary. Blank lines are considered to be commentary, too.
The lexical elements of a statement may be separated by blanks and tabs.
Aside of character string constants, upper and lower case letters are
equivalent.

Examples:     HERE:   MOV A,#0FFH     ;define label HERE and load A with FFH

                      YEAR EQU 1996   ;define symbol for current year

              $INCLUDE (80C517.MCU)   ;include SAB80C517 register definitions


III.2 Symbols
-------------
Symbols are user-defined names for addresses or numbers.
Their maximum significant length is 31 characters. They can be even
longer, but everything behind the first 31 characters is ignored.
Symbols may consist of letters, digits, '_' and '?' characters.
A symbol name must not start with a digit!
Upper and lower case letters are considered to be equivalent.
Note: Assembly language keywords must not be redefined as user symbols!

Example:     Is_this_really_a_SYMBOL_?       is a legal symbol name!


III.3 Constants
---------------
Numeric constants consist of a sequence of digits, followed by a radix
specifier. The first character must always be a decimal digit.
The legal digits and radix specifiers are:

          constant     digits        radix
          ------------------------------------
          binary       0 ... 1       B
          octal        0 ... 7       Q or O
          decimal      0 ... 9       D or none
          hex          0 ... F       H

Thus, for example, the following constants are equivalent:

          1111111B      binary
              177Q      octal
              177o      octal
               127      decimal
              127d      decimal
              07FH      hex

Character constants may be used wherever a numeric value is allowed.
A character constant consists of one or two printing characters enclosed
in single or double quotes. The quote character itself can be represented
by two subsequent quotes. For example:

               'X'       8 bit constant:       58H
              "a@"      16 bit constant:     6140H
              ''''       8 bit constant:       27H

In DB statements, character constants may have any length.
In this case, we call it a character string. For example:

              "It's only text!"


III.4 Expressions
-----------------
Arithmetic expressions are composed of operands, operators and parentheses.
Operands may be user-defined symbols, constants or special assembler symbols.
All operands are treated as unsigned 16-bit numbers.
Special assembler symbols, that can be used as operands are:

    AR0, ... , AR7     direct addresses of registers R0 thru R7

    $                  the location counter of the currently active segment
                       (start address of the current assembler statement)

The following operators are implemented:

Unary operators:   +          identity:             +x = x
                   -          two's complement:     -x = 0-x
                   NOT        one's complement:  NOT x = FFFFH-x
                   HIGH       high order byte
                   LOW        low order byte

Binary operators:  +          unsigned addition
                   -          unsigned subtraction
                   *          unsigned multiplication
                   /          unsigned division
                   MOD        unsigned remainder
                   SHL        logical shift left
                   SHR        logical shift right
                   AND        logical and
                   OR         logical or
                   XOR        exclusive or
                   .          bit operator used for bit-adressable locations
                   EQ  or =   equal to                ----.
                   NE  or <>  not equal to                |  results are:
                   LT  or <   less than                   |
                   LE  or <=  less or equal than          |     0 if FALSE
                   GT  or >   greater than                |  FFFF if TRUE
                   GE  or >=  greater or equal than   ____|

Operators that are no special characters but keywords as SHR or AND must
be separated from their operands by at least one blank or tab.
In general expressions are evaluated from left to right according to
operator precedence, which may be overridden by parentheses.
Parentheses may be nested to any level.
Expressions always evaluate to unsigned 16-bit numbers, while overflows
are ignored. When an expression result is to be assigned to an 8-bit
quantity, the high byte must be either 00 or FF.

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

Example:  The expression  P1.((87+3)/10 AND -1 SHR 0DH)  will evaluate to 91H.


III.5 The 8051 Instruction Set
------------------------------
ASEM-51 implements all 8051 machine instructions including generic jumps
and calls. The assembler implements two instructions

        JMP  <address>
        CALL <address>

that do not represent a specific opcode: generic jump and call.
These instructions will always evaluate to a jump or call, not necessarily
the shortest, that will reach the specified address.
JMP may assemble to SJMP, AJMP or LJMP, while CALL can only evaluate to
ACALL or LCALL. Note that the assembler decision may not be optimal. For
code addresses that are forward references, the assembler always generates
LJMP or LCALL respectively. However, for backward references this is a
powerful tool to reduce code size without extra trouble.

With the $PHILIPS control, ASEM-51 can be switched to the reduced instruction
set of the Philips 83C75x family of microcontrollers. This disables the LJMP,
LCALL, and MOVX instructions as well as the XDATA and XSEG pseudo instructions,
and generic jumps and calls will always assemble to absolute addressing.

The rest of the 8051 instruction mnemonics is listed in Appendix D.
Appendices I and J are containing tables of all 8051 instructions with
their opcodes, mnemonics, arguments, lengths, affected flags and durations.
The comprehensive example program DEMO.A51 provided shows all the 8051
instructions in a syntactical context.
All 8051 instruction mnemonics are copyright (c) by Intel corporation!


III.6 Pseudo Instructions
-------------------------
In the subsequent paragraphs, all ASEM-51 pseudo instructions are described.
Lexical symbols are written in lower case letters, while assembler keywords
are written in upper case.
Instruction arguments are represented by <arg>, <arg1> or something like
that. Expressions are represented by <expr>, <expr1> and so on.
Syntax elements enclosed in brackets are optional.
The ellipsis "..." means always "a list with any number of elements".


DB <arg1> [,<arg2> [,<arg3> ... ]]              define bytes

        The DB instruction reserves and initializes a number of bytes with
        the values defined by the arguments. The arguments may either be
        expressions (which must evaluate to 8-bit values) or character
        strings of any length. DB is only allowed in the CODE segment!

        Example:   DB 11,'January',96,(3*7+12)/11


DW <expr1> [,<expr2> [,<expr3> ... ]]           define words

        The DW instruction reserves and initializes a number of words with
        the values defined by the arguments. Every argument may be an
        arbitrary expression and requires two bytes of space.
        DW is only allowed in the CODE segment!

        Example:   DW 0,0C800H,1996,4711


DS <expr>                                       define space

        Reserves a number of uninitialized bytes in the current segment.
        The value of <expr> must be known on pass 1!
        DS is allowed in every segment!

⌨️ 快捷键说明

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