68K GAS temp.s page 1 1 # 1 "asmcode68.s" 1 #include "targetsys.h" 0 0 1 2 /* 3 This is the easiest place to make change. If you make a change here, 4 then all the .c files must be recompiled. This can be done with the 5 make command and the appropriate makefile. 6 */ 7 8 /* 9 the boolean logic symbols defined for code readability. 10 */ 11 12 #define TRUE 1 13 #define FALSE 0 14 15 /* 16 if you want the monitor to automatically convert all input capitals to 17 lower case, excpet after a textdel, then this should be true. 18 Otherwise, this should be false. 19 */ 20 21 #define CONVCAP TRUE 22 23 /* 24 these are the delimiters. Most are selfexpalnitory. 25 */ 26 27 #define BINDEL '%' /* binary number */ 28 #define OCTDEL '@' /* octal number */ 29 #define DECDEL '&' /* decimalnumber */ 30 #define HEXDEL '$' /* hexadecimal */ 31 #define PLUSDEL '+' /* the arithmatic plus */ 32 #define MINUSDEL '-' /* the arithmatic minus */ 33 #define SYMBOLDEL '/' /* start of a symbol in the symbol table */ 34 #define OPTDEL '-' /* start of an option on a command line */ 35 #define COUNTDEL ':' /* indicates range uses a count, not address */ 36 #define ADDRDEL ',' /* Used for assembly,change getnum if you change this */ 37 #define TEXTDEL ';' /* start of a text field */ 38 39 /* 40 these are the charachters used for halting, continuing or canceling 41 the output of commands that are taking along time. 42 */ 43 44 #define HALTCHAR 'h' /* halt display */ 45 #define CONTCHAR 'c' /* continue (after a halt) */ 46 #define STOPCHAR 's' /* stop the display */ 47 #define ESCDEF 0x01 /* escape from transparent mode */ 48 49 /* 50 these mark various breaks in the structures and strings for such 51 things as commands, register displays, etc. 52 */ 53 68K GAS temp.s page 2 54 #define ENDCMD ' ' /* used to show the end of a command */ 55 #define BREAK '=' /* used to request a break in a display */ 56 #define LASTCMD 0 /* ends a structure of indeterminate length */ 57 58 #define ENDSTR '\0' /* end of a string */ 59 #define LF 10 /* line feed */ 60 #define CR 13 /* carriage return */ 61 /* 62 directives for while in the mm and as commands. 63 */ 64 65 #define BACKUP '-' /* back up a number of bytes */ 66 #define FINISH '.' /* quit the mm or as command */ 67 #define NEXT '+' /* advance a number of bytes */ 68 #define HELP '?' /* print out the directives available */ 69 70 /* 71 numerical scales used in decoding command lines, or printing information to 72 the terminal. 73 */ 74 75 #define DEFAULTSCALE 16 /* the numerical scale used in most situations */ 76 #define REGSCALE 10 /* numerical scale used to display register numbers */ 77 #define COUNTSCALE 10 /* numerical scale for in */ 78 #define DEFCOUNT 48 /* default on if none used in */ 79 80 #define FPSCALE 10 /* numerical scale used to display/except floating 81 point numbers */ 82 #define FPDIGITS 4 /* number of decimal places to display floating point 83 numbers to */ 84 #define FIELD_DISPLAY TRUE /* display fields of floating point # data */ 85 86 /* ****************************************************************** 87 88 89 begining of MPU and processor dependant defines 90 91 92 93 ******************************************************************* */ 94 /* 95 the maximums for displaying o the screen. 96 */ 97 98 #define MAXLINE 80 /* maximum characters on a line on the screen */ 99 #define MAXSCREEN 20 /* maximum lines to display on the screen at once */ 100 #define REGPERLINE 4 /* number of registers per line to display */ 101 #define REGPERSCREEN 80 /* number of registers to display per screen */ 102 #define MEMLINEDIS 6 /* number of address spaces to print per line */ 103 104 #define MAXCMMU 2 /* number of cmmus for a 88k */ 105 106 107 #define MAXBR 8 /* number of breakpoints available to user */ 108 #define MAXSYMBOL 20 /* number of symbols in symbol table */ 109 #define MAXSYMBLEN 10 /* maximum length of symbol name */ 110 68K GAS temp.s page 3 111 /* 112 memory locations, used for memory map purposes. 113 */ 114 115 /* *************************** ASM/DISASM DEFINES ************************ */ 116 117 /* Defines that determine which 68xxx device the target system uses 118 and will determine what device the asm/disasm mimics. If size 119 is a factor then deletions in the textdef.h instruction file 120 may be made based on the number of instructions that will be referenced 121 the user should define both the DEVICE, EMULATOR and the COPROCESSOR features 122 directly below this statement */ 123 124 /* ********************** */ 125 /* ********************** */ 126 /* ********************** */ 127 /* ********************** */ 128 /* ********************** */ 129 /* ********************** */ 130 #define DEVICE 68010 131 /* ********************** */ 132 /* ********************** */ 133 /* ********************** */ 134 /* ********************** */ 135 /* ********************** */ 136 /* ********************** */ 137 138 /* known devices are 68000,68008,68010,68020,68030,68040 139 this determines what version of the asm/disasm 140 will be compiled */ 141 142 /* NOTE: The 68HC000 should be defined as a 68000 */ 143 144 #if (DEVICE==68040) 145 146 /* ********************** */ 147 /* ********************** */ 148 /* ********************** */ 149 /* ********************** */ 150 /* ********************** */ 151 /* ********************** */ 152 #define EMULATOR TRUE /* options are TRUE or FALSE */ 153 /* ********************** */ 154 /* ********************** */ 155 /* ********************** */ 156 /* ********************** */ 157 /* ********************** */ 158 /* ********************** */ 159 160 /* ***************** !!!!!!!!!!!!!!!!!!!!!!! ******************* */ 161 /* NOTE: This will provide entire 68881 support to 68040 */ 162 /* ***************** !!!!!!!!!!!!!!!!!!!!!!! ******************* */ 163 164 #endif 165 166 167 68K GAS temp.s page 4 168 #if (DEVICE>=68020) 169 170 #if(DEVICE==68040) 171 #define COPROCESSOR TRUE 172 #else 173 /* ********************** */ 174 /* ********************** */ 175 /* ********************** */ 176 /* ********************** */ 177 /* ********************** */ 178 #define COPROCESSOR TRUE /* options are TRUE or FALSE */ 179 /* ********************** */ 180 /* ********************** */ 181 /* ********************** */ 182 /* ********************** */ 183 /* ********************** */ 184 /* ********************** */ 185 186 /* ***************** !!!!!!!!!!!!!!!!!!!!!!! ******************* */ 187 /* NOTE: This is for entire 68881 support */ 188 /* ***************** !!!!!!!!!!!!!!!!!!!!!!! ******************* */ 189 190 #endif 191 #endif 192 193 /* ********************************************************************* */ 194 195 196 /* ********************************************************************* */ 197 /* ********************** MEMORY MAP FOR DEBUGGER *********************** */ 198 199 #define DUARTALOC 0x0402001 /* MC68681 duart channel a */ 200 #define DUARTBLOC 0x0402011 /* MC68681 duart channel b */ 201 202 #define ROMLOC 0x800000 /* system ROM space */ 203 /* .text segment should be loaded here */ 204 /* .data segment should be loaded here */ 205 206 #define RAMSIZE 0x080000 /* 512 Kb */ 207 208 #define SYSRAMLOC 0x0007e000 209 /* system RAM space */ 210 /* NOTE: space must be reserved for the 211 location of the .bss used by 212 the monitor. */ 213 /* Provided the .bss is not larger than 214 1000 (ie. VBRLOC resides at SYSRAMLOC 215 + 1000) placing the .bss from the 216 monitor at this location is allowed */ 217 218 #define ISPLOC SYSRAMLOC+0x2000 /* defines for monitor */ 219 #define MSPLOC SYSRAMLOC+0x1c00 220 #define USPLOC SYSRAMLOC+0x1b00 221 #define VBRLOC SYSRAMLOC+0x1000 222 223 #define USERPCLOC 0x2000 /* defines for usercode */ 224 #define USERVBRLOC 0x0 68K GAS temp.s page 5 225 226 /* *********************************************************************** */ 227 #if(DEVICE<68020) 228 #define USERSSPLOC USERVBRLOC+0x2000 /* Note: Only one of these is 229 used based on the device 230 being implemented */ 231 #else 232 #define USERISPLOC USERVBRLOC+0x2000 233 #endif 234 /* *********************************************************************** */ 235 236 #define USERMSPLOC USERVBRLOC+0x1c00 237 #define USERUSPLOC USERVBRLOC+0x1b00 238 239 #define SRSTART 0x2700 /* status register */ 240 241 #define TERMINAL DUARTALOC /* location of terminal (i.e. screen) */ 242 #define HOST DUARTBLOC /* location of host computer port */ 243 244 245 /* ************************** END MEMMORY MAP ************************** */ 246 /* ********************************************************************* */ 247 248 /* 249 number of bytes word different sizes. 250 */ 251 252 #define WORD 2 /* word 2 for 68k, 4 for 88k */ 253 #define BYTE 1 /* byte, always 1 */ 254 #define LONG 4 /* long, 4 for 68k, not used for 88k */ 255 #define HALF 2 /* half, 2 for 88k, not used for 68k */ 256 #define DFSIZE 2 /* default size to use if none specified */ 257 258 259 #ifndef COPROCESSOR 260 #define COPROCESSOR FALSE 261 #endif 262 263 264 #if (DEVICE==68008) 265 #define MAXINST 124 266 #define COPROCESSOR FALSE 267 #endif 268 #if (DEVICE==68010) 269 #define MAXINST 130 270 #define COPROCESSOR FALSE 271 #endif 272 #if (DEVICE==68020) 273 #define MAXINST 159 274 #endif 275 #if (DEVICE==68030) 276 #define MAXINST 171 277 #endif 278 #if (DEVICE==68040) 279 #define CRENTRIES 15 280 #define MAXINST 186 /* Note: This is the entire table */ 281 #endif 68K GAS temp.s page 6 282 283 #ifndef MAXINST 284 #define DEVICE 68000 285 #define MAXINST 124 286 #endif 287 288 #ifndef CRENTRIES /* variable used to determine the extent of the 289 CONTROLREG table for movec instruction */ 290 #define CRENTRIES 7 291 #endif 292 293 #ifndef EMULATOR 294 #define EMULATOR FALSE 295 #endif 296 297 #if (COPROCESSOR==TRUE || EMULATOR==TRUE) 298 #define MAXCOPROCINST 41 /* NOTE: This will be changed to represent the 299 entire table when the table is 300 implemented */ 301 #else 302 #define MAXCOPROCINST 36 303 #endif 304 305 306 #if (EMULATOR==TRUE || COPROCESSOR==TRUE) 307 #define MONADICSRCH 34 308 #endif 309 310 #ifndef MONADICSRCH 311 #define MONADICSRCH 7 312 #endif 313 314 #define MAXMONADIC 34 315 316 #if(DEVICE==68040 || COPROCESSOR==TRUE) 317 #define MAXREGS 75 /* most registers used by any one device */ 318 #endif 319 320 #if(DEVICE==68030) 321 #ifndef MAXREGS 322 #define MAXREGS 41 /* most registers used by any one device */ 323 #endif 324 #endif 325 326 327 #ifndef MAXREGS 328 #define MAXREGS 33 /* most registers used by any one device */ 329 #endif 330 /* ************************************************************************ */ 331 332 /* 333 location of program counter, status register and stack pointer in mpu register 334 list. 335 */ 336 337 #define PC 0 338 #define SR 1 68K GAS temp.s page 7 339 #if(DEVICE<68020) 340 #define USP 2 341 #else 342 #define USP 3 343 #endif 344 #define MSP 4 345 #define ISP 5 346 #define VBR 6 347 #define CACR 7 348 #define CAAR 8 349 #define SFC 9 350 #define DFC 10 351 #define D0 12 352 #define A7 28 353 354 /* 355 various values used to mask of bits in assembler/disassembler 356 */ 357 358 #define MASK8 0x000000ff 359 #define MASK4 0x0000000f 360 #define MASK16 0x0000ffff 361 #define MASK12 0x00000fff 362 #define MASK32 0xffffffff 363 #define MASK 0xfc000000 364 #define MASK2521 0x03f00000 365 #define MASK2016 0x001f0000 366 #define MASK50 0x0000001f 367 #define MASK60 0x0000003f 368 #define MASK80 0x000001ff 369 #define MASK105 0x000007e0 370 #define MASK95 0x000003e0 371 #define MASK75 0x000000e0 372 #define MASK98 0x00000300 373 #define MASK109 0x00000600 374 #define MASK87 0x00000180 375 #define MASK65 0x00000060 376 #define MASK1514 0x0000c000 377 #define MASK1511 0x0000f800 378 #define MASK1310 0x00003c00 379 #define MASK1311 0x00003800 380 #define MASK139 0x00003e00 381 #define MASK9 0x00000200 382 #define MASK250 0x03ffffff 383 384 /* 385 Hex values used in tracing and break points 386 An alternative to using ILLEGAL is BKPT #0 (0x4848). 387 The monitor will handle both identically, but the hardware will react 388 differently. 389 */ 390 #define BRTRAP 0x4afc /* hex value of ILLEGAL instruction for break points */ 391 #define TRACEON 0x8000 /* bit to toggle to turn trace on */ 392 393 /* 394 location in the inst struct where the set of instructions start. 395 */ 68K GAS temp.s page 8 396 397 #define SET0 0 398 #define SET1 32 399 #define SET2 40 400 #define SET3 112 401 #define SET4 135 402 #define SET5 138 403 #define SET6 170 404 #define SET7 207 405 #define SET8 213 406 #define SET9 229 407 #define SET10 178 408 #define SET11 124 409 #define SET12 48 410 #define SET13 80 411 #define SET14 104 412 413 414 /* 415 offsets for duart 416 */ 417 418 #define MR1X 0 /* mode register 1 */ 419 #define MR2X 0 /* mode register 2 */ 420 #define SRX 2 /* status register */ 421 #define CSRX 2 /* clock-select register */ 422 #define CRX 4 /* command register */ 423 #define RBX 6 /* receive buffer */ 424 #define TBX 6 /* transmitter buffer */ 425 #define IPCR 8 /* input port change register */ 426 #define ACR 8 /* auxillary contol register */ 427 #define ISR 10 /* interrupt status register */ 428 #define IMR 10 /* interrupt mask register */ 429 #define CMSB 12 /* counter most significant byte */ 430 #define CTUR 12 /* counter/timer upper register */ 431 #define CLSB 14 /* counter least significant register */ 432 #define CTLR 14 /* counter/timer lower register */ 433 #define IVR 24 /* interrupt vector register */ 434 #define IP 26 /* input port */ 435 #define OPCR 26 /* output port configuration register */ 436 #define STRC 28 /* start counter command */ 437 #define BTST 28 /* bit set command */ 438 #define STPC 30 /* stop counter command */ 439 #define BTRST 30 /* bit reset command */ 440 441 442 /* Definitions for RTC */ 443 444 #define RTC_0 0x0c08001 445 #define RTC_1 RTC_0+2 446 #define RTC_2 RTC_1+2 447 #define RTC_3 RTC_2+2 448 #define RTC_4 RTC_3+2 449 #define RTC_5 RTC_4+2 450 #define RTC_6 RTC_5+2 451 #define RTC_7 RTC_6+2 452 #define RTC_8 RTC_7+2 68K GAS temp.s page 9 453 #define RTC_9 RTC_8+2 454 #define RTC_A RTC_9+2 455 #define RTC_B RTC_A+2 456 #define RTC_C RTC_B+2 457 #define RTC_D RTC_C+2 458 #define RTC_E RTC_D+2 459 #define RTC_F RTC_E+2 460 461 #define PIT_PGCR 0x400001 462 #define PIT_PSRR PIT_PGCR+2 463 #define PIT_PADDR PIT_PSRR+2 464 #define PIT_PBDDR PIT_PADDR+2 465 #define PIT_PCDDR PIT_PBDDR+2 466 #define PIT_IVR PIT_PCDDR+2 467 #define PIT_PACR PIT_IVR+2 468 #define PIT_PBCR PIT_PACR+2 469 #define PIT_PADR PIT_PBCR+2 470 #define PIT_PBDR PIT_PADR+2 471 #define PIT_PAAR PIT_PBDR+2 472 #define PIT_PBAR PIT_PAAR+2 473 #define PIT_PCDR PIT_PBAR+2 474 #define PIT_PSR PIT_PCDR+2 475 #define PIT_TCR PIT_PSR+6 476 #define PIT_TIVR PIT_TCR+2 477 #define PIT_CPRH PIT_TIVR+4 478 #define PIT_CPRM PIT_CPRH+2 479 #define PIT_CPRL PIT_CPRM+2 480 #define PIT_CRH PIT_CPRL+4 481 #define PIT_CRM PIT_CRH+2 482 #define PIT_CRL PIT_CRM+2 483 #define PIT_TSR PIT_CRL+2 484 485 /* ********** end of hardware and MPU dependant code *************** */ 486 2 .file "asmcode68.s" 3 .text 4 .global asmput8,asmput16,asmput32,asmget8,asmget16,asmget32 5 .global putmpu,regdata,asmaddr,asmdata 6 7 .equ RPC, 0 8 .equ RSR, 4 9 .equ RUSP, 8 10 .equ RMSP, 12 11 .equ RISP, 16 12 .equ RVBR, 20 13 .equ RCACR, 24 14 .equ RCAAR, 28 15 .equ RSFC, 32 16 .equ RDFC, 36 17 .equ RD0, 40 18 #if(DEVICE==68030) 19 .equ SCRP, 104 20 .equ SSRP, 112 21 .equ STC, 120 22 .equ STT0, 124 23 .equ STT1, 128 24 .equ SMMUSR, 134 68K GAS temp.s page 10 25 #endif 26 #if(DEVICE==68040) 27 .equ SURP, 104 28 .equ SSRP, 112 29 .equ STC, 120 30 .equ SDTT0, 124 31 .equ SDTT1, 128 32 .equ SITT0, 132 33 .equ SITT1, 136 34 .equ SMMUSR, 142 35 #endif 36 #if(DEVICE==68040 || COPROCESSOR==TRUE) 37 .equ FPCR, 144 38 .equ FPSR, 148 39 .equ FPIAR, 152 40 .equ FP0, 156 41 #endif 42 43 #if(DEVICE>68010) 44 asmput8: mov.b asmdata+3,([asmaddr]) 45 rts 46 47 asmput16: mov.w asmdata+2,([asmaddr]) 48 rts 49 50 asmput32: mov.l asmdata,([asmaddr]) 51 rts 52 53 asmget8: clr.l asmdata 54 mov.b ([asmaddr]),asmdata+3 55 bpl.b nosi8 56 or.l &0xffffff00,asmdata 57 nosi8: rts 58 59 asmget16: clr.l asmdata 60 mov.w ([asmaddr]),asmdata+2 61 bpl.b nosi16 62 or.l &0xffff0000,asmdata 63 nosi16: rts 64 65 asmget32: mov.l ([asmaddr]),asmdata 66 rts 67 #else 68 69 0000 2F08 asmput8: mov.l %a0,-(%sp) 70 0002 2079 0000 mov.l asmaddr,%a0 70 0000 71 0008 10B9 0000 mov.b asmdata+3,(%a0) 71 0000 72 000e 205F mov.l (%sp)+,%a0 73 0010 4E75 rts 74 75 0012 2F08 asmput16: mov.l %a0,-(%sp) 76 0014 2079 0000 mov.l asmaddr,%a0 76 0000 77 001a 30B9 0000 mov.w asmdata+2,(%a0) 77 0000 68K GAS temp.s page 11 78 0020 205F mov.l (%sp)+,%a0 79 0022 4E75 rts 80 81 0024 2F08 asmput32: mov.l %a0,-(%sp) 82 0026 2079 0000 mov.l asmaddr,%a0 82 0000 83 002c 20B9 0000 mov.l asmdata,(%a0) 83 0000 84 0032 205F mov.l (%sp)+,%a0 85 0034 4E75 rts 86 87 0036 42B9 0000 asmget8: clr.l asmdata 87 0000 88 003c 2F08 mov.l %a0,-(%sp) 89 003e 2079 0000 mov.l asmaddr,%a0 89 0000 90 0044 13D0 0000 mov.b (%a0),asmdata+3 90 0000 91 004a 6A0A bpl.b nosi8 92 004c 00B9 FFFF or.l &0xffffff00,asmdata 92 FF00 0000 92 0000 93 0056 205F nosi8: mov.l (%sp)+,%a0 94 0058 4E75 rts 95 96 005a 42B9 0000 asmget16: clr.l asmdata 96 0000 97 0060 2F08 mov.l %a0,-(%sp) 98 0062 2079 0000 mov.l asmaddr,%a0 98 0000 99 0068 33D0 0000 mov.w (%a0),asmdata+2 99 0000 100 006e 6A0A bpl.b nosi16 101 0070 00B9 FFFF or.l &0xffff0000,asmdata 101 0000 0000 101 0000 102 007a 205F nosi16: mov.l (%sp)+,%a0 103 007c 4E75 rts 104 105 007e 2F08 asmget32: mov.l %a0,-(%sp) 106 0080 2079 0000 mov.l asmaddr,%a0 106 0000 107 0086 23D0 0000 mov.l (%a0),asmdata 107 0000 108 008c 205F mov.l (%sp)+,%a0 109 008e 4E75 rts 110 111 #endif 112 113 114 putmpu: 115 0090 2039 0000 mov.l (regdata+RUSP),%d0 115 0000 116 #if(DEVICE>=68010) 117 0096 2239 0000 mov.l (regdata+RVBR),%d1 117 0000 118 #endif 68K GAS temp.s page 12 119 #if(DEVICE==68010) 120 009c 2E79 0000 mov.l (regdata+RISP),%a7 120 0000 121 #endif 122 #if(DEVICE>=68020) 123 mov.l (regdata+RISP),%d2 124 mov.l (regdata+RMSP),%d3 125 mov.l (regdata+RCAAR),%d4 126 mov.l (regdata+RCACR),%d5 127 mov.l (regdata+RSFC),%d6 128 mov.l (regdata+RDFC),%d7 129 #endif 130 00a2 4E7B 0800 movec.l %d0,%usp 131 #if(DEVICE>=68010) 132 00a6 4E7B 1801 movec.l %d1,%vbr 133 #endif 134 #if(DEVICE>=68020) 135 movec.l %d2,%isp 136 movec.l %d3,%msp 137 movec.l %d4,%caar 138 movec.l %d5,%cacr 139 movec.l %d6,%sfc 140 movec.l %d7,%dfc 141 #endif 142 #if(DEVICE==68030) 143 lea.l (regdata+SCRP),%a0 144 short 0xf010 145 short 0x4c00 #pmove (a0),crp 146 lea.l (regdata+SSRP),%a0 147 short 0xf010 148 short 0x4800 #pmove (a0),srp 149 lea.l (regdata+STC),%a0 150 short 0xf010 151 short 0x4000 #pmove (a0),tc 152 lea.l (regdata+STT0),%a0 153 short 0xf010 154 short 0x0800 #pmove (a0),tt0 155 lea.l (regdata+STT1),%a0 156 short 0xf010 157 short 0x0c00 #pmove (a0),tt1 158 lea.l (regdata+SMMUSR),%a0 159 short 0xf010 160 short 0x6000 #pmove (a0),psr 161 #endif 162 #if(DEVICE==68040) 163 #68040 instructions to effect supervisor 164 #programer model support should be 165 #inserted here and below ! 166 #endif 167 #if(DEVICE==68040 || COPROCESSOR==TRUE) 168 lea.l (regdata+FPCR),%a0 169 short 0xf210 170 short 0x9000 #fmove.x (a0),fpcr 171 lea.l (regdata+FPSR),%a0 172 short 0xf210 173 short 0x8800 #fmove.x (a0),fpsr 174 lea.l (regdata+FPIAR),%a0 68K GAS temp.s page 13 175 short 0xf210 176 short 0x8400 #fmove.x (a0),fpiar 177 lea.l (regdata+FP0),%a0 178 short 0xf210 179 short 0xd0ff #fmovem.x (a0),fp0-fp7 180 #endif 181 00aa 3F3C 0024 mov.w &0x0024,-(%a7) 182 00ae 2F39 0000 mov.l (regdata+RPC),-(%a7) 182 0000 183 00b4 2039 0000 mov.l (regdata+RSR),%d0 183 0000 184 00ba 3F00 mov.w %d0,-(%a7) 185 00bc 4CF9 7FFF movm.l (regdata+RD0),&0x7fff 185 0000 0000 186 00c4 4E73 rte