home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR2 / 68000ASM.ZIP / SIM.DOC < prev    next >
Text File  |  1989-04-10  |  19KB  |  478 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                                  68000 Simulator
  9.  
  10.                                 by Marwan Shaban
  11.  
  12.  
  13.  
  14.                                   User's Manual
  15.  
  16.  
  17.  
  18.                             Table of Contents 
  19.  
  20.  
  21.  
  22. I. Introduction  ................................................     2
  23.  
  24.  
  25. II.  The Simulator Environment  ...................................   3
  26.  
  27.      1.  Data Registers and Address Registers  ....................   3
  28.      2.  Program Counter, Status Register, and Cycle Counter  .....   3
  29.      3.  Trace and Single Step  ...................................   3
  30.      4.  The Port Display  ........................................   3
  31.      5.  The Memory Space  ........................................   4
  32.      6.  Startup Condition  .......................................   4
  33.  
  34.  
  35. III. Using the Simulator  .........................................   5
  36.  
  37.      1.  Loading a Program  .......................................   5
  38.      2.  Displaying and Changing Registers and Memory  ............   5
  39.      3.  Setting Simulator Options  ...............................   5
  40.      4.  Using Breakpoints  .......................................   5
  41.  
  42.  
  43. IV.  Simulator Commands  ..........................................   6
  44.  
  45.      1.  ld (load)  ...............................................   6
  46.      2.  ch (change registers or memory)  .........................   6
  47.      3.  clear (clear registers, memory, or cycles)  ..............   6
  48.      4.  bit_on and bit_off (change status register bits)  ........   6
  49.      5.  md (memory display)  .....................................   7
  50.      6.  bp (break point setting)  ................................   7
  51.      7.  dec and hex (number conversion commands)  ................   7
  52.      8.  sstep and ssoff (single stepping commands)  ..............   8
  53.      9.  trace and troff (trace control commands)  ................   8
  54.     10.  refresh (rewrite screen)  ................................   8
  55.     11.  go (execute a program)  ..................................   8
  56.     12.  help (online help)  ......................................   8
  57.     13.  exit (exit simulator)  ...................................   8
  58.  
  59.  
  60.  
  61. V.   Exception Processing  ........................................   9
  62.  
  63.      1.  Disabling and Enabling Exception Processing  .............   9
  64.      2.  Description of Exception Conditions  .....................   9
  65.      3.  What Happens During Exception Processing  ................  10
  66.  
  67.                                                                            2
  68.  
  69.  
  70.  
  71.  
  72.                              I. Introduction 
  73.  
  74.  
  75.         This manual describes the Motorola 68000 microprocessor 
  76. simulator program.  The program loads 68000 object files in S-record
  77. format, and simulates the 68000's execution of the code.  The full set 
  78. of 68000 operations is implemented.
  79.  
  80.         The simulator was written in VAX-11 C and Microsoft C 5.0 and 
  81. should be portable with little modification to any C language 
  82. implementation.  Versions of the simulator are presently available for 
  83. the VAX and IBM PC computers.
  84.  
  85.                                                                            3
  86.                      II.  The Simulator Environment 
  87.  
  88.  
  89.      When you start the simulator, you will see the main screen, which
  90. looks like this:
  91.  
  92.  
  93. <D0>  = 00000000  <D4>  = 00000000  <A0>  = 00000000  <A4> = 00000000
  94. <D1>  = 00000000  <D5>  = 00000000  <A1>  = 00000000  <A5> = 00000000
  95. <D2>  = 00000000  <D6>  = 00000000  <A2>  = 00000000  <A6> = 00000000
  96. <D3>  = 00000000  <D7>  = 00000000  <A3>  = 00000000  <A7> = 00000000
  97. trace: off        sstep: off        cycles:      0    <A7'>= 00000f00
  98.          cn  tr  st  rc           T S  INT   XNZVC    <PC> = 00000000
  99.   port1  00  00  82  00      SR = 0010000000000000
  100. -------------------------------------------------------------------------------
  101.  
  102.  
  103.  
  104. II.1    Data Registers and Address Registers: 
  105.  
  106.      At the top you can see the eight general-purpose data registers and
  107. the eight address registers as well as the system stack pointer (A7').
  108. Recall that the user stack pointer is called A7 while the system stack
  109. pointer is referred to as A7'.  In the simulator's user interface, the
  110. user stack pointer will be called A7 and the system stack pointer will
  111. be referred to as A8.  So, if you want to change the value in the system
  112. stack pointer, you must use the command "ch a8".
  113.  
  114.  
  115.  
  116. II.2    Program Counter, Status Register, and Cycle Counter: 
  117.  
  118.      Under the system stack pointer is the program counter.  To the left
  119. of the program counter is the status register, which is displayed in 
  120. binary form so that the individual bits can be examined at a glimpse.
  121. Above the status register is the cycle counter which contains the number
  122. of machine cycles that elapse while the microprocessor runs your program.
  123.  
  124.  
  125. II.3    Trace and Single Step: 
  126.  
  127.      The Trace and Single Stepping indicators show the status of trace
  128. and single stepping modes.  If single stepping mode is turned on, the 
  129. program will run only one 68000 instruction after you type "go" at the
  130. ">" prompt.  If the trace mode is turned on, the program will update the
  131. screen after the execution of every instruction while a program is being
  132. run.  Trace mode should not be confused with the 68000 trace mode which
  133. is turned on by turning on the "t" bit in the status register.
  134.  
  135.  
  136. II.4    The Port Display: 
  137.  
  138.      The display for "port1" is to show the status of a simulated 6850
  139. asynchronous communications interface adapter (ACIA) chip.  This 
  140. simulated chip is not implemented at this time.
  141.  
  142.                                                                            4
  143. II.5    The Memory Space: 
  144.  
  145.      The simulator has a "virtual" memory space from location 0 to
  146. location FFF (Hex).  Programs may be loaded into any part of this 
  147. virtual memory space.  However, you must pay attention to the fact that
  148. the locations under 0C0 (Hex) are used as exception vectors.  More
  149. detailed information on exception processing is contained in Section V
  150. (Exception Processing).
  151.  
  152.  
  153. II.6    Startup Condition: 
  154.  
  155.      On startup, the status register is clear except for the supervisor
  156. bit which is on.  The system stack pointer is set to locatin F00 (Hex).
  157. Note that the system stack grows downward, so that if any exception
  158. condition occurs, the processor will have room to grow downward.  Be
  159. careful about setting the system stack pointer to very low values or to
  160. a value of zero since that would create an out-of-memory-space error
  161. if the stack was used, which would cause an irrecoverable condition.
  162.  
  163.                                                                            5
  164.                       III.  Using The Simulator: 
  165.  
  166. III.1    Loading a Program: 
  167.  
  168.      A program may be loaded by typing "ld <program name>" at the ">"
  169. prompt.  <program name> may contain a path if the file to be loaded
  170. is not in the current directory.  
  171.  
  172.      NOTE: The ".h68" extension is required in the <program name> if the
  173. object module to be loaded does indeed have the extension ".h68".
  174.  
  175.  
  176. III.2    Displaying and Changing Registers and Memory: 
  177.  
  178.      Registers are displayed on the main screen.  If the display gets 
  179. garbled up for any reason, you may instruct the program to re-draw it
  180. by using the "refresh" command.
  181.  
  182.      To change register values, use the command "ch <Rx> <val>", where
  183. <Rx> is a value such as D0 to D7, or A0 to A8, and <val> is a hexadecimal
  184. number not greater than FFFFFFFF.  Similarly, the program counter may
  185. be altered by "ch pc <val>".
  186.  
  187.      To change bits in the status register, type <bit>_on or <bit>_off,
  188. where <bit> is one of these letters:  "t", "s", "v", "x", "z", "c" or "n".
  189. To change the value of the interrupt bits, type "ch int <val>", where
  190. <val> is a number from 0 to 7.
  191.  
  192.      To display values in memory, type "md <start loc> <stop loc>", where
  193. <start loc> is the hexadecimal first location to be displayed and <stop loc> 
  194. is the last location to be displayed.
  195.  
  196.      To change values in memory, type "ch mem <loc>" where <loc> is the 
  197. memory location you wish to alter the contents of.  Then, type in the 
  198. new value of that location at the prompt.  You may enter byte, word, or
  199. longword-sized values to be stored in memory.
  200.  
  201.  
  202. III.3   Setting Simulator Options: 
  203.  
  204.      If you wish to have the program update the values of registers on the
  205. screen after the execution of every instruction in your program, use the
  206. command "trace".  To turn this feature off, use "troff".
  207.  
  208.      If you wish the program to execute one instruction at a time, use the
  209. command "sstep".  To turn this feature off, use "ssoff".
  210.  
  211.      WARNING:  If you run your program without using the single step command,
  212. and you do not set any break points, then the program may run in an infinite
  213. loop, run beyond your program, or have other unpredictable results.
  214. Concievable situations are for the program to run into data that it 
  215. interprets as illegal instructions or run until it goes beyond the virtual
  216. memory space.  Both of these situations will cause exception conditions
  217. (see Section V).
  218.  
  219.  
  220. III.4   Using Breakpoints: 
  221.  
  222.      Use the "bp" command to set, clear, and display break points.  Before
  223. running your program, you should set at least one breakpoint at the point 
  224. you wish your program to "return" if you have not set the single stepping 
  225. mode.  This will keep your program from running out of control.
  226.  
  227.                                                                            6
  228.                           IV.  Simulator Commands: 
  229.  
  230.  
  231. IV.1  The Load Command:    (load 68000 program)
  232.  
  233.      Loads   ASCII  hex  file  (".h68"  file  produced  by  the  68000 
  234.      assembler) into memory.
  235.  
  236.      EXAMPLE :  "ld file1.h68"
  237.  
  238.  
  239. IV.2  The Change Command:    (change registers or memory)
  240.  
  241.      Ch  allows  you  to  change the values  of  the  simulated  68000 
  242.      registers or main memory.
  243.  
  244.      D<num> <val>     places <val> in register D<num>.   <num> is in the 
  245.                       range 0 - 7.
  246.  
  247.      A<num> <val>     places <val> in A register # num.  <num> is in the 
  248.                       range 0 - 8.
  249.  
  250.        NOTE: the supervisor stack pointer (A7') is referenced as "A8".
  251.  
  252.      PC <val>         places <val> in the program counter.
  253.  
  254.      int <val>        places  <val> in the interrupt mask bits of  the 
  255.                       status register.  <val> is in the range 0 - 7.
  256.  
  257.      mem <loc> <val>  places <val> in location <loc>.
  258.  
  259.      io               allows you to modify the port registers.
  260.      
  261.  
  262. IV.3  The Clear Command:   (clear registers, memory, or cycles)
  263.  
  264.      CLEAR allows you to clear different elements within the processor
  265.      and the simulator.
  266.      
  267.      mem         fills the memory space with zero's.
  268.      reg         fills all the registers with zero's.
  269.      port        clears port.
  270.      int         clears any pending interrupts.
  271.      cy          clears the cycle counter.
  272.      all         clears all of the above items.
  273.  
  274.  
  275. IV.4  The Bit_on and Bit_off Commands:   (change status register bits)
  276.  
  277.      bit_on allows you to turn on a specific bit in the statu
  278.      regist
  279.      
  280.      s_on         turns on the supervisor bit
  281.      t_on         turns on the trace bit
  282.      x_on         turns on the extend bit
  283.      n_on         turns on the negative bit
  284.      z_on         turns on the zero bit
  285.      v_on         turns on the overflow bit
  286.      c_on         turns on the carry bit
  287.  
  288.                                                                            7
  289.      bit_off allows you to turn off a specific bit in the status register
  290.           
  291.      s_off         turns off the supervisor bit
  292.      t_off         turns off the trace bit
  293.      x_off         turns off the extend bit
  294.      n_off         turns off the negative bit
  295.      z_off         turns off the zero bit
  296.      v_off         turns off the overflow bit
  297.      c_off         turns off the carry bit
  298.  
  299.  
  300. IV.5  The Memory Display Command:     (display main memory)
  301.  
  302.      Memory Display allows you to view the contents of a set of
  303.      memory location:
  304.  
  305.      md <start> <stop> displays   locations  between  start  and  stop 
  306.                        inclusive.  If  only a start value is  specifed 
  307.                        then only that location will be displayed.
  308.  
  309.  
  310. IV.6  The Break Point Command:   (break point setting)
  311.  
  312.      Break Points allows you to set clear and show break points.
  313.      
  314.      bp sp <loc>         sets a break point at loc.
  315.      bp cp <loc>         clears the break point at loc.
  316.      bp dp               displays a list of the break points.
  317.  
  318.  
  319. IV.7  The dec and hex Commands:   (number conversion commands)
  320.  
  321.      Dec allows you to convert a hexadecimal number into decimal format.
  322.      
  323.      dec <number>   shows the number in decimal format.  <number> must 
  324.                     be input in hexadecimal format.
  325.      
  326.  
  327.      Hex allows you to convert a decimal number into hexadecimal format.
  328.      
  329.      hex <number>   shows the number in hexadecimal format.   <number> 
  330.                     must be input in decimal format.
  331.      
  332.                                                                            8
  333. IV.8  The Sstep and Ssoff Commands:   (control the single step option)
  334.  
  335.      sstep      turns  on single stepping mode.   This makes the  'go' 
  336.                 command run only one instruction at a time.
  337.  
  338.      ssoff      turns off single stepping mode.   This makes the  'go' 
  339.                 command run instructions until
  340.  
  341.                     1. the processor encounters a breakpoint, or
  342.                     2. an exception condition occurs.
  343.  
  344.  
  345. IV.9  The Trace and Troff Commands:   (control the trace option)
  346.  
  347.      trace      turn on trace mode.   This activates trace mode  while 
  348.                 running a program.
  349.  
  350.      troff      turns  off  trace mode.   This deactivates trace  mode 
  351.                 while running a program.
  352.  
  353.  
  354. IV.10   The Refresh Command:   (rewrite screen)
  355.  
  356.      REFRESH updates the register set and other on-screen  information 
  357.      (such as port registers, SR, and cycles.)
  358.  
  359.  
  360. IV.11   The Go Command:   (execute a program)
  361.  
  362.      GO starts executing a hector program at the location specified.
  363.  
  364.      EXAMPLE :  "go 4B0"   start executing at 4B0 (HEX).
  365.  
  366.  
  367. IV.12   The Help Command:   (online help)
  368.  
  369.      The  HELP  command allows the user to enter a help mode and  view 
  370.      information about simulator commands.
  371.  
  372.  
  373.  
  374. IV.13   The Exit Command:   (exit simulator)
  375.  
  376.      EXIT exits the simulator and returns you to the command language.
  377.  
  378.                                                                            9
  379.                       V.  Exception Processing: 
  380.  
  381.  
  382. V.1   Disabling and Enabling Exception Processing: 
  383.  
  384.      If  you are not concerned with modeling the exact behavior of the 
  385.      68000  chip,  you may wish to disable exception processing  using 
  386.      the "ex_off" command.   In this mode, when an exception condition 
  387.      is encountered the simulator stops running the 68000 program  and 
  388.      prints a message telling what sort of exception occurred.
  389.  
  390.      To re-enable exception processing, use the "ex_on" command.
  391.  
  392.      The   simulator's  default  mode  is  "ex_off",   with  exception 
  393.      processing disabled.
  394.  
  395.  
  396. V.2   Description of Exception Conditions: 
  397.  
  398.      Exception   processing  can  begin  in  several  different  ways. 
  399. Generally, there are three classes of exception conditions:
  400.  
  401.         Group 0: Reset, Address error, Bus error.
  402.         Group 1: Trace, Interrupt, Illegal, Privilege violation.
  403.         Group 2: TRAP, TRAPV, CHK, and Divide by zero.
  404.  
  405.      The following is some information on each of these exceptions  as 
  406. they relate to the simulator:
  407.  
  408.   -- Reset cannot occur in this simulator.
  409.  
  410.   -- Address error occurs when an word or long word is written or read 
  411.           from an odd word boundary.  i.e. an odd memory address.
  412.  
  413.   -- Bus error  can  occur in this simulator by attempting to read  or 
  414.           write  outside  of the virtual memory  space.   The  virtual 
  415.           memory  for  this simulator is from location 0  to  location 
  416.           0FFF (hex).
  417.  
  418.   -- Trace is  entered  if on the completion of  an  instruction,  the 
  419.           trace bit of the status register is on.
  420.  
  421.   -- Interrupt   occurs  when  an  external  device   interrupts   the 
  422.           processor's operation.  Presently, this cannot occur on this 
  423.           simulator.
  424.  
  425.   -- Illegal  exception  occurs when an illegal instruction opcode  is 
  426.           executed.   It  also occurs when the ILLEGAL instruction  is 
  427.           executed.
  428.  
  429.   -- Privilege  violation  occurs  when a  privileged  instruction  is 
  430.           attempted  and the supervisor bit in the status register  is 
  431.           not set.
  432.  
  433.                                                                           10
  434.   -- TRAP exception occurs when a TRAP instruction is executed.
  435.  
  436.   -- TRAPV exception occurs when a TRAPV instruction is executed.
  437.  
  438.   -- CHK exception occurs when a CHK instruction is executed.
  439.  
  440.   -- Divide  by zero exception occurs when a DIVU or DIVS  instruction 
  441.           attempts a division by zero.
  442.  
  443.  
  444. V.3   What Happens During Exception Processing: 
  445.  
  446.      Exception processing begins by creating the appropriate exception 
  447. stack  frame  for  the particular exception group  on  the  supervisor 
  448. stack.   Then,  the  supervisor  mode is turned on and trace  mode  is 
  449. turned off.  After that, instruction execution resumes at the location 
  450. referenced by the appropriate exception vector.   The exception vector 
  451. locations that can be used in this simulator are listed below:
  452.  
  453.  
  454.        Location (Hex)        Assignment
  455.  
  456.            008               Bus error
  457.            00C               Address error
  458.            010               Illegal instruction
  459.            014               Divide by zero
  460.            018               CHK instruction
  461.            01C               TRAPV instruction
  462.            020               Privilege violation
  463.            024               Trace
  464.            028               Line 1010 emulator
  465.            02C               Line 1111 emulator
  466.         080 to 0BC           TRAP instruction vectors
  467.  
  468.  
  469.      When the simulator starts up the supervisor bit is set on and the 
  470. supervisor stack pointer is set to the value F00 (hex).  Note that the 
  471. stack grows downward,  so the stack frame for any exceptions will grow 
  472. from F00 downward.
  473.  
  474.      For  complete information on exception processing,  refer to  the 
  475. 68000 Programmer's Reference Manual, Section 4.
  476.  
  477.