|
| 1 | + |
| 2 | +Things to consider when moving an existing code to tpasm: |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +1. |
| 8 | + |
| 9 | +Change '$SEGMENTED' to 'SEGMENTED' and '$ASSUME' to 'ASSUME'. |
| 10 | +Add 'INCLUDE "REG_cputype.INC"' and all other header files needed. |
| 11 | +Also remove any dollarsigns /$/ that are placed inside numbers. |
| 12 | + |
| 13 | +If you get a lot of errors complaining about illegal addressing |
| 14 | +modes make sure that 'SEGMENTED' is followed by the needed |
| 15 | +'ASSUME'-s. A good start may be |
| 16 | + |
| 17 | + ASSUME DPP0:0x0000 |
| 18 | + ASSUME DPP1:0x4000 |
| 19 | + ASSUME DPP2:0x8000 |
| 20 | + ASSUME DPP3:0xC000 |
| 21 | + |
| 22 | +This is the same as the default after a hardware reset. It |
| 23 | +corresponds to a real initialisation of |
| 24 | + |
| 25 | + MOV DPP0,#0h |
| 26 | + MOV DPP1,#1h |
| 27 | + MOV DPP2,#2h |
| 28 | + MOV DPP3,#3h |
| 29 | + |
| 30 | + |
| 31 | +2. |
| 32 | + |
| 33 | +Try to sort out how 'DGROUP' and 'CGROUP' are used (if present). |
| 34 | +You may leave them in place as they are ignored but take whatever |
| 35 | +countermeasures that may be necessary. |
| 36 | + |
| 37 | + |
| 38 | +3. |
| 39 | + |
| 40 | +Change |
| 41 | + |
| 42 | +named SECTION DATA |
| 43 | +to |
| 44 | + SEG named |
| 45 | +named |
| 46 | + |
| 47 | +and |
| 48 | + |
| 49 | +namec SECTION CODE |
| 50 | +to |
| 51 | + SEG namec |
| 52 | +namec |
| 53 | + |
| 54 | +This makes it possible to use 'namec' and 'named' in 'ASSIGN DPPn:named'. |
| 55 | + |
| 56 | +Note that the start of a segment is normally done through an |
| 57 | + |
| 58 | + ORG startofsomething |
| 59 | + |
| 60 | +and that is only done in one place. The above examples will become |
| 61 | + |
| 62 | + SEG named |
| 63 | +named ORG RAM |
| 64 | + |
| 65 | +and |
| 66 | + |
| 67 | + SEG namec |
| 68 | +mamec ORG FLASH |
| 69 | + |
| 70 | +tpasm has a predefined segment called 'code' ment for placing code in. |
| 71 | + |
| 72 | +Lines looking like |
| 73 | + |
| 74 | +label PROC xxx yyy .. |
| 75 | + |
| 76 | +can be left in place but 'label' will be ignored |
| 77 | + |
| 78 | +'PUBLIC', 'GLOBAL', 'NAME', REGDEF' 'ENDP' and 'SSKDEF' are also ignored |
| 79 | +by tpasm. They are (among other things) there to help the assembler to |
| 80 | +look after you as if you don't know what you are doing :-) |
| 81 | + |
| 82 | + |
| 83 | +Comment out or remove all 'ENDS'-s as they are in conflict with tpasms own |
| 84 | +'ends' that closes a switch directive. |
| 85 | + |
| 86 | + |
| 87 | +4. |
| 88 | + |
| 89 | +Remove all "types" appended to same variables. That is 'variable:type' |
| 90 | +becomes just 'variable'. Consider the effect of doing so. It may affect |
| 91 | +the memory used. Also check if 'JMP' and 'CALL' are used. They must be |
| 92 | +replaced by 'JMPA'/'JMPR' and 'CALLA'/'CALLR' respectively. tpasm does |
| 93 | +not (yet) decide for you! |
| 94 | + |
| 95 | + |
| 96 | +5. |
| 97 | + |
| 98 | +Change string delimiters in 'DB' statements from single quotes /'/ to |
| 99 | +double quotes /"/. See the file MANUAL.TXT for a complete description |
| 100 | +of the formats used. |
| 101 | + |
| 102 | + |
| 103 | +6. |
| 104 | + |
| 105 | +Make sure that there is no label called 'SYSTEM' or 'NOTHING'. These |
| 106 | +words are reserved and defined in 'REG_cputype.INC' . |
| 107 | + |
| 108 | + |
| 109 | +7. |
| 110 | + |
| 111 | +Make sure that in all places where a DPPn *register* ( not a prefix ) |
| 112 | +is to be loaded with a page number the name of the page is prefixed |
| 113 | +by '#PAG'. ( Else the register will be loaded with the segment offset! ) |
| 114 | + |
| 115 | +'ASSUME' operands are always taken as memory addresses and the 'PAG' |
| 116 | +operator is implied and must not be used. |
| 117 | +If you want to give a real page number use the form |
| 118 | + |
| 119 | + ASSUME DPPn: value<<14 |
| 120 | + |
| 121 | +8. |
| 122 | + |
| 123 | +Verify that all 'EXTRN' and 'EXTERNAL' references make sense when all |
| 124 | +modules are assembled together via 'INCLUDE's. Remove all 'EXTRN' and |
| 125 | +'EXTERNAL' if you like. They are ignored by tpasm. |
| 126 | + |
| 127 | + |
| 128 | +9. |
| 129 | + |
| 130 | +Consider changing 'LIT' to 'EQU' everywhere a label that may be used in |
| 131 | +an 'ASSUME', 'ORG' or other directive is defined. This may be a major |
| 132 | +problem in converting to tpasm. tpasm does not do literal substitution |
| 133 | +on anything but operands of ordinary instructions and that only once. |
| 134 | +This limits the ways of writing header files since you can't nest sub- |
| 135 | +stitutions. A typical example is the definitions of bits in registers: |
| 136 | + |
| 137 | +PSW EQU 0xFF10 ; We can't use LIT here |
| 138 | +IEN LIT PSW.11 ; if we want this to work |
| 139 | + |
| 140 | + BSET IEN ; when we come here |
| 141 | + |
| 142 | +Notice that 'LIT' is the same as 'ALIAS' to tpasm. The only difference |
| 143 | +is that 'ALIAS' takes double quotes around strings and 'LIT' expects |
| 144 | +single quotes if used at all. |
| 145 | + |
| 146 | + |
| 147 | +10. |
| 148 | + |
| 149 | +'DB' cant't take expressions containing the operators 'PAG', 'POF', 'SEG' |
| 150 | +and 'SOF'. |
| 151 | +Replace 'SEG op' with 'op>>16' and 'SOF op' with 'op&0xFFFF' |
| 152 | +Replace 'PAG op' with 'op>>14' and 'POF op' with 'op&0x3FFF' |
| 153 | + |
| 154 | +11. |
| 155 | + |
| 156 | +Take a look at how negative values are used. This differs between other |
| 157 | +assemblers! For example |
| 158 | + |
| 159 | + MOV R0,#-4 |
| 160 | + |
| 161 | +may be ok but with tpasm you will have to make it |
| 162 | + |
| 163 | + MOV R0,#( -4&0xFFFF ) |
| 164 | + |
| 165 | +since -4 is internally stored as 0xFFFFFFFC and that does not fit into |
| 166 | +sixteen bits. Values are signed 32 bit integers when evaluated but they are |
| 167 | +currently not downsized to signed values. In case of DW the value is simply |
| 168 | +'anded' with 0xFFFF. Instructions taking immediate operands accept only |
| 169 | +the range 0 - 0xFFFF. |
| 170 | + |
| 171 | + |
0 commit comments