home *** CD-ROM | disk | FTP | other *** search
- Creating ASM65.COM
- ------------------
- Thσ ASM6╡ assemble≥ ha≤ beeε buil⌠ a≤ aε overla∙ t∩ Digita∞ ì
- Research'≤ AS═ assemble≥ fo≥ 808░ serie≤ processors« T∩ protec⌠ ì
- you≥ CP/═ licencσ froφ Digita∞ Research¼ ASM6╡ i≤ supplieΣ onl∙ ì
- iε .HE╪ form¼ anΣ mus⌠ bσ mergeΣ witΦ aε existinτ cop∙ oµ ASM.CO═ ì
- usinτ DD╘ o≥ ß simila≥ 8080/Z8░ debugger« Usinτ DDT¼ thσ ì
- conversatioε t∩ creatσ ASM65.CO═ i≤ a≤ follows:
-
- A>ddt asm.com
- DDT VERS 2.2
- NEXT PC
- 2100 0100
- -iasm65.hex
- -r
- NEXT PC
- 2300 0100
- -^C
- A>save 34 asm65.com
-
-
-
- èBackground
- ----------
- ASM6╡ i≤ ß 650▓ cross-assemble≥ fo≥ CP/═ system≤ -- iε othe≥ ì
- word≤ i⌠ use≤ 650▓ assembl∙ languagσ t∩ creatσ program≤ fo≥ 6502-ì
- baseΣ systems¼ bu⌠ thσ assemble≥ itselµ run≤ oε CP/═ systems¼ ì
- allowinτ thσ usσ oµ better-qualit∙ editor≤ sucΦ a≤ WordSta≥ anΣ ì
- Spellbinde≥ t∩ creatσ prograφ source« I⌠ i≤ ß ful∞ conditiona∞ ì
- bu⌠ non-macr∩ assemble≥ supportinτ al∞ 650▓ opcode≤ anΣ ì
- addressinτ mode≤ (includinτ thσ extension≤ supporteΣ oε thσ GT┼ ì
- 65C0▓ processor⌐ witΦ ß gooΣ rangσ oµ pseudo-operations« I⌠ doe≤ ì
- NOT conver⌠ 8080/Z8░ assembl∙ languagσ program≤ t∩ 650▓ ì
- equivalents.
-
- Wσ assumσ tha⌠ yo⌡ arσ familia≥ witΦ assembl∙ languagσ ì
- programminτ -- iµ not¼ wσ woulΣ advisσ readinτ '650▓ Assembl∙ ì
- Languagσ Programmingº (Leventhal¼ Osborne/McGraw-Hill⌐ o≥ aε ì
- equivalen⌠ iε conjunctioε witΦ thesσ notes« Wσ als∩ assumσ tha⌠ ì
- yo⌡ havσ ß cop∙ oµ thσ Digita∞ ResearcΦ AS═ manua∞ t∩ hand¼ a≤ wσ ì
- wil∞ refe≥ t∩ i⌠ fo≥ description≤ oµ pseudo-ops¼ erro≥ message≤ ì
- anΣ thσ like.
-
- Iε general¼ thσ assembl∙ languagσ useΣ iε ASM6╡ follow≤ standarΣ ì
- MO╙ Technolog∙ syntax¼ bu⌠ therσ arσ somσ deviation≤ froφ thσ ì
- standarΣ (enforceΣ b∙ usinτ a≤ corσ aε assemble≥ designeΣ fo≥ thσ ì
- 8080/Z8░ processo≥ family⌐ whicΦ ma∙ affec⌠ portabilit∙ oµ ì
- program≤ t∩ standarΣ 650▓ assemblers« Thσ maiε difference≤ arσ iε ì
- thσ specificatioε oµ numeriπ value≤ (in suffixe≤ rathe≥ thaε ì
- prefixe≤ arσ useΣ t∩ distinguisΦ numbe≥ bases)╗ iε pseudo-o≡ ì
- names¼ whicΦ arσ standarΣ AS═ syntax; anΣ iε thσ descriptioε oµ ì
- indirec⌠ addressinτ modes« Bracket≤ arσ useΣ t∩ enclosσ ì
- arithmetiπ expression≤ iε AS═ syntax¼ witΦ thσ resul⌠ tha⌠ ì
- indirec⌠ addressinτ mode≤ canno⌠ bσ specifieΣ b∙ enclosinτ thσ ì
- operanΣ iε bracket≤ a≤ pe≥ MO╙ Technolog∙ synta° -- onσ non-ì
- standarΣ opcodσ (JMPI⌐ anΣ slightl∙ differen⌠ registe≥ mnemonic≤ ì
- (IX¼ I┘ anΣ I⌐ arσ useΣ instead.
-
- Preparing source files
- ----------------------
- Prograφ creatioε witΦ ASM6╡ i≤ ß three-stagσ process: editinτ thσ ì
- sourcσ filσ witΦ ß suitablσ edito≥ o≥ word-processor╗ usinτ ASM6╡ ì
- t∩ creatσ ß he° file╗ anΣ creatinτ ß binar∙ filσ froφ thσ he° ì
- filσ witΦ LOA─ o≥ CODE¼ o≥ sendinτ i⌠ direc⌠ t∩ thσ externa∞ ì
- 6502-baseΣ system« Thi≤ par⌠ oµ thσ note≤ i≤ concerneΣ onl∙ witΦ ì
- the first stage, that of source-file creation.
-
- Program≤ caε bσ createΣ usinτ an∙ suitablσ CP/═ edito≥ o≥ word-ì
- processo≥ (wσ mainl∙ usσ WordStar¼ whicΦ allow≤ u≤ sourcσ file≤ ì
- oµ an∙ length)« Filename≤ MUST usσ thσ extensioε .A6╡ (e.g« ì
- PROGRAM.A65)¼ otherwisσ ASM6╡ wil∞ no⌠ finΣ thσ filσ -- thσ erro≥ ì
- message 'No source file present' will be printed in this case.
-
- As usual, assembly language statements take the form of:
-
- <label:> opcode <operand> <;comment>
-
- -- eacΦ linσ ends¼ oµ course¼ witΦ carriage-returε o≥ thσ CR/L╞ ì
- combination.è
- Linσ number≤ shoulΣ no⌠ bσ useΣ (thougΦ seσ thσ AS═ manua∞ fo≥ ì
- more detail if you REALLY want to use line numbers).
-
- Labels
- ------
- Label≤ ma∙ bσ oµ an∙ length¼ althougΦ onl∙ 1╢ character≤ arσ ì
- significant« The∙ ma∙ bσ writteε a≤ eithe≥ uppe≥ o≥ lowe≥ casσ ì
- letter≤ (lower-casσ letter≤ arσ converteΣ t∩ cap≤ automaticall∙ ì
- durinτ assembly⌐ anΣ numeral≤ (althougΦ thσ firs⌠ characte≥ oµ ß ì
- labe∞ mus⌠ bσ ß letter« Thσ ':º i≤ optional« Wherσ ß labe∞ refer≤ ì
- t∩ aε assignmen⌠ (EQ╒ o≥ SET⌐ i⌠ mus⌠ bσ oε thσ samσ line╗ ì
- otherwise¼ wherσ i⌠ refer≤ t∩ codσ (opcode≤ o≥ code-creatinτ ì
- pseudo-op≤ sucΦ a≤ DB⌐ i⌠ doe≤ no⌠ neeΣ t∩ bσ oε thσ samσ line¼ ì
- s∩ tha⌠ multiplσ label≤ ma∙ refe≥ t∩ thσ samσ codσ location« Seσ ì
- the ASM manual for more detail.
-
- Multiple expressions
- --------------------
- Opcode≤ anΣ operand≤ arσ describeΣ iε detai∞ below¼ anΣ wil∞ no⌠ ì
- bσ discusseΣ here« Note¼ however¼ tha⌠ severa∞ opcode/operanΣ ì
- expression≤ ma∙ bσ placeΣ oε thσ samσ line if separated by '!':
-
- PHA ! TXA ! PHA ! TYA ! PHA ;save registers
-
- -- onσ side-effec⌠ i≤ tha⌠ '!º ma∙ no⌠ bσ useΣ iε comments¼ ì
- otherwisσ ASM6╡ interpret≤ thσ followinτ tex⌠ a≤ sourcσ ì
- statements, with unpredictable results.
-
- Comments
- --------
- ┴ commen⌠ i≤ precedeΣ b∙ ';'¼ anΣ run≤ t∩ thσ enΣ oµ thσ linσ ì
- (witΦ thσ exceptioε oµ '!º a≤ describeΣ above)« Therσ i≤ n∩ ì
- provisioε fo≥ multiple-linσ comment≤ -- eacΦ linσ oµ commen⌠ mus⌠ ì
- bσ precedeΣ b∙ ';º -- althougΦ comment≤ ma∙ star⌠ a⌠ an∙ positioε ì
- in the line.
-
- EacΦ par⌠ oµ thσ statemen⌠ mus⌠ bσ separateΣ b∙ a⌠ leas⌠ onσ ì
- spacσ o≥ tab« Apar⌠ froφ this¼ space≤ anΣ tab≤ arσ no⌠ ì
- significant¼ anΣ ma∙ bσ useΣ iε an∙ wa∙ t∩ increasσ thσ ì
- readability of the file.
-
- Opcodes
- -------
- ASM6╡ support≤ al∞ standarΣ MO╙ Technolog∙ anΣ GT┼ (65C02⌐ opcodσ ì
- mnemonics¼ witΦ onσ exception║ JMP╔ i≤ useΣ iε placσ oµ JM╨ (..⌐ ì
- fo≥ jump-indirect« WitΦ tha⌠ exception¼ al∞ opcodσ mnemonic≤ arσ ì
- three-letter╗ thσ four-lette≥ mnemonic≤ ASLA¼ ROLA¼ LSRA¼ ROR┴ ì
- (anΣ INCA¼ DEC┴ -- 65C0▓ only⌐ ma∙ als∩ bσ useΣ t∩ describeΣ ì
- accumulator operations.
-
- Thσ opcodσ lis⌠ belo≈ show≤ al∞ oµ thσ opcode≤ availablσ witΦ ì
- ASM65¼ includinτ 65C0▓ extensions« Thσ addressinτ mode≤ availablσ ì
- fo≥ eacΦ instructioε arσ showε iε brackets¼ witΦ mode≤ availablσ ì
- onl∙ oε thσ 65C0▓ indicateΣ b∙ aε asterisk« Thσ mode≤ arσ ì
- repesented by:
- (none) implicit operation
- A accumulator only
- # immediate (8-bit value)è Z zero page (8-bit address)
- Abs absolute (16-bit address)
- Rel relative (8-bit signed branch)
- Z,X zero page + X register
- Z,Y zero-page + Y register
- Abs,X absolute + X register
- Abs,Y absolute + Y register
- IX indirect from (zpage + X register)
- IY indirect from zpage, + Y register
- I indirec⌠ froφ zpagσ (samσ a≤ I┘ witΦ Y=0⌐ (65C0▓ ì
- áááááááááááááááonly)
-
- Implicit operations
- -------------------
- PHA, PLA push/pull accumulator
- PHP, PLP push/pull processor status flags
- PHX, PLX push/pull X register (65C02 only)
- PHY, PLY push/pull Y register (65C02 only)
- TSX move stack pointer to X register
- TXS set stack pointer from X register
- TAX, TAY load X, Y register from A
- TXA, TYA load A from X, Y register
- SEC, SED, SEI set carry, decimal, interrupt flags
- CLC, CLD clear carry, decimal flags
- CLI, CLV clear interrupt, overflow flags
- RTS, RTI return from subroutine, interrupt
- BRK break (software interrupt)
- NOP no-operation
-
- Call, Jump and Branch
- ---------------------
- JSR call subroutine (Abs)
- JMP jump to new location (Abs)
- JMPI jum≡ indirec⌠ viß specifieΣ locatioε (Abs╗ ì
- ááááááááááááááááááááAbs,X*)
- BPL, BMI branch if sign clear/set (Rel)
- BNE, BEQ branch if zero flag clear/set (Rel)
- BCC, BCS branch if carry clear/set (Rel)
- BVC, BVS branch if overflow flag clear/set (Rel)
- BRA unconditional branch (Rel*)
-
- Test/Set/Reset memory
- ---------------------
- BIT test memory bits (Z; Abs; Z,X*; Abs,X*; #*)
- TRB tes⌠ anΣ rese⌠ memor∙ agains⌠ accumulato≥ ì
- áááááááááááááááááááá(Z*╗ Abs*)
- TSB tes⌠ anΣ se⌠ memor∙ agains⌠ accumulato≥ (Z*╗ ì
- ááááááááááááááááááááAbs*)
-
- Rotate and Shift
- ----------------
- ASL shift left (Z; Abs; Z,X; Abs,X; A)
- ASLA shift A left (same as ASL A)
- LSR shift right (Z; Abs; Z,X; Abs,X; A)
- LSRA shift A left (same as LSR A)
- ROL rotatσ lef⌠ -- 9-bi⌠ rotatσ througΦ carr∙ (Z╗ ì
- ááááááááááááááááááááAbs╗ Z,X╗ Abs,X╗ A)
- ROLA rotate A left (same as ROL A)
- ROR rotatσ righ⌠ -- 9-bi⌠ rotatσ througΦ carr∙ ìèáááááááááááááááááááá(Z╗ Abs╗ Z,X╗ Abs,X╗ A)
- RORA rotate A right (same as ROR A)
-
- Decrement and Increment
- -----------------------
- DEC decrement (Z; Abs; Z,X; Abs,X; A*)
- DECA decrement A (same as DEC A*)
- INC increment (Z; Abs; Z,X; Abs,X; A*)
- INCA increment A (same as INC A*)
- DEX, INX decrement/increment X
- DEY, INY decrement/increment Y
-
- Accumulator operations
- ----------------------
- ORA inclusivσ O╥ witΦ accumulato≥ (#╗ Z╗ Abs╗ ì
- ááááááááááááááááááááZ,X╗ Abs,X╗ Abs,Y╗ IX╗ IY╗ I*)
- AND binar∙ AN─ witΦ accumulato≥ (#╗ Z╗ Abs╗ Z,X╗ ì
- ááááááááááááááááááááAbs,X╗ Abs,Y╗ IX╗ IY╗ I*)
- EOR exclusivσ O╥ witΦ accumulato≥ (#╗ Z╗ Abs╗ ì
- ááááááááááááááááááááZ,X╗ Abs,X╗ Abs,Y╗ IX╗ IY╗ I*)
- ADC adΣ witΦ carr∙ t∩ accumulato≥ (#╗ Z╗ Abs╗ ì
- ááááááááááááááááááááZ,X╗ Abs,X╗ Abs,Y╗ IX╗ IY╗ I*)
- SBC subtrac⌠ witΦ borro≈ froφ accumulato≥ (#╗ Z╗ ì
- ááááááááááááááááááááAbs╗ Z,X╗ Abs,X╗ Abs,Y╗ IX╗ IY╗ I*)
-
- Load and Store
- --------------
- LDA loaΣ ┴ registe≥ (#╗ Z╗ Abs╗ Z,X╗ Abs,X╗ ì
- ááááááááááááááááááááAbs,Y╗ IX╗ IY╗ I*)
- STA storσ ┴ registe≥ (Z╗ Abs╗ Z,X╗ Abs,X╗ Abs,Y╗ ì
- ááááááááááááááááááááIX╗ IY╗ I*)
- LDX load X register (#; Z; Abs; Z,Y; Abs,Y)
- STX store X register (Z; Abs; Z,Y)
- LDY load Y register (#; Z; Abs; Z,X; Abs,X)
- STY store Y register (Z; Abs; Z,X)
-
- Compare registers
- -----------------
- CMP comparσ accumulato≥ (#╗ Z╗ Abs╗ Z,X╗ Abs,X╗ ì
- ááááááááááááááááááááAbs,Y╗ IX╗ IY╗ I*)
- CPX compare X (#; Z; Abs)
- CPY compare Y (#; Z; Abs)
-
- Addressing modes
- ----------------
- (none) implicit operation
- A accumulator only
- áááááááááááááááUseΣ wherσ accumulato≥ i≤ thσ operand¼ e.g« AS╠ A« ì
- áááááááááááááááAl∞ ┴ addressinτ option≤ havσ ß 4-lette≥ matchinτ ì
- áááááááááááááááopcode -- i.e. ASLA and ASL A are identical.
- # immediate (8-bit value)
- áááááááááááááááNex⌠ bytσ i≤ thσ operand« Example≤ arσ LD┴ #20¼ ì
- áááááááááááááááLD╪ #20h¼ CP╪ #'i'« Aε erro≥ i≤ generateΣ iµ thσ ì
- áááááááááááááááoperand evaluates to greater than 0FFh.
- Z zero page (8-bit address)
- áááááááááááááááNex⌠ bytσ i≤ thσ low-orde≥ addres≤ oµ thσ operand« ì
- áááááááááááááááSelecteΣ automaticall∙ iµ thσ operanΣ evaluate≤ t∩ ì
- áááááááááááááááles≤ thaε 100h« Example≤ arσ LD┴ 20¼ ST╪ 20h¼ anΣ ì
- áááááááááááááááORA <address> where <address> is less than 100h.
- áááááááááááááááAl∞ zero-pagσ addresse≤ mus⌠ bσ knowε oε thσ firs⌠ ìèááááááááááááááápass¼ withou⌠ forwarΣ references¼ otherwisσ phasσ ì
- áááááááááááááááerror≤ (seσ AS═ manual⌐ ma∙ occu≥ durinτ thσ ì
- ááááááááááááááásecond pass of the assembler.
- Abs absolute (16-bit address)
- áááááááááááááááNex⌠ bytσ i≤ thσ low-orde≥ addres≤ oµ thσ operand╗ ì
- áááááááááááááááfollowinτ bytσ i≤ thσ high-orde≥ address« SelecteΣ ì
- áááááááááááááááautomaticall∙ iµ thσ operanΣ evaluate≤ t∩ greate≥ ì
- áááááááááááááááthaε 0FFh¼ o≥ iµ zero-pagσ modσ i≤ no⌠ available« ì
- áááááááááááááááExample≤ arσ LD┴ 2000¼ ST╪ 200h¼ anΣ OR┴ <address> ì
- áááááááááááááááwhere <address> is greater than 0FFh.
- Rel relative (8-bit signed branch)
- áááááááááááááááNex⌠ bytσ i≤ thσ offse⌠ t∩ ß labe∞ relativσ t∩ thσ ì
- ááááááááááááááástar⌠ oµ thσ NEXT instructioε (i.e« tw∩ byte≤ ì
- áááááááááááááááafte≥ thσ locatioε oµ thσ brancΦ test)¼ givinτ aε ì
- áááááááááááááááeffectivσ rangσ oµ -12╢ t∩ +12╣ froφ thσ locatioε ì
- áááááááááááááááoµ thσ brancΦ instruction« Iµ thσ operanΣ ì
- áááááááááááááááevaluate≤ outsidσ thi≤ range¼ aε erro≥ wil∞ bσ ì
- ááááááááááááááágenerated« Example≤ arσ BR┴ label¼ BN┼ $-│ ('$º i≤ ì
- áááááááááááááááthe reserved name of the position counter).
- Z,X zero page + X register
- áááááááááááááááA≤ fo≥ ┌ above¼ excep⌠ thσ content≤ oµ thσ ╪ ì
- áááááááááááááááregiste≥ arσ addeΣ t∩ givσ aε offse⌠ withiε thσ ì
- ááááááááááááááázero-page« Addresse≤ 'wra≡ roundº WITHIN zero-ì
- ááááááááááááááápage. Example: AND address,X
- Z,Y zero-page + Y register
- áááááááááááááááA≤ fo≥ Z,╪ above¼ excep⌠ tha⌠ thσ ┘ registe≥ i≤ ì
- áááááááááááááááused. Example: STX 20h,Y
- Abs,X absolute + X register
- áááááááááááááááA≤ fo≥ Ab≤ above¼ excep⌠ tha⌠ thσ content≤ oµ thσ ì
- ááááááááááááááá╪ registe≥ arσ addeΣ t∩ givσ aε offse⌠ froφ thσ ì
- áááááááááááááááfollowinτ two-bytσ address« Addresse≤ d∩ no⌠ 'wra≡ ì
- ááááááááááááááároundº withiε thσ curren⌠ pagσ -- wherσ thσ suφ oµ ì
- áááááááááááááááthσ low-orde≥ addres≤ anΣ thσ ╪ registe≥ content≤ ì
- áááááááááááááááexceed≤ 0FFh¼ thσ high-orde≥ addres≤ i≤ ì
- áááááááááááááááincremented. Example: SBC 2000h,X
- Abs,Y absolute + Y register
- áááááááááááááááA≤ fo≥ Abs,╪ above¼ excep⌠ tha⌠ thσ ┘ registe≥ i≤ ì
- áááááááááááááááused« Example║ AD├ address,┘ (wherσ addres≤ i≤ ì
- ááááááááááááááágreater than 0FFh).
- IX indirect from (zpage + X register)
- áááááááááááááááThσ followinτ bytσ i≤ thσ lo≈ orde≥ addres≤ withiε ì
- ááááááááááááááázero-pagσ t∩ whicΦ thσ ╪ registe≥ i≤ addeΣ ì
- ááááááááááááááá('wrappinτ roundº iµ necessary)« Thσ effectivσ ì
- áááááááááááááááoperanΣ i≤ thσ addres≤ pointeΣ t∩ by thσ content≤ ì
- áááááááááááááááoµ thσ effectivσ addres≤ generated« Iµ thσ basσ ì
- áááááááááááááááaddres≤ doe≤ no⌠ evaluatσ t∩ aε 8-bi⌠ addres≤ ì
- ááááááááááááááá(i.e« thσ high-orde≥ bytσ i≤ greate≥ thaε zero⌐ ì
- áááááááááááááááan error is generated. Example: LDA base,IX
- IY indirect from zpage, + Y register
- áááááááááááááááSimila≥ t∩ IX¼ excep⌠ tha⌠ thσ content≤ oµ thσ ┘ ì
- áááááááááááááááregiste≥ arσ addeΣ AFTER thσ indirectioε -- thσ ì
- ááááááááááááááácontent≤ oµ thσ ┘ registe≥ arσ addeΣ t∩ thσ ì
- ááááááááááááááácontent≤ oµ thσ tw∩ byte≤ a⌠ 'addressº (withiε ì
- ááááááááááááááázero-page⌐ t∩ creatσ thσ effectivσ address« Iµ thσ ì
- ááááááááááááááábasσ addres≤ doe≤ no⌠ evaluatσ t∩ aε 8-bi⌠ addres≤ ìèáááááááááááááááan error is generated. Example: CMP 20h,IY
- I indirec⌠ froφ zpagσ
- áááááááááááááááThσ effectivσ addres≤ i≤ thσ content≤ oµ thσ tw∩ ì
- ááááááááááááááábyte≤ startinτ a⌠ thσ followinτ addres≤ iε zero-ì
- ááááááááááááááápage« Thi≤ i≤ identica∞ t∩ I┘ iε case≤ wherσ thσ ┘ ì
- áááááááááááááááregister is zero. Example: AND flag,I
-
- Tw∩ othe≥ addressinτ mode≤ arσ available¼ bu⌠ onl∙ witΦ thσ JM╨ ì
- instruction║ absolutσ indirect¼ anΣ absolutσ indexeΣ indirect« ì
- Thesσ arσ availablσ a≤ JMP╔ Ab≤ anΣ JMP╔ Abs,╪ respectively╗ thσ ì
- JMP instruction has only the Abs addressing mode.
-
- Numeric values
- --------------
- (Note║ Thi≤ i≤ NOT thσ samσ a≤ MO╙ Technolog∙ syntax)« Fou≥ ì
- numbe≥ base≤ arσ recognised║ binary¼ octal¼ decima∞ anΣ ì
- hexadecimal« Thesσ arσ representeΣ b∙ thσ followinτ suffixes:
-
- B binary -- 011011b
- O or Q octal -- 377q
- D decimal (defaults to decimal) -- 100, 100d
- H hexadecimal -- 20h, 0FFh
-
- Al∞ numeriπ value≤ MUST star⌠ witΦ ß numbe≥ -- he° value≤ abovσ ì
- 9Fh must be prefixed by 0.
-
- Numeriπ value≤ arσ treateΣ a≤ 16-bi⌠ unsigneΣ numbers╗ thσ ì
- addressinτ modσ useΣ check≤ tha⌠ thσ numbe≥ i≤ withiε it≤ ì
- required range.
-
- Arithmetic expressions
- ----------------------
- Operand≤ ma∙ includσ arithmetiπ expression≤ oµ considerablσ ì
- complexity« Thσ followinτ i≤ ß lis⌠ oµ thσ function≤ anΣ ì
- operator≤ tha⌠ ma∙ bσ useΣ withiε arithmetiπ expressions«
-
- * times
- + plus
- - minus
- / divide
- MOD remainder from divide
- & binary AND (note -- not 'AND', which is a 6502 opcode)
- OR binary inclusive-OR
- XOR binary exclusive-OR
- NOT binary negate
- SHL binary shift-left
- SHR binary shift-right
-
- Al∞ arithmetiπ operation≤ ac⌠ oε thσ curren⌠ valuσ a≤ ß 16-bi⌠ ì
- unsigneΣ number« Bracket≤ -- ¿ ⌐ -- enclosσ thesσ expression≤ anΣ ì
- ma∙ bσ nesteΣ u≡ t∩ si° deep╗ bracket≤ caε als∩ bσ useΣ t∩ forcσ ì
- thσ orde≥ oµ evaluatioε oµ aε expression« Seσ thσ AS═ manua∞ fo≥ ì
- morσ details.
-
- Literal expressions
- -------------------
- Tex⌠ (o≥ individua∞ letters⌐ ma∙ bσ includeΣ iε operand≤ b∙ ì
- enclosinτ it in single quotes, e.g.:è
- CMP #'T'
- db 'text'
-
- Wherσ single-quote≤ character≤ arσ t∩ bσ included¼ the∙ mus⌠ bσ ì
- repeated:
-
- db 'it''s a little confusing'
- CMP #'''' ;is A single-quote?
-
- For more details, see the ASM manual.
-
- Pseudo-operations
- -----------------
- Pseudo-op≤ fal∞ int∩ fivσ groups║ defininτ o≥ reservinτ space¼ ì
- defininτ constant≤ o≥ variables¼ defininτ thσ locatioε counter¼ ì
- delimitinτ area≤ fo≥ conditiona∞ assembly¼ anΣ (a≤ ye⌠ ì
- unimplemented⌐ expansioε instructions« Onl∙ ß brieµ summar∙ i≤ ì
- given here: for more detail refer to the ASM manual.
-
- Defining space
- --------------
- DB definσ bytσ (equivalen⌠ oµ .BYT┼ iε MO╙ Technolog∙ syntax)« ì
- áááááReservσ bytσ orienteΣ spacσ anΣ it≤ contents¼ sucΦ a≤ ì
- áááááconstants, variables or embedded text.
- áááááExamples:
- ááááá db 0,0,0,0,22,105,0
- ááááá db 'text',0
- áááááIµ an∙ valuσ evaluate≤ t∩ greate≥ thaε 0FFh¼ aε erro≥ wil∞ ì
- ááááábe generated.
- DWááádefinσ worΣ (equivalen⌠ oµ .WOR─ iε MO╙ Technolog∙ syntax)« ì
- áááááReservσ word-orienteΣ spacσ anΣ it≤ contents¼ witΦ thσ ì
- ááááácontent≤ storeΣ iε lo-hΘ order╗ typicall∙ useΣ t∩ definσ ì
- áááááaddress tables.
- áááááExample:
- ááááá dw word1,word2,0,0FFFFh
- DSááádefinσ reserveΣ areß witΦ undefineΣ contents╗ typicall∙ useΣ ì
- áááááto define scratchpad areas.
- áááááExample:
- ááááá ds 255
-
- Defining constants or variables
- -------------------------------
- EQU assigε ß constan⌠ valuσ t∩ 'labelº (equivalen⌠ oµ '=º iε MO╙ ì
- áááááTechnolog∙ syntax)« Thσ labe∞ mus⌠ bσ iε thσ samσ line« ì
- áááááValue≤ arσ considereΣ t∩ bσ 16-bi⌠ unsigneΣ numbers¼ anΣ ma∙ ì
- ááááábσ addresses¼ characte≥ constants¼ o≥ 16- o≥ 8-bi⌠ value≤ oµ ì
- áááááan∙ kind« Iµ ß constan⌠ i≤ defineΣ morσ thaε oncσ usinτ EQU¼ ì
- áááááaε erro≥ wil∞ bσ generated.
- Example:
- ááááá eof EQU 1ah
- SETááassigε ß variablσ valuσ t∩ 'label'« Thσ samσ a≤ EQU¼ excep⌠ ì
- ááááátha⌠ n∩ erro≥ wil∞ bσ generateΣ iµ i⌠ i≤ redefined« ì
- áááááTypicall∙ useΣ t∩ specif∙ variable≤ t∩ contro∞ o≥ fo≥ usσ iε ì
- áááááconditional assembly.
- áááááExample:
- ááááá flag SET 1
- èDefining the location counter
- -----------------------------
- ORGááDefine≤ thσ curren⌠ locatioε counte≥ froφ whicΦ addresse≤ ì
- áááááwil∞ bσ calculateΣ (samσ a≤ '*=º iε MO╙ Technolog∙ syntax)« ì
- áááááMa∙ bσ defineΣ o≥ redefineΣ a⌠ an∙ timσ -- shoulΣ onl∙ bσ ì
- ááááádefineΣ t∩ ß highe≥ address¼ a≤ redefinition≤ t∩ lowe≥ ì
- áááááaddresse≤ thaε thσ curren⌠ addres≤ ma∙ causσ problem≤ a⌠ ì
- áááááfina∞ assembly.
- áááááExample:
- ááááá org 0f000h
- ENDááDefine≤ thσ enΣ oµ thσ prograφ a≤ fa≥ a≤ assembl∙ i≤ ì
- áááááconcerned. Optional.
-
- Conditional assembly
- --------------------
- IFáááStar⌠ oµ sectioε whicΦ wil∞ bσ assembleΣ onl∙ iµ thσ ì
- áááááfollowinτ conditioε i≤ truσ (non-zero)« Onl∙ onσ leve∞ oµ ì
- áááááconditional assembly is available.
- áááááExample:
- ááááá testversion equ 1
- ááááá IF testversion
- ááááá jsr printstatus
- ááááá ENDIF
- ááááá IF not testversion
- ááááá jsr clrstatus
- ááááá ENDIF
- ááááá jmp mainloop
- ENDIF
- áááááEnd≤ ß sectioε oµ conditiona∞ assembly« ┴ missinτ o≥ ì
- áááááunmatched ENDIF will cause an error to be generated.
-
- Unimplemented instructions
- --------------------------
- Thσ followinτ instruction≤ arσ treateΣ a≤ reserveΣ words¼ bu⌠ ì
- arσ no⌠ ye⌠ implementeΣ -- thei≥ usσ wil∞ causσ aε erro≥ t∩ bσ ì
- generated:
- MACRO
- ENDM
- TITLE
-
- Error messages
- --------------
- Assembl∙ erro≥ message≤ arσ rudimentary¼ consistinτ oµ ß singlσ ì
- lette≥ iε thσ firs⌠ columε oµ thσ listinτ (.PRN⌐ filσ anΣ thσ ì
- displa∙ oε thσ consolσ oµ thσ relevan⌠ line« Wherσ severa∞ error≤ ì
- occu≥ withiε thσ samσ line¼ onl∙ thσ lette≥ oµ thσ firs⌠ erro≥ ì
- wil∞ bσ shown« Iε general¼ thσ causσ oµ aε erro≥ wil∞ bσ a≤ ì
- describeΣ iε thσ lis⌠ iε thσ AS═ manual╗ aε exceptioε i≤ tha⌠ al∞ ì
- illega∞ addressinτ mode≤ arσ treateΣ a≤ 'Rº (register⌐ errors¼ ì
- fo≥ whicΦ threσ NOP≤ ('EAEAEA'⌐ wil∞ bσ generateΣ a≤ code«
-
- A≤ witΦ ASM¼ assembl∙ continue≤ afte≥ al∞ errors¼ sometime≤ ì
- causinτ othe≥ error≤ late≥ durinτ assembl∙ a≤ ß 'knock-onº ì
- effect.
-
-
-
- èUsing ASM65
- -----------
- Wσ assumσ tha⌠ yo⌡ havσ createΣ you≥ prograφ oε ß sourcσ filσ ì
- calleΣ 'filename.A65'« (Notσ tha⌠ thσ filσ mus⌠ usσ thσ extensioε ì
- '.A65')« ASM6╡ caε creatσ u≡ t∩ tw∩ additiona∞ file≤ froφ thσ ì
- sourcσ file║ ß '.HEXº file¼ containinτ machinσ codσ iε Inte∞ he° ì
- format¼ and/o≥ ß '.PRNº listinτ file╗ i⌠ caε als∩ lis⌠ t∩ thσ ì
- console« Iε al∞ case≤ sourcσ line≤ witΦ error≤ wil∞ bσ listeΣ t∩ ì
- thσ screeε and¼ iµ thσ printe≥ i≤ enabled¼ t∩ thσ printe≥ a≤ ì
- well.
-
- Typical examples of assemblies are:
-
- B>a:asm65 filename
-
- whicΦ assume≤ ß sourcσ filσ filename.A6╡ oε thσ B║ drive¼ anΣ ì
- creates files filename.HEX and filename.PRN on the same drive.
-
- B>a:asm65 filename.bbz
-
- which does the same, except that no .PRN file will be created.
-
- B>a:asm65 filename.bzx
-
- whicΦ read≤ thσ sourcσ filσ oε B:¼ doe≤ no⌠ creatσ ß .HE╪ file¼ ì
- anΣ send≤ thσ listinτ onl∙ t∩ thσ screeε withou⌠ creatinτ ß .PR╬ ì
- file.
-
- Notσ tha⌠ ß .PR╬ filσ ma∙ wel∞ bσ twicσ thσ sizσ oµ you≥ origina∞ ì
- sourcσ file║ makσ surσ tha⌠ yo⌡ havσ enougΦ disδ spacσ beforσ ì
- allowing the assembler to create it!
-
- Fo≥ ful∞ detail≤ oε thσ actua∞ assembl∙ proces≤ anΣ it≤ erro≥ ì
- messages, refer to the ASM manual.
-
-
- Creating executable code
- ------------------------
- ASM6╡ doe≤ no⌠ b∙ itselµ creatσ executablσ codσ -- i⌠ create≤ ß ì
- '.HEXº filσ containinτ it≤ machinσ codσ a≤ loaΣ address¼ he° ì
- value≤ anΣ checksuφ iε thσ Inte∞ he° format« Thi≤ mus⌠ bσ ì
- converted to executable code by a separate loader.
-
- Digita∞ Research'≤ LOA─ prograφ doe≤ thi≤ fo≥ 8080/Z8░ programs¼ ì
- anΣ wil∞ als∩ bσ suitablσ fo≥ non-ROMablσ 650▓ code« Thσ catcΦ ì
- witΦ LOA─ i≤ tha⌠ i⌠ alway≤ create≤ ß filσ assuminτ ß loaΣ ì
- addres≤ oµ 100h¼ wherea≤ ROMablσ 650▓ codσ wil∞ tenΣ t∩ residσ ì
- mucΦ highe≥ iε memory╗ LOA─ thereforσ tend≤ t∩ creatσ aε oversizσ ì
- filσ consistinτ mainl∙ oµ garbage¼ witΦ thσ actua∞ codσ u≡ a⌠ thσ top« ì
- Thσ solutioε iε thesσ case≤ i≤ t∩ pas≤ thσ he° filσ t∩ aε externa∞ 650▓ ì
- systeφ fo≥ processinτ it¼ o≥ usσ thσ modifieΣ loader¼ CODE.CO═ (oε ì
- thi≤ disk)¼ whicΦ automaticall∙ generate≤ aε offse⌠ t∩ storσ ROMablσ ì
- codσ iε thσ minimuφ sizσ file« PROMLOA─ o≥ somσ othe≥ file-reade≥ caε ì
- theε transfe≥ thσ codσ t∩ aε externa∞ systeφ o≥ PRO═ programmer.