home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / program / books / mc68ktu2 / mc680009.doc < prev    next >
Text File  |  1985-11-18  |  7KB  |  209 lines

  1. 02200000000801
  2. 1
  3. 2
  4. 9[...............................................................]0
  5. üASSEMBLY LANGUAGE COURS PART IX Çby Mark van den Boer
  6.  
  7. ëSystem Control instructionsÇ
  8.  
  9. In this part of the course the last group of instructions will be 
  10. explained.  This group of instructions deals with the supervisor-
  11. mode  and are therefore sometimes referred to as  system  control 
  12. instructions.  To  remind  you:  the  S-bit  in  the  SR  (status 
  13. register)  of  the  68000  determines whether  the  68000  is  in 
  14. supervisor-mode or not.  Many of these instructions deal with  so 
  15. called  exceptions.  Exception is another word for interrupt  and 
  16. these are used to force program control immediately to a specific 
  17. routint exception handler routine.  Exceptions are used to detect 
  18. situations  that  are  urgent and need to  be  handled  directly. 
  19. Therefore  every  exception has a vector  assigned  to  it.  This 
  20. vector is a pointer to a routine which performs some action which 
  21. should  be  taken when such an exception  occurs.  The  exception 
  22. vectors are located in the first 256 longwords of memory.
  23.  
  24.  
  25.  
  26.  
  27. Instruction:   CHK
  28. Syntax:        CHK <ea>,Dn
  29. Data sizes:    word
  30. Condition codes affected:
  31.                X    not affected
  32.                N    Set if Dn is less than zero,  cleared if <ea> 
  33.                     less than Dn, in all other cases undefined
  34.                Z
  35.                V
  36.                C    always undefined
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49. Addressing modes allowed:
  50. Source:
  51.           Dn
  52.           (An)
  53.           (An)+
  54.           -(An)
  55.           w(An)
  56.           b(An,Rn)
  57.           w
  58.           l
  59.           w(PC)
  60.           b(PC,Rn)
  61.           #
  62. Destination:
  63.           Dn
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71. Function: Compares the contents of the effective address  operand 
  72.           with  the data-register.  If the data register is  less 
  73.           than zero (the data register is always considered to be 
  74.           a  signed word) or greater than the contents  of  <ea>, 
  75.           then   an  exception  occurs.   The  pointer  to   this 
  76.           exception-routine  is  located  at  address  $18.  This 
  77.           instruction  is  used to check if a  data  register  is 
  78.           within  a  range.   It  is  often  used  by  high-level 
  79.           languages   such  as  PASCAL  to  perform   array-bound 
  80.           checking.
  81. Examples:
  82. Instruction              Before              After
  83. CHK #50,D0               D0=45               D0=45
  84.                          No exception occured, if D0 had been 51
  85.                          or greater then an exception would have
  86.                          occured.
  87.  
  88.  
  89. Instruction:   MOVE USP       ü(privileged instruction)Ç
  90. Syntax:        MOVE USP,An    or   MOVE An,USP
  91. Data sizes:    long
  92.  
  93. Condition codes affected:
  94.                X
  95.                N
  96.                Z
  97.                V
  98.                C    not affected
  99. Addressing modes allowed:
  100.      See syntax
  101. Function: As  you all should know,  the 68000 has in fact two  A7 
  102.           registers.  One A7 register is used when in supervisor-
  103.           mode,  the  other  when in usermode (this  is:  not  in 
  104.           supervisor-mode.   It  is  sometimes  desirable  for  a 
  105.           program  which is executing in supervisor mode to  know 
  106.           the value of the usermode A7-register. This instruction 
  107.           provides  a  way to obtain and change the value  of  A7 
  108.           usermode-register.
  109. Example:
  110. Instruction              Before              After
  111. MOVE USP,A6              A7user=$12345678    A7user=$12345678
  112.                          A6    =$00000000    A6    =$12345678
  113.                          A7sup =$87654321    A7sup =$87654321
  114.  
  115. Instruction:   RESET
  116. Syntax:        RESET          ü(privileged instruction)Ç
  117. Data sizes:    none
  118. Condition codes affected:
  119.                X
  120.                N
  121.                Z
  122.                V
  123.                C    not affected
  124. Function: Reset all external devices. A device can be a chip like 
  125.           the 6850.
  126.  
  127.  
  128. Instruction:   RTE            ü(privileged instruction)Ç
  129. Syntax:        RTE
  130. Data sizes:    none
  131. Condition codes affected:
  132.                none
  133.  
  134.  
  135.  
  136.  
  137. Function: Every exception is terminated by this  instruction.  It 
  138.           can be compared to RTS. The only difference is that RTE 
  139.           will  restore  the  SR  in  addition.   Note  that   an 
  140.           exception-routine   has  the  responsibility  to   save 
  141.           registers if this is important.
  142.  
  143.  
  144. Instruction:   STOP           ü(privileged instruction)Ç
  145. Syntax:        STOP #
  146. Data sizes:    word
  147. Condition codes affected:
  148.           All set as a direct result of the operand
  149. Addressing modes allowed:
  150. Source:
  151.           #
  152. Function: Stop execution of a program until an exception  occurs. 
  153.           The  operand  stored  in the SR.  Note  that  with  the 
  154.           operand  a minimum interrupt level can  be  determined. 
  155.           With  this  instruction it is possible to  wait  for  a 
  156.           videochip interrupt to occur.
  157.  
  158.  
  159. Example:
  160.           STOP #%0010011000011111
  161.           Wait  for  an exception with a priority of 6  or  7  to 
  162.           occur and set the XNZVC-bits.
  163.  
  164.  
  165. Instruction:   TRAP
  166. Syntax:        TRAP #
  167. Data sizes:    # must be >=0 and <=15
  168. Condition codes affected:
  169.                X
  170.                N
  171.                Z
  172.                V
  173.                C    not affected
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181. Function: This  instruction generates an exception.  The  operand 
  182.           indicates  an  exception number.  The vectors  for  the 
  183.           exceptions  are located at addresses $80 to  $BC.  This 
  184.           instruction  is  mainly  used to  allow  programs  that 
  185.           execute in user-mode to call supervisor-mode  routines. 
  186.           This  way  a  user can be given a  number  of  specific 
  187.           functions. In the ST trap vectors 2, 14 and 15 are used 
  188.           for GEM,  BIOS and XBIOS functions.  In the case of the 
  189.           ST  the TRAP-instructions is preceded  by  instructions 
  190.           that  put  function numbers and  parameters  for  these 
  191.           functions  on  the stack.  This way it is  possible  to 
  192.           assign êgroupsÇ of functions to one trap-vector.
  193.           Note  that  when  calling  a  TRAP  in  user-mode   the 
  194.           stackpointers  change (supervisor-mode  and  user-mode, 
  195.           remember??). Thus, the MOVE USP instruction can be used 
  196.           to retrieve parameters that had been put on the stack.
  197.  
  198.  
  199. Instruction:   TRAPV
  200. Syntax:        TRAPV
  201. Data sizes:    none
  202.  
  203. Condition codes affected:
  204.                none
  205. Function: When  the  V-bit  is  set  an  exception  occurs.   The 
  206.           exception vector is located at address $1C. When the V-
  207.           bit is clear nothing happens.  This instruction can  be 
  208.           used by high-level languages to inform the user that an 
  209.           overflow error has occured.