home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / _ / 6502xass / !6502-XAss / Docs / !Instruct next >
Text File  |  1995-12-24  |  11KB  |  382 lines

  1.  
  2.                      6502/6510 Cross Assembler System
  3.                      
  4.                        Version 0.72ß (24 Dec 1995)
  5.                   
  6.                         ©1995 Skoe of Expression
  7.                   
  8.  
  9. The 6502/6510 Cross Assembler System (XAss) was made for comfortable
  10. programming of these 8 bit processors. The object code can be found in
  11. the file "scrap.object" or transfered directly to the 8 bit computer.
  12. XAss has a lot of functions developed for the Commodore 64.
  13.  
  14. This file will not explain programming assembler, only the use of XAss.
  15. I offer you to read this text carefully to avoid problems!
  16.                                                     
  17.  
  18. STARTING XASS
  19. ~~~~~~~~~~~~~
  20. Double click the 6502-XAss icon or drag it onto the iconbar.
  21.  
  22.  
  23. TRANSFER
  24. ~~~~~~~~
  25. You will need a cable (not too long) from Archimedes/RiscPC parallel 
  26. printer port to a parallel port of the 6502/6510 computer, e.g. the C64 
  27. user port (see the file "C64-Cable"). The format of transfered datas is 
  28. explained in chapter "SCRAP/Object".
  29. The destination machine will need a small program for receiving. For C64
  30. you can find the files "Transfer" and "Trans-Run" in the Sources directory.
  31. I suppose that you are a coder so I do not explain the usage. You must
  32. type it into a C-64 assembler or assemble it using XAss and transfer it
  33. in hex dump.
  34.  
  35. If you use another computer, I'll explain the link:
  36. You have 8 data wires (0V = low, 5V = high), one for ground (0V) and the
  37. "^ACK" wire. To order the next byte the destination computer must pull
  38. this one down to 0V, normally it's 5V. The parallel link uses only one way
  39. handshaking, so the destination computer must read slower than the Arc can
  40. send. If the Arc is slower it will happen that the destination reads one
  41. byte two times, e.g. if you write the receiving routine in assembler 
  42. without waiting loops.
  43.  
  44.  
  45. SYMBOLS  
  46. ~~~~~~~         
  47. Symbols can contain all letters, numbers and the '_'. They must not start
  48. with a number. Symbol names can be very long, the assembler uses only the
  49. first 39 characters. Symbols are case sensitiv, i.e. "my_label_1" and
  50. "My_Label_1" are not the same!
  51.  
  52. You can use intern and extern symbols. Intern symbols are labels inside your
  53. program. You define one in a seperate line beginning with a dot:
  54.                
  55.                sei                     ; set IRQ flag
  56. .my_nice_label                         ; here is my label
  57.                nop                     ; do nothing
  58.                dex                     ; decrement X reg
  59.                bne my_nice_label       ; if not zero branch to my label
  60.  
  61. Extern symbols can contain any number from 0 to $FFFF. You can define one in
  62. a seperate line beginning with a '!':
  63.  
  64. !letter_A = 65                         ; 65 is a capital 'A' 
  65. !screen = $0400                        ; this is the address of screen mem
  66.                lda #65                 ; load akku with #65
  67.                sta screen              ; store it into $0400
  68.  
  69. To generate a program you must define a base address. To do this, simply
  70. define the extern symbol "base" (not "Base" or "BASE"!) at the top of your
  71. source code:
  72.  
  73. ; -----------------------------------           
  74. ; This is a complete program for C-64
  75. ; It prints 256 letters onto screen
  76.  
  77. !base = $c000                          ; start this program with "SYS 49152"
  78. !screen = $0400
  79. !letter = 65
  80.              sei
  81.              lda #letter
  82.              ldx #0
  83. .loop           
  84.              sta screen,x
  85.              dex
  86.              bne loop
  87.              rts
  88. ; -----------------------------------
  89.               
  90. As you can see you can use symbols like normal numbers or addresses.
  91.  
  92.  
  93. TERMS
  94. ~~~~~
  95. Every parameter can contain simple calculations, i.e.
  96.  
  97. ;-----------------------------------                                   
  98. !base = $C000
  99. !label_2 = 3         
  100.              jmp base + label_2 - 3     ; jumps to $C000+3-3 = $C000
  101. ;-----------------------------------                                   
  102.  
  103. ;-----------------------------------                                   
  104. !one = 1
  105. !two = 2
  106.              lda #3 * (one + two)       ; loads akku with #9
  107. ;-----------------------------------                                   
  108.  
  109. You can use decimal and hexadecimal numbers. Hex can begin with '&' (like on
  110. Acorn computers) or with '$' (like on C64).
  111.  
  112. If an term starts with '<' or '>' you'll get the low or high byte of an 
  113. expression:
  114.  
  115. !base = $C000
  116.              lda #<base              ;load akku with #$00
  117.              lda #>base              ;load akku with #$C0
  118.  
  119. Note: The parser has a bug recognizing brackets. E.g. you want to get "lda 20" 
  120.       and write "lda (2+3)*4". The assembler answers with a "missing ')' 
  121.       error". Use "lda 4*(2+3)" instead!                 
  122.  
  123.  
  124. ADRESS MODES
  125. ~~~~~~~~~~~~             
  126. Explained in a very short form:
  127. (By the way: you can use "LDA $0ca0", "lda $0Ca0" or "Lda $0CA0"...
  128.  not case sensitive)
  129.                           
  130.           examples       length
  131.           --------       ------                          
  132.           asl
  133.           nop            ;1 byte  (akku or single command)
  134.  
  135.           ldx #symbol+1
  136.           lda #3         ;2 bytes (direct)
  137.       
  138.           lda z,100      ;2 bytes (zeropage)  \
  139.                                                \   if you forget "z,"
  140.           lda z,$a1,x    ;2 bytes (zeropage,x)  \  the assembler will
  141.                                                 /  use "absolute[,x|,y]"
  142.           ldx z,5,y      ;2 bytes (zeropage,y) / 
  143.                                                 
  144.           ldy $400       ;3 bytes (absolute)   
  145.  
  146.           lda $0400,x    ;3 bytes (absolute,x)
  147.  
  148.           ldx $04C0,y    ;3 bytes (absolute,y)
  149.  
  150.           bcc label      ;2 bytes (relative)
  151.                                   
  152.           adc ($10,x)    ;2 bytes (indirect,x)
  153.                          ;        it's the same as "adc z,($10,x)"
  154.  
  155.           adc (1),y      ;2 bytes (indirect,y)
  156.                          ;        or "adc z,(1),y"
  157.  
  158.           jmp ($200)     ;3 bytes (absolute indirect)
  159.  
  160. Note: a command like "lda 1" will assembled as absolute command (3 bytes),
  161.       if you want a zeropage command (2 bytes) you MUST use "lda z,1" !
  162.       So you or the assembler will have no problems with these address modes
  163.       in future (knowing the used address mode is important e.g. for self
  164.       changing code or difficult timing e.g. "bit z,0").
  165.       The XAss is the only assembler I know that uses this "z," method.
  166.  
  167.  
  168. ASSEMBLER COMMANDS
  169. ~~~~~~~~~~~~~~~~~~
  170. /align
  171.  
  172. is sometimes a very useful command. It fills the object file with NOPs until
  173. the program counter is $xx00. The meaning is, that branches (B?? mnemonics)
  174. are one cycle faster if they do not overjump a memory page. It could be very
  175. important for routines with difficult timing.
  176.  
  177. example:
  178.                     
  179. ;---------------------
  180.  !base = $5aff
  181.             dex
  182.             bne base 
  183. ;---------------------
  184.  
  185. is slower than
  186.  
  187. ;---------------------
  188. !base = $5aff    
  189. /align
  190. .loop
  191.             dex
  192.             bne loop  
  193. ;---------------------
  194.  
  195.  
  196. /by
  197.  
  198. puts some bytes into memory, e.g.:
  199.  
  200. /by 0,3+3,<label
  201.  
  202.  
  203. /tx "Some text"
  204.  
  205. puts a ASCII text into memory. The table for translating Acorn to C-64 ASCII
  206. you can find in the file "<6502-XAss$Dir>.c.TextTable", it's a part of the
  207. source code of XAss, you mustn't change it!
  208.  
  209. Some specials:
  210.  
  211. Arc CHR$
  212.  °  0     e.g. for string ends
  213.  ä  27 [
  214.  ö  28 £
  215.  ü  29 ]
  216.  ß  30 ^  
  217.  Ä  91 
  218.  Ö  92
  219.  Ü  93
  220.  _  13    enter
  221.  
  222.  ~        clr/home
  223.  “        "
  224.  
  225.  
  226. /sc "Text"                                                             
  227.  
  228. puts the screen codes into memory (C-64 POKE codes). Useful for scrollers...
  229.  
  230. Note: if you use set 1 at C64, small letters on Arc will be capital letters
  231.       on C64, capital letters on Arc will be graphic characters on C64.
  232.                                                                       
  233.  
  234. PRECOMPILER
  235. ~~~~~~~~~~~                             
  236. Precompiler commands start allways with an '#' as first (!) char at a line. 
  237.  
  238. #include
  239.  
  240. Big sources can be splitted into several text files. At the line containing
  241. this command the precompiler includes this file. At the moment included
  242. files mustn't contain "#include".
  243. An example:
  244.  
  245. File "IDEFS::4.$.Main