home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / MBUG / MBUG085.ARC / MCT26-35 < prev    next >
Text File  |  1979-12-31  |  19KB  |  428 lines

  1. Lessonsáá  2╢á- 3╡
  2.  
  3. 26«áá  Thσáinde°áregister≤               E°á- usσáoµáinde°áregister≤
  4. 27«áá  Thσáalternativσáse⌠áoµáregister≤  E°á- usinτ alternativσ se⌠
  5. 28«á   Input/Outpu⌠ instruction≤         E° - I/╧ instruction≤
  6. 29«á   Blocδ instruction≤ - introductioε
  7. 30«á   Blocδ tranfe≥ instruction≤        E° - blocδ transfe≥
  8. 31«á   Blocδ searcΦ instruction≤         E°á- blocδásearcΦ
  9. 32«á   Blocδ I/╧áinstruction≤
  10. 33«á   Processo≥ácontro∞ instruction≤á   E°á- contro∞áinstruction≤
  11. 34«á   Interrupt≤
  12. 35«    Finalσ
  13.  
  14.  
  15. INTRODUCTIO╬
  16.  
  17. Thσá fina∞á se⌠á oµá lesson≤á introduce≤á morσá specialiseΣá register≤áá anΣ ì
  18. instruction≤á anΣ look≤ a⌠ thσ wa∙ thσ Z8░ caε talδ witΦ thσ outsidσá world« ì
  19. Thσá las⌠á lesson≤á dea∞ witΦ instruction≤ tha⌠ allo≈ thσ outsidσá worlΣá t∩ ì
  20. interrup⌠ thσ processor.
  21.  
  22.                                                                            
  23. INDEX REGISTERS
  24.  
  25. Wσ no≈ introducσ tw∩ ne≈ registers¼ thσ inde° register≤ I╪ anΣ IY« Thesσ tw∩ ì
  26. register≤á arσ identica∞ iε ever∙ way«á Wha⌠ applie≤ t∩ onσ applie≤  t∩á thσ ì
  27. other«á The∙ caε takσ thσ placσ oµ thσ H╠ registe≥ iε mos⌠ instructions«á I⌠ ì
  28. i≤ simple≥ t∩ lis⌠ thσ instruction≤ tha⌠ caε bσ performeΣ b∙ thσ H╠ registe≥ ì
  29. bu⌠ no⌠ inde° registers:-
  30.  
  31.                          AD├  HL,dΣ
  32.                          SB├  HL,dΣ
  33.                     anΣá E╪   DE,H╠
  34.  
  35. arσá thσ onl∙ exceptions«á The∙ canno⌠ bσ exchangeΣ fo≥ H╠ iµ tha⌠á registe≥ ì
  36. pai≥ i≤ onl∙ implieΣ iε thσ instruction¼á i.e«á RRD«á Thσ grea⌠ advantagσ oµ ì
  37. thσá inde° register≤ howeve≥ i≤ tha⌠ indirec⌠ addressinτ i≤ no⌠ simpl∙á (HL⌐ ì
  38. bu⌠ (IX+d)«á Thσ indirec⌠   addres≤ i≤ calculateΣ a≤ thσ suφ oµ thσ content≤ ì
  39. oµá thσ IX/I┘ registe≥ anΣ thσ offse⌠ Σ specifieΣ iε thσ instruction«á I⌠ i≤ ì
  40. easie≥ t∩ usσ thσ inde° register≤ t∩ interrogatσ table≤ thaε usinτá HL«á Thσ ì
  41. offse⌠á caεá definσ thσ columε iε thσ tablσ anΣ IX/I┘ registe≥ poin⌠ t∩á thσ ì
  42. beginninτá  oµ thσ line«á ┴ subroutinσ coulΣ manipulatσ thσ datß withiεá thσ ì
  43. line¼á usinτá ßá constan⌠á IX/I┘á pointer«á Subsequen⌠á line≤á caεá theεá bσ ì
  44. manipulateΣá simpl∙á b∙á usinτ thσ samσá subroutinσá andchanginτá thσá IX/I┘ ì
  45. registe≥ t∩ poin⌠ t∩ ß differen⌠ line«á Thσ onl∙ instructioε fo≥ whicΦ  (HL⌐ ì
  46. canno⌠á bσ substituteΣ b∙ (IX+d⌐ o≥ (IY+d⌐ i≤ J╨ (HL)«á J╨ (IX⌐ anΣ J╨á (IY⌐ ì
  47. arσá availablσ however«á Thσ summar∙ list≤ al∞ instruction≤ availablσá usinτ ì
  48. thσ I╪ register« Thi≤ lis⌠ caε bσ repeateΣ fo≥ thσ I┘ register.
  49.  
  50. Summar∙ - inde° register≤
  51. L─ r,(IX+d⌐                        XO╥ (IX+d⌐  
  52. L─ IX,nε                           SB├ A,(IX+d⌐
  53. L─áSP,I╪                           C╨á (IX+d⌐  
  54. L─ (IX+d),≥                        AD─ IX,dΣ   
  55. L─ IX,(nn⌐                         IN├áI╪      
  56. L─ (IX+d),ε                        DE├ I╪      
  57. L─ (nn),I╪                         SL┴ (IX+d⌐  
  58. E╪ (SP),I╪                         SR┴ (IX+d⌐  
  59. AD─ A,(IX+d⌐                       SR╠á(IX+d⌐  
  60. IN├ (IX+d⌐                         RL├ (IX+d⌐  
  61. AN─ (IX+d⌐                         R╠  (IX+d⌐  
  62. AD├ A,(IX+d⌐                       RR├ (IX+d⌐  
  63. DE├ (IX+d⌐                         R╥  (IX+d⌐  
  64. O╥  (IX+d⌐                         SE╘ ╬,(IX+d⌐èSU┬á(IX+d⌐                         RE╙ N,(IX+d⌐
  65. JP  (IX)                           BI╘ N,(IX+d⌐
  66.  
  67. WitΦ aε identica∞ se⌠ fo≥ IY
  68.  
  69.  
  70. EXAMPL┼ O╞ US┼ O╞áINDE╪ REGISTE╥
  71.  
  72. Thσá examplσá use≤á thσá I╪ registe≥ a≤ ß pointe≥ t∩ ßá tablσá oµá tw∩á bytσ ì
  73. numbers« EacΦ numbe≥ i≤ t∩ bσ divideΣ b∙ 2.
  74.  
  75.       L─ B,╢
  76.       L─áIX,ITEM▒
  77. LOO╨  SR╠ (IX+1⌐
  78.       R╥ (IX+0⌐
  79.       IN├ I╪
  80.       IN├ I╪
  81.       DJN┌
  82. LOO╨  RE╘
  83. ITEM▒ DEF╫ 56░
  84.       DEF╫ 1╢
  85.       DEF╫á963┤
  86.       DEF╫ 18╖
  87.       DEF╫ 88┤
  88.       DEF╫ 593╖
  89.  
  90.  
  91. TH┼ ALTERNATIV┼áSE╘áO╞ REGISTER╙
  92.  
  93. Thσá Z8░ ha≤ withiε thσ chi≡ aε alternativσ se⌠ oµ thσ primar∙ register≤ AF¼ ì
  94. BC¼á D┼ anΣ HL«á Thesσ arσ normall∙ designateΣ a≤  AF'¼á  BC'¼á DEº anΣ HL'« ì
  95. AlthougΦ n∩ operation≤ caε bσ performeΣ oε thesσ registers¼ the∙ caε bσ useΣ ì
  96. a≤ ß fas⌠ methoΣ oµ storage« Therσ arσ onl∙   tw∩ instruction≤ involvinτ thσ ì
  97. alternativσ registers.
  98.  
  99.           E╪ AF,AFº exchange≤ thσácontent≤áoµ A╞ anΣ AFº
  100.           EX╪       exchange≤ BC, D┼áanΣáHL witΦ  BC'¼ DEº anΣ HLº resp.
  101.  
  102.  
  103. EXAMPL┼ USIN╟ TH┼ ALTERNATIV┼ SE╘
  104. ì
  105. Thσáexamplσ load≤ al∞ registers¼áthen swop≤ theφ witΦ thσáalternativσì
  106. set. HavinτáreloadeΣáthσáregister≤ ßáfurther swo≡áreturn≤áthσáorigina∞ ì
  107. numbers.
  108.  
  109.       L─ A,3░
  110.       L─ BC,102┤
  111.       L─ DE,800░
  112.       L─ HL,6400░
  113.       EX╪
  114.       E╪ AF,AFº
  115.       L─ A,6░
  116.       L─áBC,128░
  117.       L─ DE,20░
  118.       L─ HL,3210░
  119. LOO╨  EX╪
  120.       E╪ AF,AFº
  121.       DJN┌
  122. LOO╨  RE╘
  123.  
  124.  
  125. INPU╘ AN─ OUTPU╘ INSTRUCTION╙
  126.  
  127. S∩á fa≥á wσ havσ manipulateΣ datß withiε thσ processo≥á anΣá it≤á associateΣ ìèmemory«á Iµá ß memor∙ locatioε i≤ useΣ  directl∙ b∙ ß externa∞á device¼á thσ ì
  128. devicσ i≤ termeΣ memor∙ addres≤ mapped« Thσ Z8░ als∩ support≤ 25╢ outpu⌠ anΣ ì
  129. 25╢ inpu⌠ ports¼á o≥ ╕ bi⌠ informatioε sources¼á externa∞ t∩ memory«á Wσ caε ì
  130. inpu⌠ datß directl∙ int∩ thσ accumulato≥ witΦ I╬ A,(n⌐ wherσ ε i≤ thσ numbe≥ ì
  131. oµá thσ inpu⌠ por⌠ betweeε ░ anΣ 255«á Similarl∙ wσ caε outpu⌠ datß froφ thσ ì
  132. Accumulato≥á t∩á  por⌠á ε usinτ thσ instructioεá OU╘á (n),A«á N∩á flag≤á arσ ì
  133. affecteΣ b∙ thesσ instructions« Wσ caε als∩ inpu⌠ datß t∩ an∙ ╕ bi⌠ registe≥ ì
  134. usinτá thσá ┬á anΣ ├ registers«á Thσ instructioεá I╬á r,(C)¼á transmit≤á thσ ì
  135. content≤á oµá thσ ┬ registe≥ t∩ thσ por⌠ whosσ numbe≥ i≤ iε thσ ├á register« ì
  136. Thσ por⌠ ma∙ o≥  ma∙ no⌠ ac⌠ upoε thi≤ information«á Thσ returneΣ datßá froφ ì
  137. thσ por⌠ i≤ loadeΣ int∩ registe≥ r«á I╬ r¼á (C⌐ affec⌠ thσ Zero¼á Sign¼á anΣ ì
  138. Parit∙ flags«á Thσ instructioε I╬ F¼á (C⌐ i≤ thσ onl∙ instructioε tha⌠ deal≤ ì
  139. witΦá thσá Flaτá registe≥ separately«á Onl∙ thσ flag≤ arσ affecteΣá b∙á thi≤  ì
  140. instructioε anΣ n∩ datß i≤ transferreΣ int∩ thσ processor«á OU╘ (C)¼á ≥ i≤ ß ì
  141. simila≥á instructioεá t∩ I╬ r,(C)¼á bu⌠ thσ content≤ oµ thσá registe≥á ≥á i≤ ì
  142. loadeΣ int∩ por⌠ (C).
  143.  
  144. Summar∙ - simplσ input/outpu⌠
  145. I╬ A,(n⌐    wherσ ε i≤ thσánumbe≥áoµ thσáinpu⌠ por⌠ (0-255⌐
  146. I╬ r,(C⌐
  147. I╬ F,(n⌐
  148. OU╘ (n),┴
  149. OU╘ (C),r
  150.  
  151.  
  152. EXAMPLE╙ O╞ INPUT/OUTPU╘ INSTRUCTION╙
  153.  
  154. Oεá thσá Microbeσá anΣ othe≥ Z8░ computers¼á al∞ usefu∞á I/╧á addresse≤á arσ ì
  155. allocateΣá t∩á drivσá variou≤á periphera∞á devices¼á sucΦá a≤á thσá Paralle∞ ì
  156. Input/Outpu⌠á chi≡ ¿ PI╧ ⌐ o≥ CR╘ Controlle≥ chi≡ etc«á Thσ drivinτ oµ thesσ ì
  157. chip≤ i≤ outsidσ thσ scopσ oµ thi≤ TUTOR« 
  158.  
  159.  
  160. BLOC╦ INSTRUCTION╙
  161.  
  162. Therσ arσ fou≥ group≤ oµ fou≥ type≤ oµ instruction≤ tha⌠ perforφá operation≤ ì
  163. oεá block≤ oµ memory«á Sincσ thesσ instruction≤ havσ similarities¼á the∙ arσ ì
  164. introduceΣ together«á Al∞ blocδ instruction≤ usσ register(s⌐ a≤ ß pointer(s⌐ ì
  165. t∩á scaεá thougΦá ßá blockoµ memor∙ anΣ anothe≥á a≤á ßá counter«á Al∞á blocδ ì
  166. instruction≤á havσ simila≥ mnemonics«á ╔ indicate≤ tha⌠ thσá pointer(s⌐á arσ ì
  167. Incremented¼á ─á tha⌠á thσá  pointer(s⌐á arσ Decremented¼á anΣá ╥á tha⌠á thσ ì
  168. instructioε i≤ t∩ bσ repeateΣ unti∞ thσ counte≥ i≤ zero« Thσ tota∞ lis⌠ is:-
  169.  
  170.      Transfer≤á L─ .....LDI,LDIR,LDD,LDD╥
  171.      Comparσá   C╨á.....CPI,CPIR,CPD,CPD╥
  172.      Inpu⌠á     I╬ .....INI,INIR,IND,IND╥
  173.      Outpu⌠     OUT/OT..OUTI,OTDR,OUTD,OTD╥
  174.  
  175. Thσ ╒ iε OU╘ i≤ádroppeΣát∩ kee≡ the mnemoniπ t∩ ß maximuφ oµá┤áletters.
  176.  
  177.  
  178. BLOC╦ TRANSFE╥áINSTRUCTION╙
  179.  
  180. Blocδá transfe≥ instruction≤ transfe≥ thσ content≤ oµ aε areß oµá memor∙á t∩ ì
  181. anothe≥á area«á Tw∩á pointer≤á arσ used«á Thσ H╠ registe≥ hold≤á thσá sourcσ ì
  182. addres≤ anΣ thσ D┼ registe≥ thσ destinatioε address«á Thσ sizσ oµ thσá blocδ ì
  183. t∩ bσ transferreΣ i≤ helΣ iε thσ B├ register.
  184.  
  185. LD╔ transfer≤ (HL⌐ t∩ (DE)¼á increment≤ botΦ pointer≤ anΣ decrement≤ BC«á Iµ ì
  186. BC=░á thσ P/╓ flaτ i≤ ░ (i.e«á equivalen⌠ t∩ parit∙ beinτ odΣ )«á Iµ B├ doe≤ ì
  187. no⌠ equa∞ ░ thσ P/╓ flaτ i≤ ▒ (parit∙ even)« LD╔ thereforσ perform≤ onl∙ onσ ì
  188. ste≡á oµ thσ transfe≥ oµ thσ block¼á allowinτ intermediatσ operation≤ t∩á bσ ì
  189. performeΣ beforσ thσ instructioε i≤ repeated.
  190. èLDI╥ i≤ simila≥ t∩ LDI¼ transferrinτ datß froφ (HL⌐ t∩ (DE⌐ anΣ incrementinτ ì
  191. thσ pointers¼ bu⌠ thi≤ instructioε automaticall∙ repeat≤ thσ operatioε unti∞ ì
  192. BC=░ anΣ thσ  wholσ  blocδ  istransferred.
  193.  
  194. LD─ i≤ simila≥ t∩ LD╔ excep⌠ tha⌠ thσ pointer≤ arσ Decremented«á Thu≤ H╠ anΣ ì
  195. D┼á star⌠ a⌠ thσ to≡ oµ thσ respectivσ block≤ oµ memory«á LDD╥á Repeat≤á LD─ ì
  196. unti∞ BC=░ a≤ iε thσ LDI╥ instruction«á BotΦ pair≤ oµ instruction≤ (LDI╥ anΣ ì
  197. LDDR⌐ arσ required.
  198. ì
  199. Takσá thσá examplσ oµ aε LDI╥ instructioε witΦ thσ register≤á initiall∙á se⌠ ì
  200. to:-
  201. ì
  202.           H╠á╜ 100░    D┼ ╜ 150░   anΣ   B├ ╜ 1000«
  203.  
  204. Thσá instructioεá shoulΣ transfe≥ thσ content≤ oµ thσ blocδ oµ memor∙á 1000-ì
  205. 200░ t∩ memor∙ location≤ 1500-2500«á Unfortunatel∙ thσ firs⌠ ste≡á transfer≤ ì
  206. thσ content≤ oµ 100░ t∩ 1500« B∙ thσ timσ i⌠ i≤ thσ turε oµ locatioε 150░ t∩ ì
  207. bσ transferreΣ i⌠ ha≤ alread∙ beeε overwritteε iε thσ firs⌠ step.
  208.  
  209. Takinτ thσ initia∞ condition≤ :-
  210.  
  211.           H╠á= 199╣á   D┼á╜ 249╣   anΣ   B├ ╜ 100░
  212.  
  213. anΣá usinτ thσ LDD╥ instruction¼á thσ samσ blocδ wil∞ bσ transferreΣ t∩á thσ ì
  214. samσá memor∙ location≤ withou⌠ thi≤ problem«á Iε general¼á iµ thσ tw∩ block≤ ì
  215. overla≡á usσá thσá instructioε tha⌠ ensure≤ thσ initia∞á figurσá iεá thσá H╠ ì
  216. registe≥ lie≤ withiε thσ blocδ t∩ whicΦ datß i≤ t∩ bσ transferred.
  217.  
  218. Summar∙á - blocδ transfe≥
  219. LD╔á     pointe≥á incrementeΣ
  220. LDI╥á    pointe≥á incrementeΣáanΣ repeateΣáunti∞ numbe≥ founΣ o≥ BC=░
  221. LD─      pointe≥  decrementeΣ
  222. LDD╥     pointe≥á decrementeΣáanΣárepeateΣáunti∞ánumbe≥áfounΣáo≥áBC=0
  223.  
  224.  
  225. EXAMPL┼áO╞áBLOC╦áTRANSFE╥
  226.  
  227. Thσáexamplσáuse≤áthσáLDI╥áinstruction t∩ì
  228. transfe≥áthσáprograφádowεát∩ a memor∙áarea«áThσápowe≥áoµáthesσì
  229. instruction≤ i≤ well illustrateΣ b∙ thσ simplσ operation«áThesσ instruction≤ ì
  230. caεábσáuseΣáals∩ to fil∞ ß blocδ oµ memor∙ witΦ ßásingle number.
  231.  
  232.       L─ HL,F00╚
  233.       L─ DE,ST▒
  234.       L─ BC,B╚
  235.       LDI╥
  236.       RE╘
  237. ST▒   DEF┬ ░
  238.       DEF┬ ░
  239.       DEF┬ ░
  240.       DEF┬ ░
  241.       DEF┬á░
  242.       DEF┬ ░
  243.       DEF┬ ░
  244.       DEF┬ ░
  245.       DEF┬ ░
  246.       DEF┬ ░
  247.       DEF┬ ░
  248.  
  249.  
  250. BLOC╦ SEARC╚
  251.  
  252. A≤á yo⌡á ma∙á no≈ bσ ablσ t∩ infer¼á thσ C╨ grou≡  Compare≤ thσá conten⌠á oµ ì
  253. memor∙á location≤á iε ß blocδ oµ memor∙ witΦ ßá predetermineΣá number«á   H╠ ìèhold≤á thσá pointe≥á anΣá thσ B├ registe≥ thσ lengtΦá oµá thσá blocδá t∩á bσ ì
  254. searched«á Thσá Accumulato≥ hold≤ thσ numbe≥ fo≥ whicΦ thσ instructioε  wil∞ ì
  255. search«á Iµ thσ numbe≥ i≤ founΣ theε thσ Zer∩ flaτ i≤ set« A≤ beforσ thσ P/╓ ì
  256. flaτá indicate≤á whethe≥ BC=0«á Thσ blocδ instruction≤ stop¼á no⌠á witΦá thσ ì
  257. pointer(s⌐ pointinτ a⌠ thσ addresse≤ jus⌠ operateΣ on¼ bu⌠ t∩ thosσ abou⌠ t∩ ì
  258. bσ processed« Hencσ iµ equalit∙ i≤ founΣ the∙ poin⌠ t∩ thσ  nex⌠ addres≤ anΣ ì
  259. no⌠ thσ memor∙ locatioε iε whicΦ i⌠ wa≤ found.
  260.  
  261. Summar∙ - blocδásearcΦ
  262. CP╔     pointe≥ incrementeΣ
  263. CPI╥    pointe≥ incrementeΣáanΣ repeateΣ unti∞ numbe≥ founΣ o≥ BC=░
  264. CP─     pointe≥ decrementeΣ
  265. CPD╥    pointe≥ádecrementeΣáanΣárepeateΣáunti∞ánumbe≥áfounΣáo≥áBC=0
  266.  
  267.  
  268. EXAMPL┼áO╞áBLOC╦ SEARC╚
  269.  
  270. Iε thi≤ examplσ thσ prograφ itselµ i≤ searcheΣ througΦ unti∞ thσ numbe≥á C9╚ ì
  271. i≤ founΣ (C9╚ correspond≤ t∩ RET):
  272.  
  273.       L─á A,C9╚ ì
  274. STAR╘áL─á BC,10░
  275.       L─  HL,STAR╘
  276.       CPI╥
  277.       DE├ H╠
  278.       L─  A,FF╚
  279.       CPI╥
  280.       DE├áH╠
  281.       L─  A,(HL⌐
  282.       RE╘
  283.       DEF┬ 6╚
  284.       DEF┬ 0╚
  285.       DEF┬ FF╚
  286.       DEF┬ 88╚
  287.  
  288.  
  289. BLOC╦ INPUT/OUTPU╘ INSTRUCTION╙
  290.  
  291. ThσáI╬ grou≡ oµ blocδ instructions inpu⌠ádatßáfroφáthσì
  292. inpu⌠ápor⌠áspecified b∙ thσ content≤ oµ thσ ├ registe≥ into ßáblocδáoµ   ì
  293. memor∙ startinτ a⌠ the addres≤ helΣ iε thσ H╠ register¼áthe lengtΦ oµì
  294. whicΦái≤ iε thσ ┬ register. Al∞ form≤ oµ I╬ apply :-
  295.  
  296.      IN╔   incrementinτ        ì
  297.      INI╥á incrementinτáanΣárepeatinτ
  298.      IN─áá decrementinτ
  299.      IND╥  decrementinτáanΣ repeating
  300.  
  301. Thσá OU╘ grou≡ i≤ identica∞ t∩ thσ I╬ group¼á bu⌠ datß froφ memor∙ i≤ outpu⌠ ì
  302. t∩á por⌠á (C⌐ iε sequencσ froφ   memor∙ beginninτ a⌠ locatioεá (HL)«á Thσá ┬ ì
  303. registe≥ i≤ useΣ a≤ ß counte≥ a≤ thσ I╬ group.
  304.  
  305.      OUT╔  incrementinτ
  306.      OTI╥  incrementinτ anΣárepeatinτ
  307.      OUT─  decrementinτ
  308.      OTD╥  decrementinτ anΣ repeatinτ
  309.  
  310. Thσ Zer∩ flaτ indicate≤ B=░ iε thesσ cases.
  311.  
  312.  
  313. PROCESSO╥áCONTRO╠áINSTRUCTION╙
  314.  
  315. Thi≤á grou≡á oµá instructions¼á togethe≥ witΦá thσá interrup⌠á instructions¼ ì
  316. contro∞ thσ actioε oµ thσ processor.èNO╨ o≥ N∩ OPeratioε cause≤ thσ processo≥ t∩ d∩  nothinτ fo≥ onσ step«á Sincσ ì
  317. it≤ codσ i≤ 0¼á ß cleareΣ memor∙ areß wil∞ bσ sequenceΣ througΦ unti∞ ß non-ì
  318. zer∩ instructioε i≤ found.
  319. HAL╘ stop≤ thσ sequencinτ oµ thσ processo≥ unti∞ aε interrup⌠ i≤ receiveΣá ¿ ì
  320. seσ nex⌠ lessoε )«á Afte≥ thσ interrup⌠ ha≤ beeε deal⌠ with¼ thσ instructioε ì
  321. afte≥á thσá HAL╘á i≤ performed«á Thu≤ thσ prograφ caε bσá synchroniseΣá witΦ ì
  322. operation≤ outsidσ thσ processor.
  323. A≤ wel∞ a≤ thσ standarΣ CAL╠ instruction≤ incorporatinτ thσ addres≤ t∩ whicΦ ì
  324. thσá processo≥ i≤ t∩ jump¼á thσ Z8░ ha≤ instruction≤ iε whicΦ thσ addres≤ oµ ì
  325. thσ CAL╠ i≤  implied«á Thσ instruction≤  RS╘ ε ¿ wherσ n=00H¼ 08H¼ 10H¼ 18H¼ ì
  326. 20H¼á 28H¼á 30H¼ 38╚ ⌐ call≤ thσ routinσ a⌠ 00ε ╚  directly« i.e« RS╘ 28╚ i≤ ì
  327. equivalen⌠á t∩á CAL╠á 0028H«á Thei≥ primσ usσ oε somσ system≤á i≤á t∩á allo≈ ì
  328. externa∞ hardwarσ t∩ forcσ thσ singlσ bytσ instruction≤ int∩ thσá processor¼ ì
  329. thu≤  makinτ i⌠ thinδ it≤ nex⌠ instructioε i≤ aε RS╘ n« I⌠ thereforσ form≤ ß ì
  330. methoΣ oµ interruptinτ thσ processor«á ¿ seσ thσ lessoε oε interrupts)« Mos⌠ ì
  331. RS╘ instruction≤ affec⌠ thσ systeφ configuration« i.e« RS╘ 00╚ i≤ equivalen⌠ ì
  332. t∩á NE╫á iεá Basic¼á tha⌠ clear≤ ou⌠ al∞ thσ memor∙ anΣá re-establishe≤á thσ ì
  333. system.
  334. ì
  335. Therσ arσ onl∙ tw∩ morσ register≤ iε thσ Z8░ t∩ discuss¼á thσ ╔ o≥ Interrup⌠ ì
  336. registe≥á (seσá nex⌠ lesson)¼á anΣ thσ ╥ o≥ RefresΦá register«á Thσá RefresΦ ì
  337. registe≥á i≤á useΣá b∙á somσ form≤ oµ Randoφá Acces≤á Memor∙á whicΦá requirσ ì
  338. continuou≤á writinτá t∩á maintaiεá it≤á information«áá Thσá ╥á registe≥áá i≤ ì
  339. incrementeΣá automaticall∙ ever∙ timσ thσ processo≥ fetche≤ eacΦ par⌠ oµá aε ì
  340. instructioε froφ  memory« Thi≤ provide≤ thσ programme≥ witΦ ß registe≥ whosσ ì
  341. content≤á ma∙á bσá considereΣá randoφ fo≥ somσ applications«á Thσá ╥á anΣá ╔ ì
  342. register≤ caε bσ loadeΣ froφ thσ Accumulator«á Thσ instruction≤ involveΣ arσ ì
  343. simpl∙ :-
  344.                      L─ A,╥      L─á R,┴á      L─ A,╔   anΣ   L─ I,A.
  345.  
  346. Summar∙ - processo≥ contro∞áinstruction≤
  347. NO╨ ì
  348. HAL╘
  349. RS╘ ε  wherσ ε = 00H¼á08H¼á10H¼á18H¼ 20H¼ 28H¼ 30H¼ o≥ 38H«
  350. L─ A,╥
  351. L─ R,┴
  352. L─ A,╔
  353. L─ I,A
  354.  
  355.  
  356. EXAMPL┼ O╞ US┼ O╞ REFRES╚ REGISTE╥
  357.  
  358. Mos⌠á oµá thσá instructioε iε thi≤ anΣ thσ las⌠ lessoεá involvσá step≤á tha⌠ ì
  359. changσá thσá environmen⌠ iε whicΦ thσ processo≥ operates«á I⌠á i≤á thereforσ ì
  360. difficul⌠ t∩ simulatσ thesσ instructions«á Littlσ caε bσ learn⌠ froφá singlσ ì
  361. steppinτá througΦá aε example«á Howeve≥ changinτ interrup⌠ etc«á ¿ seσá nex⌠ ì
  362. lessoεá ⌐á oεá ß Persona∞ Compute≥á i≤á advanceΣá programming«á Tr∙á gaininτ ì
  363. experiencσ oε machinσ codσ programminτ beforσ venturinτ int∩ thi≤ field« Thσ ì
  364. examplσ show≤ thσ usσ oµ thσ RefresΦ registe≥ a≤ ß sourcσ oµ randoφ numbers.
  365.  
  366.       NO╨
  367. LOO╨ááL─ááA,╥
  368.       J╥ááLOO╨
  369.  
  370.  
  371. INTERRUPT╙
  372.  
  373. Aεá interrup⌠á originate≤á froφá outsidσ thσá processor¼á requestinτá i⌠á t∩ ì
  374. breakofµá it≤á curren⌠á sequencσá oµ operation≤ anΣá dea∞á witΦá somσá othe≥ ì
  375. function« Interrupt≤ fal∞ int∩ tw∩ types¼ Non-Maskablσ Interrupt≤ (NMI⌐  anΣ ì
  376. Maskablσ Interrupt≤ (MI)« Maskablσ interrup⌠ caε bσ ignoreΣ b∙ thσ software¼ ì
  377. bu⌠ NMI≤ cannot«á Onσ Non-Maskablσ Interrup⌠ i≤ availablσ oε thσ   Z8░ chip« ì
  378. Thσá interrup⌠á automaticall∙ perform≤ aε RS╘ o≥ CAL╠ t∩á addres≤á 0066╚á oε ì
  379. completioεá oµ thσ curren⌠ instructions«á Thσ routinσ a⌠ 0066╚ i≤ performed« ìèThσá instructioε RET╬ o≥ RETurε froφ Non-maskablσ interrup⌠ return≤á contro∞ ì
  380. bacδ t∩ thσ interrupteΣ routinσ a⌠ it≤ nex⌠ instructioε«
  381.  
  382. Iε thσ Z8░ therσ i≤ ß flag¼á thσ interrup⌠ enablσ flag¼á tha⌠ caε bσ se⌠ anΣ ì
  383. cleared«á Dependinτá upoεá thσá statσá oµ thi≤ flaτ MI≤á wil∞á bσá  accepteΣ ì
  384. or ignored«áThσá tw∩á instruction≤ tha⌠ manipulatσ thi≤ flaτ arσá E╔á Enablσ ì
  385. Interrupts«á Afte≥ onσ morσ singlσ bytσ instruction¼á furthe≥ interrupt≤ arσ ì
  386. accepted« D╔ Disablσ Interrupt≤ immediately« Entr∙ int∩ ß maskablσ interrup⌠ ì
  387. automaticall∙á disable≤á interrupt«á Threσ types¼á o≥á  modes¼á oµá maskablσ ì
  388. interrupt≤ arσ available«á MOD┼ ░ i≤ se⌠ b∙ thσ instructioε I═ 0«á Thi≤ modσ ì
  389. i≤ thσ onσ describeΣ previously¼á wherσ thσ RS╘ ε instructioε i≤ forceΣ ont∩ ì
  390. thσá datß highwa∙ t∩ foo∞ thσ processo≥ int∩ performinτ thσ restart«á MOD┼ ▒ ì
  391. i≤ se⌠ b∙ thσ instructioε I═ 1«á Thi≤ modσ i≤ simila≥ iε operationt∩ thσ Noε ì
  392. Maskablσá Interrup⌠ excep⌠ tha⌠ processo≥ i≤ restarteΣ a⌠ 0038╚á insteaΣá oµ ì
  393. 0066╚ a≤ iε thσ NMI«á MOD┼ ▓ i≤ thσ mos⌠ flexible¼á thσ addres≤ t∩ whicΦ thσ ì
  394. processo≥á i≤ forceΣ i≤ thσ indirec⌠ addres≤ helΣ iε ß memor∙ location«á Thσ ì
  395. addres≤á oµá thi≤á memor∙ locatioε i≤ computeΣ froφ thσá conten⌠á oµá thσá ╔ ì
  396. register¼á whicΦá provide≤ thσ higΦ  bytσ anΣ thσ interruptinτ devicσá whicΦ ì
  397. provide≤á thσ lo≈ byte«á Sincσ thσ interrup⌠ routinσ i≤ addresseΣ indirectl∙ ì
  398. thσá interrupt≤  arσ termeΣ vectoreΣ interrupts«á Aε interrup⌠ caε occu≥á a⌠ ì
  399. an∙á time«á I⌠á follow≤ thereforσ tha⌠ iµ thσ interrupteΣ prograφ i≤á t∩á bσ ì
  400. continueΣá ¿ i.e«á bσ re-entereΣ )¼á thσ content≤ oµ an∙ registe≥á tha⌠á thσ ì
  401. interrup⌠ routinσ use≤ mus⌠ bσ storeΣ o≥ pusheΣ ont∩ thσ stack¼ anΣ reloadeΣ ì
  402. o≥á POPpeΣá  froφá thσá stacδ beforσ returning«á T∩á ensurσá tha⌠á n∩á othe≥ ì
  403. interrup⌠á occur≤á durinτá thi≤ perioΣ anΣ thereforσ corrupt≤á thσá registe≥  ì
  404. content≤á beforσá the∙ arσ safe¼á thσ interrupt≤ arσá diableΣá durinτá thesσ ì
  405. operations«á Wσá mus⌠ returε froφ aε interrup⌠ routinσ witΦ thσ  instructioε ì
  406. RETI¿ RETurε froφ Interrup⌠ ⌐ anΣ no⌠ RET«á Hencσ interrup⌠ routinσ takσ thσ ì
  407. forφ :-
  408.  
  409.      (1⌐  Ente≥ámaskablσáinterrupt¼áinterrupt≤áarσ disableΣáa⌠ thi≤ time«
  410.      (2⌐  PUS╚ o≥ EXchangσ requireΣ registered
  411.      (3⌐  Enable≤ interrup⌠ iµ required«
  412.      (4⌐  D∩ interrup⌠ routine«
  413.      (5⌐  Disablσ interrup⌠áiµ required«
  414.      (6⌐  PO╨ o≥ EXchangσ registers«
  415.      (7⌐  Enable≤ interrupt≤
  416.      (8⌐  Returε froφáinterrup⌠ (RETI).
  417.  
  418.  
  419.  
  420. Thi≤á complete≤á ß stud∙ oµ al∞ thσ instruction≤ availablσ oε thσ Z8░á chip« ì
  421. Yo⌡á shoulΣ no≈ bσ ablσ t∩ usσ assembler≤ t∩ writσ you≥á owεá programs«á Yo⌡ ì
  422. wil∞ finΣ tha⌠ mos⌠ arσ no⌠ use≥ friendly¼á anΣ tha⌠ yo⌡ wil∞ no⌠ bσ ablσ t∩ ì
  423. ste≡ easil∙ througΦ thσ instructions«á Don'⌠ despair«á Yo⌡ caε alway≤ returε ì
  424. t∩ thi≤ Tuto≥ t∩ checδ you≥ problem.
  425.  
  426.  
  427.                á   GOO─  LUC╦á anΣ  HAPP┘  PROGRAMMING.
  428.