home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / CROSSASM / ASM49.ZIP / ASM48.DOC < prev    next >
Encoding:
Text File  |  1988-05-25  |  15.6 KB  |  373 lines

  1.                         ASM48 Version 1.3 
  2.        Cross Assembler for the Intel 8748 Microcontroller
  3.                        By Vance Navarrette
  4.  
  5. Introduction:
  6.  
  7.  
  8.      The ASM 48 assembler was intended to be a simple, easy to 
  9. use assembler for the person who only intends to assemble one or 
  10. two programs for personal use in a hacker type project. This 
  11. person does not want to spend $200-300 for a professional 
  12. product, but rather just needs something simple to get him by.
  13.      The source file is written using any editor that will 
  14. generate an ascii file (Wordstar, or even (Gag!) Edlin) and is 
  15. processed using the ASM48 program to produce an assembled object 
  16. file.
  17.  
  18.  
  19. Changes for version 1.3:
  20.  
  21.      Version 1.3 is now in compiled format using Borland's Turbo 
  22. Basic. This speeds up the execution by a factor of 8. On a 
  23. 4.77MHz IBM PC, a 1K object file would have taken approximately 
  24. 20 minutes to assemble, depending on the number of comments and 
  25. errors in the source file. This will now take a little over 3 
  26. minutes, and on AT class machines the execution time will be 
  27. measured in seconds, not minutes.
  28.      The error messages for version 1.3 have been reworked, so 
  29. that additional kinds of errors are flagged that previously would 
  30. have gone unflagged (object code generation was still correct, 
  31. but certain kinds of errors resulted in the source line in which 
  32. the error occurred to be ignored).
  33.  
  34. To use the program:
  35.  
  36. The program is now much faster than before, but it is impossible 
  37. to modify to suit your needs unless you have the turbo-basic 
  38. compiler. Such is the tradeoff for speed. The program can be 
  39. invoked by typing ASM48 <Enter>. After the program loads, it 
  40. will immediately execute, and will prompt:
  41.  
  42. "Name of file to assemble?"
  43.  
  44.      The user types the name of the source listing file. A sample 
  45. file name would be "A:Test"<Enter>. Note that the program assumes no 
  46. extension is present in the file name. If an extension is 
  47. present, an error will be generated.
  48.      The program will then prompt:
  49.  
  50. "Do you want to print the assembler listing (Enter=YES)?"
  51.  
  52.      The user would type a "N"<Enter> at this point if no hardcopy 
  53. was wanted, or if there is no printer available for the system. 
  54. If the assembler is unable to find a printer, or if the printer 
  55. is not ready, the file will be generated but not printed, and 
  56. execution will terminate with an error message.    It is strongly 
  57. recommended that a listing be used to de-bug any assembly errors. 
  58.      Assuming the file to be assembled is be found, the assembler 
  59. then responds :
  60.  
  61.  
  62. "BEGINNING PASS 1
  63. Press F1 key to abort assembly"
  64.  
  65.      The assembler then decodes the listing, looking for opcodes 
  66. and errors. During this time, a temporary file is created on the 
  67. disk for use by the assembler to store the partially assembled 
  68. code listing. For this reason, it is recommended that there be 
  69. plenty of disk space for large files to assemble. The file will 
  70. be created on the same disk that the source listing resides.
  71.  
  72.      After some time (depending on the amount of code to be 
  73. assembled), the assembler prints:
  74.  
  75. "BEGINNING PASS 2"
  76.  
  77. and continues to assemble the source. During the second pass, 
  78. absolute addresses are assigned to labels and branches. Because 
  79. this assembler produces absolute code, a linker or locator is not 
  80. required. After assembly is complete, an assembler listing is 
  81. produced (if requested) and is sent to the list device (printer). 
  82. In addition to the listing, a label table is dumped to aid in 
  83. debug, and the number of errors is shown.
  84.      The object code is placed in a file called <filespec>.OBJ, 
  85. and the listing, if requested is also placed in a file called 
  86. <filespec>.LST. The assembler then prints on the CRT screen:
  87.  
  88. "ERRORS THIS ASSEMBLY: XX"
  89.  
  90. and assembly is complete.
  91.  
  92.  
  93.  
  94. Syntax of the source file:
  95.  
  96.      It is assumed that the user is familiar with assembly 
  97. language programming, and understands it's elements. For a 
  98. listing of the Intel mnemonics, see the MCS-48 User's Manual, 
  99. available from Intel.
  100.      The structure of a typical source code line is:
  101.  
  102. LABEL       OPCODE  VARIABLE       ;COMMENT <Enter>
  103.  
  104.      Note that the above elements may appear in any combination, 
  105. but only in the order shown. In other words, a label is optional, 
  106. but if present, must appear before the opcode. The opcode is not 
  107. needed for a comment to be legal, but must appear BEFORE the 
  108. comment if present on a line.
  109.      The assembler uses a FREE FIELD format, that is as long as 
  110. spaces are used as delimiters, the spacing of the various 
  111. language elements is irrelevant.
  112.  
  113.      A source file might look like this:
  114.                                              
  115.  
  116.                                             
  117.  
  118.                 ; this is a test file for asm48
  119.                 ;it includes comments and a few sample opcodes
  120.                                                
  121. label1          MOV P4,A                        ;COMMENT
  122.                 DEC R1
  123.                 RR A                            ;ANOTHER COMMENT
  124.                 INC A
  125. LABEL2          XRL A,#  label1                                
  126.         ORL P2,#00                      
  127.                 ORL BUS,# 0F                    
  128.         ADD A,# 55                          
  129.         ORG 000F            ; ORG PSEUDO OP
  130.         DS 05                ; SAVE 5 BYTES
  131.         DB 00,FF,88            ; DEFINE 3 BYTES
  132. ASIC        EQU 00
  133. ASID            EQU ASIC
  134. labelxyz        JMP LABEL2         
  135.         XRL A,#FA            ;TEST FOR HEX 
  136.         NOP
  137.         CALL label1
  138.         JMP 0187            ;TEST FOR GOOD JMP
  139.         DT  HELLO, DEVO!
  140. ARCANE        EQU   LABEL2
  141.                                                 ; END OF TEST
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148. Object Code:
  149.  
  150.      The object code is placed in an Intel compatible ascii HEX 
  151. listing file. The basic format of the hex dump is:
  152.  
  153. :BBAAAA00B1B2B3B4B5B6B7B8B9BABCBDBE...B(N)SS
  154. :BBAAAA00B1B2B3B4B5B6B7B8B9BABCBDBE...B(N)SS
  155.                .
  156.                .
  157.                .
  158. :0000000000
  159.  
  160.      Where:
  161.            BB=Number of bytes in the record (max=255)
  162.            AAAA=Absolute load Address for this record
  163.            00=Always two 0s.
  164.            B1, B2,....B(N)=Object code (Hexadecimal)
  165.            SS=Two's compliment Check Sum of BB, AAAA, and B1-
  166.                 B(N).
  167.  
  168.  
  169.  
  170.      The last record (line) will be all zeroes. Note that NO 
  171. BINARY OBJECT FILE IS PRODUCED. Thus, the output of this 
  172. assembler cannot be loaded directly and executed. This was deemed 
  173. un-necessary, since the target system is a controller, and not 
  174. the host microprocessor. If you need a straight binary file, the 
  175. INHEX subroutine in the basic listing (If you have it) may be 
  176. modified to produce one.
  177.  
  178.  
  179.  
  180.      Points to Remember!:
  181.  
  182.           a. The assembler is case sensitive (i.e. "a" does NOT 
  183.                equal "A")
  184.           b. All mnemonics must be in caps (labels need not be).
  185.           c. All comments start with ";".
  186.           d. The vertical bar "|" is a reserved character. Do not 
  187.                use it! The results are unpredictable.
  188.           e. All numbers are to be in hex. Binary and decimal 
  189.                numbers are not supported.
  190.           f. No math operators (+, -, etc.) are supported.
  191.           g. The file to be assembled must be an ascii coded text 
  192.              file. No special control codes are allowed. If you 
  193.              use a word processor like "Word Star" to edit the 
  194.              file, be sure to use the non-document mode or else 
  195.              do a ^QU command in the non document mode to insure 
  196.              that the assembler won't get confused. You will get 
  197.              error messages with nothing (apparently) wrong in the
  198.              listing file when you try to debug your source code 
  199.              if you fail to observe this rule.
  200.       h. All Hexadecimal number must have two characters, even 
  201.         if they are both zeros.
  202.       i. The ^C and the ^Scroll Lock keys are NOT supported. Use
  203.         F1 key to terminate assembly prematurely.
  204. Pseudo Opcodes:
  205.  
  206.      In addition to the standard Intel mnemonics, several pseudo 
  207. opcodes are supported to control the flow of the assembler and 
  208. aid in producing code with a minimum of fuss. Pseudo opcodes
  209. produce no hexadecimal output, and take up no space in the 
  210. assembled code, although they will show up in your listing and 
  211. will show an "address" in the listing. They are:
  212.  
  213.                DB      "define byte"
  214.                DT     "define Text"
  215.                EQU    "equals"
  216.                ORG     "Set Origin"
  217.                DS     "Define space"
  218.  
  219.      DB: Used to define a byte or bytes of code, using 
  220. hexadecimal. Note that hex notation is always assumed, and that 
  221. multiple bytes are delimited with a single space or comma. Do not 
  222. use an "H" to designate hex, as it is assumed. It is also 
  223. permissible to define a constant using the "EQU" opcode, and then 
  224. use the label previously defined as a variable.
  225.      DT: Used to define text. This generates the ascii code for 
  226. each letter in a text string. Delimiters are not necessary.
  227.      EQU: Sets the label on the left equal to the variable on the 
  228. right. The variable on the right may be hex or a previously 
  229. defined label.
  230.      ORG: This sets the address counter used for assembly to the 
  231. value of the hex variable or label on the right of the pseudo-op. 
  232. The ORG opcode forces the assembly of subsequent code to begin at 
  233. the address given by the variable used for ORG. May be used with 
  234. hex or a previously defined label.
  235.      DS: This allocates space in memory immediately following the 
  236. opcode. The amount of space is defined by the variable used. The
  237. Variable may be Hex or previously defined Label.
  238.  
  239.  
  240.      Error Messages:
  241.      The following error messages are generated during assembly, 
  242. and are fatal (i.e. object code would have been incorrect, so the 
  243. object file was deleted). The error messages will appear as com-
  244. ments in the listing (.LST file). While the original comment will
  245. appear to have been erased and the error message substituted, the 
  246. original comment is in fact still present in the source file. 
  247. Correcting the cause of the error and reassembling the source 
  248. file will cause the original comment to appear in the listing 
  249. file.
  250.  
  251.  
  252. ILLEGAL VARIABLE: A non-hexadecimal character was found where 
  253. only 0-9 or A-F characters were expected, or a label was used as 
  254. a variable and was not previously defined. This error message 
  255. will also be generated if an attempt is made to define a variable 
  256. that is too large (>FFF hexadecimal) or use a variable larger 
  257. than 0FF hex in a branch instruction that expects a single byte 
  258. variable (i.e. using a variable larger than 0FF in any branch 
  259. instruction other than JMP or CALL). 
  260.  
  261. UNKNOWN OPCODE: An opcode was used that is not legal, or an 
  262. opcode is missing, resulting in a variable being interpreted as 
  263. an opcode. Another possible cause is using lower case letters for 
  264. an opcode (all opcodes must be in CAPS). Also note that embedded 
  265. spaces in opcodes are considered significant, and must be present 
  266. if defined by INTEL mnemonics.
  267.  
  268. MISSING VARIABLE: A variable was not found following an opcode  
  269. that requires a variable. Also used when a DT pseudo op is used, 
  270. and there is no text, or when there are no variables following a 
  271. DB pseudo op.
  272.  
  273. LABEL TOO LONG: A label was encountered that was longer than 10 
  274. characters. If a label is too long and subsequently used as a 
  275. variable, an ILLEGAL VARIABLE error message will result.
  276.  
  277. DUPLICATE DEFINITION: A label that was previously defined was 
  278. re-defined subsequent to the original definition. The label will 
  279. appear twice in the label table, but only the first definition 
  280. will be used in the assembly.
  281.  
  282. PAGE ERROR: The 8748 uses certain jump instructions that are only 
  283. valid in a paged memory scheme (this is done for the sake of 
  284. compactness and speed. Most branches in a typical assembly 
  285. program jump to locations that are close by...).An attempt was 
  286. made to cross a page boundary (Address in the range of X00-XFF 
  287. hex) using a branch instruction that only supports branching 
  288. within the page in which that branch instruction occurs. The 
  289. assembler has generated code that will result in a jump to an 
  290. incorrect address.
  291.      This error is not necessarily even possible to see while 
  292. writing the source code. The simplest way to correct the problem 
  293. is to substitute a JMP instruction, but it is possible to simply 
  294. move the offending subroutine inside the addressing page where 
  295. the error occurred.
  296.  
  297.      A word on debugging the source code:
  298.      
  299.      It is possible for more than one error to occur on a given 
  300. line of source code. ONLY THE MOST RECENT ERROR MESSAGE WILL 
  301. APPEAR. Thus it is possible to have an "unknown opcode" error 
  302. message appear, to then correct the opcode error and reassemble, 
  303. only to have a "Illegal Variable" error message appear.
  304.      To save time, it is therefore prudent to examine each 
  305. flagged source line for other mistakes that might have occurred 
  306. during assembly. The error count given at the close of assembly 
  307. will not match a physical count of the error messages under these 
  308. circumstances, and should be taken as an indication of multiple 
  309. errors on single source lines. It is also possible that correcting 
  310. one error will generate another. For instance, the following 
  311. line:
  312.  
  313. TLABEL         ORg       5G            ;Comment.....
  314.  
  315.      Will first result in the "Unknown Opcode" message. After the 
  316. line is corrected:
  317.  
  318. TLABEL         ORG       5G            ;Comment.....
  319.  
  320.      It will generate an "Illegal Variable" Error, since 5G is 
  321. not a legal hex number.
  322.  
  323.  
  324.  
  325.      BASIC error messages:
  326.  
  327.      Several errors can arise that are not part of the assembler 
  328. flow itself, but are generated by BASIC as a result of 
  329. unexpected conditions during the execution of the assembler 
  330. program. They are:
  331.  
  332. PRINTER IS OUT OF PAPER OR IS OFF LINE:
  333.      A listing was requested, but the print device is 
  334. unavailable. 
  335.  
  336. DISK DRIVE IS FULL:
  337.      The disk drive that the source file was found on has 
  338. insufficient space to allow the assembler to complete assembly. 
  339. There are several options to correct this:
  340.  
  341.      1. Copy the source file to a floppy or Hard disk that has 
  342.           more room, and re-assemble the file.
  343.      2. Request that no list file be generated. This will greatly 
  344.           reduce the space (and time) required to assemble the 
  345.           file. (It will also make it nearly impossible to 
  346.           debug. The total error count will appear on the 
  347.           screen at the close of assembly.)
  348.      3. Create a copy of the source file, and edit it to 
  349.           eliminate all comments, blank lines, etc. Then proceed 
  350.           to assemble the new source file.
  351.  
  352.  
  353. DISK DRIVE NOT READY:
  354.      The disk drive named for use by the assembler is unavailable 
  355. to the system. Usually caused by an open door on the disk drive 
  356. or a write protected file or disk.
  357.  
  358.  
  359. SOURCE FILE NOT FOUND:
  360.      The file specified for assembly is not on the specified disk 
  361. drive, or is mis-spelled. This is a non fatal error, and can be 
  362. recovered by retyping the file specification, including the disk 
  363. drive. Be sure to include the name of the sub-directory that the 
  364. file may be located in. Example: A:\SRCFILES\TEST
  365.  
  366.      Additional error messages may be generated by turbo-basic 
  367. that are not found here. These will appear as error code numbers. 
  368. Consult your BASIC manual to correct the error conditions, using 
  369. the error code number that  appears on the screen. Be careful if
  370. you do not have access to a Borlan Turbo-Basic manual. While the
  371. error codes are in the vast majority of cases identicle, there can
  372. be subtle differences in the definition of the error code.
  373.