1; 2; Test that branches work: 8- and 16-bit all insns, relaxing to 3; 32-bit, forward and backward. No need to check the border 4; cases for *all* insns. 5; 6 .text 7start_original: 8 nop 9startm32: ; start start2 start3 10 nop 11 .space 32750-(256-21*2+20)-(21*2+10*2+21*4)-12,0 12startm16: 13 nop 14 ; The size of a bunch of short branches is start2-start = 42, 15 ; so make the threshold be dependent of the size of that block, 16 ; for the next block; half of them will be relaxed. 17 .space 256-21*2-20,0 18start: 19 nop 20 ba start 21 bcc start 22 bcs start 23 beq start 24 bwf start 25 bext start 26 bext start ; leftover, used to be never-implemented "bir" 27 bge start 28 bgt start 29 bhi start 30 bhs start 31 ble start 32 blo start 33 bls start 34 blt start 35 bmi start 36 bne start 37 bpl start 38 bvc start 39 bvs start 40start2: 41 nop 42 ba startm16 43 bcc startm16 44 bcs startm16 45 beq startm16 46 bwf startm16 47 bext startm16 48 bext startm16 49 bge startm16 50 bgt startm16 51 bhi startm16 52 bhs startm16 53 ble startm16 54 blo startm16 55 bls startm16 56 blt startm16 57 bmi startm16 58 bne startm16 59 bpl startm16 60 bvc startm16 61 bvs startm16 62start3: 63; Ok, once more to make sure *all* 16-bit variants get ok for 64; backward references. 65 nop 66 ba startm16 67 bcc startm16 68 bcs startm16 69 beq startm16 70 bwf startm16 71 bext startm16 72 bext startm16 73 bge startm16 74 bgt startm16 75 bhi startm16 76 bhs startm16 77 ble startm16 78 blo startm16 79 bls startm16 80 blt startm16 81 bmi startm16 82 bne startm16 83 bpl startm16 84 bvc startm16 85 bvs startm16 86; 87; Now check that dynamically relaxing some of these branches 88; from 16-bit to 32-bit works. 89; 90start4: 91 nop 92 ba startm32 93 bcc startm32 94 bcs startm32 95 beq startm32 96 bwf startm32 97 bext startm32 98 bext startm32 99 bge startm32 100 bgt startm32 101 bhi startm32 102 bhs startm32 103 ble startm32 104 blo startm32 105 bls startm32 106 blt startm32 107 bmi startm32 108 bne startm32 109 bpl startm32 110 bvc startm32 111 bvs startm32 112; 113; Again, so all insns get to be tested for 32-bit relaxing. 114; 115start5: 116 nop 117 ba startm32 118 bcc startm32 119 bcs startm32 120 beq startm32 121 bwf startm32 122 bext startm32 123 bext startm32 124 bge startm32 125 bgt startm32 126 bhi startm32 127 bhs startm32 128 ble startm32 129 blo startm32 130 bls startm32 131 blt startm32 132 bmi startm32 133 bne startm32 134 bpl startm32 135 bvc startm32 136 bvs startm32 137; 138; Now test forward references. Symmetrically as above. 139; 140; All to 32-bit: 141start6: 142 nop 143 ba endp32 144 bcc endp32 145 bcs endp32 146 beq endp32 147 bwf endp32 148 bext endp32 149 bext endp32 150 bge endp32 151 bgt endp32 152 bhi endp32 153 bhs endp32 154 ble endp32 155 blo endp32 156 bls endp32 157 blt endp32 158 bmi endp32 159 bne endp32 160 bpl endp32 161 bvc endp32 162 bvs endp32 163; 164; Some get relaxed: 165; 166start7: 167 nop 168 ba endp32 169 bcc endp32 170 bcs endp32 171 beq endp32 172 bwf endp32 173 bext endp32 174 bext endp32 175 bge endp32 176 bgt endp32 177 bhi endp32 178 bhs endp32 179 ble endp32 180 blo endp32 181 bls endp32 182 blt endp32 183 bmi endp32 184 bne endp32 185 bpl endp32 186 bvc endp32 187 bvs endp32 188; 189; All to 16-bit: 190; 191start8: 192 nop 193 ba endp16 194 bcc endp16 195 bcs endp16 196 beq endp16 197 bwf endp16 198 bext endp16 199 bext endp16 200 bge endp16 201 bgt endp16 202 bhi endp16 203 bhs endp16 204 ble endp16 205 blo endp16 206 bls endp16 207 blt endp16 208 bmi endp16 209 bne endp16 210 bpl endp16 211 bvc endp16 212 bvs endp16 213; 214; Some relaxing: 215; 216start9: 217 nop 218 ba endp16 219 bcc endp16 220 bcs endp16 221 beq endp16 222 bwf endp16 223 bext endp16 224 bext endp16 225 bge endp16 226 bgt endp16 227 bhi endp16 228 bhs endp16 229 ble endp16 230 blo endp16 231 bls endp16 232 blt endp16 233 bmi endp16 234 bne endp16 235 bpl endp16 236 bvc endp16 237 bvs endp16 238; 239; And all the short ones, forward. 240; 241start10: 242 ba end 243 bcc end 244 bcs end 245 beq end 246 bwf end 247 bext end 248 bext end 249 bge end 250 bgt end 251 bhi end 252 bhs end 253 ble end 254 blo end 255 bls end 256 blt end 257 bmi end 258 bne end 259 bpl end 260 bvc end 261 bvs end 262 nop 263end: 264 nop 265 .space 256-21*2-20,0 266endp16: 267 nop 268 .space 32750-(256-21*2+20)-(21*2+10*2+21*4)-12,0 269endp32: 270 nop 271