home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / ST_NEWS / STN_01_C.MSA / DATA_DOC26 < prev    next >
Text File  |  1994-03-14  |  6KB  |  103 lines

  1. ü68000 MACHINE LANGUAGE COURSE PART I Çby Mark van de Boer
  2.  
  3. Originally  published in üST NEWSÇ Volume 1 Issue  6,  launched  on 
  4. November 15th 1986.
  5.  
  6. As  the  title  already says this is the first  part  of  an 68000 
  7. assembly language programming course.  This course is intended for 
  8. people  who  already have a little experience with programming  in 
  9. assembly  language  on microprocessors like the 6502 (6510  is  in 
  10. fact the same) and the 68xx (like 6800,  6801, 6805, 6809) series. 
  11. In   this  course  these  two  microprocessor-families   will   be 
  12. referenced by their most famous members, the 6502 and the 6809. At 
  13. this  time it is not exactly known how many articles  this  course 
  14. will have. I think it will be about six articles long.
  15. Now  I will describe some features of the 68000.  The 68000  is  a 
  16. sixteen-bit  microprocessor.  This means that an opcode is  always 
  17. sixteen bits (On the 6502 and 6809 an opcode is 8 bits,  therefore 
  18. they are called 8-bit microprocessors).  The databus of the  68000 
  19. is  16 bits wide,  this means that 16 bits can be  transferred  at 
  20. once  by the 68000 (The 6502 and 6809 both have a databus that  is 
  21. eight  bits wide,  so they can transfer 8 bits at  once).
  22.  
  23. Another  important feature of the 68000 is its impressive  set  of 
  24. registers.  First there are the eight data registers, numbered D0-
  25. D7. They are 32 bits wide and can be used for operations on 8-bit, 
  26. 16-bit and 32-bit quantities.  Data registers can be compared with 
  27. the  A-register  (Accumulator)  on  the  6502  and   6809,   their 
  28. function  same,  but  the use of the data registers is  much  more 
  29. convenient.   Second,  there  are  the  eight  address  registers, 
  30. numbered from A0-A7.  They are 32 bits wide as well and their only 
  31. use  is  in  addressing memory.  However,  the upper  8  bits  are 
  32. ignored  by  the  68000 since its address bus is  'only'  24  bits 
  33. wide,  meaning  that the 68000 can address up to 16  megabytes  of 
  34. memory.  Register  A7  has a special function;  it is  called  the 
  35. system  stackpointer.  This  means  that  if  you  execute  a  JSR 
  36. instruction,  some data will be saved on the address contained  in 
  37. this  register.  By the way,  you can use every  address  register 
  38. very  easily as a stackpointer.  The third class consists  of  one 
  39. register, the PC (program counter). This register always  contains
  40. the address of the instruction  to  be  executed next.  Of course,
  41. the upper eight bits of the PC are also ignored. The  fourth class
  42. consists of one 16 bit register, the status register, called SR.
  43.  
  44.  
  45. This register is built up like this:
  46.  
  47. -------------------------------------------------------------
  48. | T |   | S |   | Iá0Ç| Iá1Ç| Iá2ü|Ç   |   |   | X | N | Z | V | C |
  49. -------------------------------------------------------------
  50.     system-byte             |          user-byte
  51.  
  52. The  upper 8 bits are called the system byte.  This byte  contains 
  53. information that is important to the system.  Normally you can not 
  54. change this byte if you run an application.  Bit 15 is called  the 
  55. trace-bit.  If  this  bit is set,  every time after  executing  an 
  56. instruction  the 68000 will generate an exception (This is  called 
  57. an interrupt on the 6502 and 6809). This is especially useful when 
  58. debugging programs. Bit 13 is called the supervisor bit. When this 
  59. bit  is  set the 68000 is in supervisor mode;  when  this  bit  is 
  60. cleared,  however,  the 68000 is in user mode.  When executing  in 
  61. supervisor  mode,  the 68000 can execute the so called  privileged 
  62. instructions,  which are not available in user mode.  For example, 
  63. it is illegal trying to change the upper 8 bits of the SR when  in 
  64. user  mode.  Bits 8,  9 and 10 are called the interrupt  mask.  In 
  65. total they can contain eight different values ranging from zero to 
  66. seven.  For  instance,  if  bits  8 and 10 are set and  bit  9  is 
  67. cleared,  the  value of the interrupt mask is 5.  This means  that 
  68. only interrupts with a level of 5 and higher are recognized by the
  69. 68000  and  interrupts  with a level lower  than  5  are  ignored. 
  70. Interrupts of level 7 can be considered as non maskable interrupts
  71. (compare this to the NMI  on the 6502 and 6809).  The lower 8 bits
  72. are   called  the  conditioncode  register,   CCR  (this  can   be 
  73. compared to the CC of the 6502 and 6809). The CCR contains 5 bits,
  74. which contain useful data.  Bit 0 is the carry-flag (C),  bit 1 is 
  75. the overflow-flag (V),  bit 2 is the zero-flag (Z),  bit 3 is  the 
  76. negative-flag  (N).  The  meanings of these bits are  exactly  the 
  77. same as on the 6502 and 6809.  Then there is bit 4 which is called 
  78. the extend-flag (X).  It is nearly exactly the same as the  carry-
  79. flag,  but  is not affected by every instruction that affects  the 
  80. carry-flag. This feature of the extend-flag  is  especially useful
  81. when  using  multiple precision  arithmetic,  e.g.  adding  64-bit 
  82. numbers.
  83. Another  feature of the 68000 is its ability to access three  data 
  84. formats: byte (8 bits), word (16 bits) and longword (32 bits). You 
  85. can  indicate  this  with a suffix  in  the  mnemonic  field.  The 
  86. suffixes are .b for byte,  .w for word and .l for  longword.  E.g. 
  87. asr.b d0  ,   asr.w   d0    , asr.l   d0. These instructions shift 
  88. data register d0 one place to the right.
  89. I  think  this is enough new stuff for today.  Next  time  I  will 
  90. explain  the  addressing  modes of the  68000.  If  you  have  any 
  91. comments  or  questions  on this  article,  please  write  to  the 
  92. correspondence address and I'll take your notes into account.
  93.  
  94. A good Motorola MC 68000 book is:
  95. The Motorola 68000 programming guide,  which unfortunately is  not 
  96. available in the stores.
  97. Further there are a number of books on the 68000.  I would like to 
  98. mention the book written by Lance Leventhal & Gerry Kane,  which I 
  99. think gives good value for its money.  Another good book is  Steve 
  100. Williams' "Programming the 68000".
  101.  
  102.  
  103.