home *** CD-ROM | disk | FTP | other *** search
- ASM48 Version 1.3
- Cross Assembler for the Intel 8748 Microcontroller
- By Vance Navarrette
-
- Introduction:
-
-
- The ASM 48 assembler was intended to be a simple, easy to
- use assembler for the person who only intends to assemble one or
- two programs for personal use in a hacker type project. This
- person does not want to spend $200-300 for a professional
- product, but rather just needs something simple to get him by.
- The source file is written using any editor that will
- generate an ascii file (Wordstar, or even (Gag!) Edlin) and is
- processed using the ASM48 program to produce an assembled object
- file.
-
-
- Changes for version 1.3:
-
- Version 1.3 is now in compiled format using Borland's Turbo
- Basic. This speeds up the execution by a factor of 8. On a
- 4.77MHz IBM PC, a 1K object file would have taken approximately
- 20 minutes to assemble, depending on the number of comments and
- errors in the source file. This will now take a little over 3
- minutes, and on AT class machines the execution time will be
- measured in seconds, not minutes.
- The error messages for version 1.3 have been reworked, so
- that additional kinds of errors are flagged that previously would
- have gone unflagged (object code generation was still correct,
- but certain kinds of errors resulted in the source line in which
- the error occurred to be ignored).
-
- To use the program:
-
- The program is now much faster than before, but it is impossible
- to modify to suit your needs unless you have the turbo-basic
- compiler. Such is the tradeoff for speed. The program can be
- invoked by typing ASM48 <Enter>. After the program loads, it
- will immediately execute, and will prompt:
-
- "Name of file to assemble?"
-
- The user types the name of the source listing file. A sample
- file name would be "A:Test"<Enter>. Note that the program assumes no
- extension is present in the file name. If an extension is
- present, an error will be generated.
- The program will then prompt:
-
- "Do you want to print the assembler listing (Enter=YES)?"
-
- The user would type a "N"<Enter> at this point if no hardcopy
- was wanted, or if there is no printer available for the system.
- If the assembler is unable to find a printer, or if the printer
- is not ready, the file will be generated but not printed, and
- execution will terminate with an error message. It is strongly
- recommended that a listing be used to de-bug any assembly errors.
- Assuming the file to be assembled is be found, the assembler
- then responds :
-
-
- "BEGINNING PASS 1
- Press F1 key to abort assembly"
-
- The assembler then decodes the listing, looking for opcodes
- and errors. During this time, a temporary file is created on the
- disk for use by the assembler to store the partially assembled
- code listing. For this reason, it is recommended that there be
- plenty of disk space for large files to assemble. The file will
- be created on the same disk that the source listing resides.
-
- After some time (depending on the amount of code to be
- assembled), the assembler prints:
-
- "BEGINNING PASS 2"
-
- and continues to assemble the source. During the second pass,
- absolute addresses are assigned to labels and branches. Because
- this assembler produces absolute code, a linker or locator is not
- required. After assembly is complete, an assembler listing is
- produced (if requested) and is sent to the list device (printer).
- In addition to the listing, a label table is dumped to aid in
- debug, and the number of errors is shown.
- The object code is placed in a file called <filespec>.OBJ,
- and the listing, if requested is also placed in a file called
- <filespec>.LST. The assembler then prints on the CRT screen:
-
- "ERRORS THIS ASSEMBLY: XX"
-
- and assembly is complete.
-
-
-
- Syntax of the source file:
-
- It is assumed that the user is familiar with assembly
- language programming, and understands it's elements. For a
- listing of the Intel mnemonics, see the MCS-48 User's Manual,
- available from Intel.
- The structure of a typical source code line is:
-
- LABEL OPCODE VARIABLE ;COMMENT <Enter>
-
- Note that the above elements may appear in any combination,
- but only in the order shown. In other words, a label is optional,
- but if present, must appear before the opcode. The opcode is not
- needed for a comment to be legal, but must appear BEFORE the
- comment if present on a line.
- The assembler uses a FREE FIELD format, that is as long as
- spaces are used as delimiters, the spacing of the various
- language elements is irrelevant.
-
- A source file might look like this:
-
-
-
-
- ; this is a test file for asm48
- ;it includes comments and a few sample opcodes
-
- label1 MOV P4,A ;COMMENT
- DEC R1
- RR A ;ANOTHER COMMENT
- INC A
- LABEL2 XRL A,# label1
- ORL P2,#00
- ORL BUS,# 0F
- ADD A,# 55
- ORG 000F ; ORG PSEUDO OP
- DS 05 ; SAVE 5 BYTES
- DB 00,FF,88 ; DEFINE 3 BYTES
- ASIC EQU 00
- ASID EQU ASIC
- labelxyz JMP LABEL2
- XRL A,#FA ;TEST FOR HEX
- NOP
- CALL label1
- JMP 0187 ;TEST FOR GOOD JMP
- DT HELLO, DEVO!
- ARCANE EQU LABEL2
- ; END OF TEST
-
-
-
-
-
-
- Object Code:
-
- The object code is placed in an Intel compatible ascii HEX
- listing file. The basic format of the hex dump is:
-
- :BBAAAA00B1B2B3B4B5B6B7B8B9BABCBDBE...B(N)SS
- :BBAAAA00B1B2B3B4B5B6B7B8B9BABCBDBE...B(N)SS
- .
- .
- .
- :0000000000
-
- Where:
- BB=Number of bytes in the record (max=255)
- AAAA=Absolute load Address for this record
- 00=Always two 0s.
- B1, B2,....B(N)=Object code (Hexadecimal)
- SS=Two's compliment Check Sum of BB, AAAA, and B1-
- B(N).
-
-
-
- The last record (line) will be all zeroes. Note that NO
- BINARY OBJECT FILE IS PRODUCED. Thus, the output of this
- assembler cannot be loaded directly and executed. This was deemed
- un-necessary, since the target system is a controller, and not
- the host microprocessor. If you need a straight binary file, the
- INHEX subroutine in the basic listing (If you have it) may be
- modified to produce one.
-
-
-
- Points to Remember!:
-
- a. The assembler is case sensitive (i.e. "a" does NOT
- equal "A")
- b. All mnemonics must be in caps (labels need not be).
- c. All comments start with ";".
- d. The vertical bar "|" is a reserved character. Do not
- use it! The results are unpredictable.
- e. All numbers are to be in hex. Binary and decimal
- numbers are not supported.
- f. No math operators (+, -, etc.) are supported.
- g. The file to be assembled must be an ascii coded text
- file. No special control codes are allowed. If you
- use a word processor like "Word Star" to edit the
- file, be sure to use the non-document mode or else
- do a ^QU command in the non document mode to insure
- that the assembler won't get confused. You will get
- error messages with nothing (apparently) wrong in the
- listing file when you try to debug your source code
- if you fail to observe this rule.
- h. All Hexadecimal number must have two characters, even
- if they are both zeros.
- i. The ^C and the ^Scroll Lock keys are NOT supported. Use
- F1 key to terminate assembly prematurely.
- Pseudo Opcodes:
-
- In addition to the standard Intel mnemonics, several pseudo
- opcodes are supported to control the flow of the assembler and
- aid in producing code with a minimum of fuss. Pseudo opcodes
- produce no hexadecimal output, and take up no space in the
- assembled code, although they will show up in your listing and
- will show an "address" in the listing. They are:
-
- DB "define byte"
- DT "define Text"
- EQU "equals"
- ORG "Set Origin"
- DS "Define space"
-
- DB: Used to define a byte or bytes of code, using
- hexadecimal. Note that hex notation is always assumed, and that
- multiple bytes are delimited with a single space or comma. Do not
- use an "H" to designate hex, as it is assumed. It is also
- permissible to define a constant using the "EQU" opcode, and then
- use the label previously defined as a variable.
- DT: Used to define text. This generates the ascii code for
- each letter in a text string. Delimiters are not necessary.
- EQU: Sets the label on the left equal to the variable on the
- right. The variable on the right may be hex or a previously
- defined label.
- ORG: This sets the address counter used for assembly to the
- value of the hex variable or label on the right of the pseudo-op.
- The ORG opcode forces the assembly of subsequent code to begin at
- the address given by the variable used for ORG. May be used with
- hex or a previously defined label.
- DS: This allocates space in memory immediately following the
- opcode. The amount of space is defined by the variable used. The
- Variable may be Hex or previously defined Label.
-
-
- Error Messages:
- The following error messages are generated during assembly,
- and are fatal (i.e. object code would have been incorrect, so the
- object file was deleted). The error messages will appear as com-
- ments in the listing (.LST file). While the original comment will
- appear to have been erased and the error message substituted, the
- original comment is in fact still present in the source file.
- Correcting the cause of the error and reassembling the source
- file will cause the original comment to appear in the listing
- file.
-
-
- ILLEGAL VARIABLE: A non-hexadecimal character was found where
- only 0-9 or A-F characters were expected, or a label was used as
- a variable and was not previously defined. This error message
- will also be generated if an attempt is made to define a variable
- that is too large (>FFF hexadecimal) or use a variable larger
- than 0FF hex in a branch instruction that expects a single byte
- variable (i.e. using a variable larger than 0FF in any branch
- instruction other than JMP or CALL).
-
- UNKNOWN OPCODE: An opcode was used that is not legal, or an
- opcode is missing, resulting in a variable being interpreted as
- an opcode. Another possible cause is using lower case letters for
- an opcode (all opcodes must be in CAPS). Also note that embedded
- spaces in opcodes are considered significant, and must be present
- if defined by INTEL mnemonics.
-
- MISSING VARIABLE: A variable was not found following an opcode
- that requires a variable. Also used when a DT pseudo op is used,
- and there is no text, or when there are no variables following a
- DB pseudo op.
-
- LABEL TOO LONG: A label was encountered that was longer than 10
- characters. If a label is too long and subsequently used as a
- variable, an ILLEGAL VARIABLE error message will result.
-
- DUPLICATE DEFINITION: A label that was previously defined was
- re-defined subsequent to the original definition. The label will
- appear twice in the label table, but only the first definition
- will be used in the assembly.
-
- PAGE ERROR: The 8748 uses certain jump instructions that are only
- valid in a paged memory scheme (this is done for the sake of
- compactness and speed. Most branches in a typical assembly
- program jump to locations that are close by...).An attempt was
- made to cross a page boundary (Address in the range of X00-XFF
- hex) using a branch instruction that only supports branching
- within the page in which that branch instruction occurs. The
- assembler has generated code that will result in a jump to an
- incorrect address.
- This error is not necessarily even possible to see while
- writing the source code. The simplest way to correct the problem
- is to substitute a JMP instruction, but it is possible to simply
- move the offending subroutine inside the addressing page where
- the error occurred.
-
- A word on debugging the source code:
-
- It is possible for more than one error to occur on a given
- line of source code. ONLY THE MOST RECENT ERROR MESSAGE WILL
- APPEAR. Thus it is possible to have an "unknown opcode" error
- message appear, to then correct the opcode error and reassemble,
- only to have a "Illegal Variable" error message appear.
- To save time, it is therefore prudent to examine each
- flagged source line for other mistakes that might have occurred
- during assembly. The error count given at the close of assembly
- will not match a physical count of the error messages under these
- circumstances, and should be taken as an indication of multiple
- errors on single source lines. It is also possible that correcting
- one error will generate another. For instance, the following
- line:
-
- TLABEL ORg 5G ;Comment.....
-
- Will first result in the "Unknown Opcode" message. After the
- line is corrected:
-
- TLABEL ORG 5G ;Comment.....
-
- It will generate an "Illegal Variable" Error, since 5G is
- not a legal hex number.
-
-
-
- BASIC error messages:
-
- Several errors can arise that are not part of the assembler
- flow itself, but are generated by BASIC as a result of
- unexpected conditions during the execution of the assembler
- program. They are:
-
- PRINTER IS OUT OF PAPER OR IS OFF LINE:
- A listing was requested, but the print device is
- unavailable.
-
- DISK DRIVE IS FULL:
- The disk drive that the source file was found on has
- insufficient space to allow the assembler to complete assembly.
- There are several options to correct this:
-
- 1. Copy the source file to a floppy or Hard disk that has
- more room, and re-assemble the file.
- 2. Request that no list file be generated. This will greatly
- reduce the space (and time) required to assemble the
- file. (It will also make it nearly impossible to
- debug. The total error count will appear on the
- screen at the close of assembly.)
- 3. Create a copy of the source file, and edit it to
- eliminate all comments, blank lines, etc. Then proceed
- to assemble the new source file.
-
-
- DISK DRIVE NOT READY:
- The disk drive named for use by the assembler is unavailable
- to the system. Usually caused by an open door on the disk drive
- or a write protected file or disk.
-
-
- SOURCE FILE NOT FOUND:
- The file specified for assembly is not on the specified disk
- drive, or is mis-spelled. This is a non fatal error, and can be
- recovered by retyping the file specification, including the disk
- drive. Be sure to include the name of the sub-directory that the
- file may be located in. Example: A:\SRCFILES\TEST
-
- Additional error messages may be generated by turbo-basic
- that are not found here. These will appear as error code numbers.
- Consult your BASIC manual to correct the error conditions, using
- the error code number that appears on the screen. Be careful if
- you do not have access to a Borlan Turbo-Basic manual. While the
- error codes are in the vast majority of cases identicle, there can
- be subtle differences in the definition of the error code.