Computer archi&mp

10,006 views

Published on

Published in: Education
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
10,006
On SlideShare
0
From Embeds
0
Number of Embeds
5,129
Actions
Shares
0
Downloads
362
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Computer archi&mp

  1. 1. Computer Architecture and Microprocessor
  2. 2. Session I <ul><li>Number System </li></ul><ul><li>Conversions </li></ul><ul><li>Binary Operations </li></ul><ul><li>Code </li></ul><ul><li>Logic Gates </li></ul><ul><li>Boolean Algebra </li></ul><ul><li>Registers & Counters </li></ul><ul><li>Computer Languages </li></ul>
  3. 3. Number System <ul><li>Systematic representation of data in Numerical Format </li></ul><ul><li>Decimal Number System  0 to 9 </li></ul><ul><li>Binary Number System  0 and 1 </li></ul><ul><li>Octal Number System  0 to 7 </li></ul><ul><li>Hexa Decimal Number System  0 to 9 and A to F </li></ul>
  4. 4. Decimal Number System <ul><li>Uses digits from 0 to 9. </li></ul><ul><li>Has a base of 10 </li></ul><ul><li>Value of digit corresponds to its position in the number </li></ul><ul><li>number X (base) position-1 </li></ul><ul><li>Example : </li></ul><ul><li>495 10 , 84 10 </li></ul>
  5. 5. Binary Number System <ul><li>Computer uses the Binary Number System </li></ul><ul><li>Consists of numbers 0 and 1 </li></ul><ul><li>Bit ( B inary dig it ) </li></ul><ul><li>Byte (8 - bits) </li></ul><ul><li>Example: </li></ul><ul><ul><ul><ul><ul><li>1010 2 , 1110 2 </li></ul></ul></ul></ul></ul>
  6. 6. Octal Number System <ul><li>Uses the digits from 0 to 7. </li></ul><ul><li>Has a base of 8 </li></ul><ul><li>can be represented by a group of 3 bits </li></ul><ul><li>Example: </li></ul><ul><li>123 8 , 435 8 </li></ul>
  7. 7. Hexa Decimal Number System <ul><li>Uses the digits from 0 to 15. </li></ul><ul><li>Numbers from 10 to 15 represented by alphabets A through F </li></ul><ul><li>Has a base of 16 </li></ul><ul><li>Can be represented by a group of 4 bits. </li></ul><ul><li>Example: </li></ul><ul><li>B3A1 16 , 98C 16 </li></ul>
  8. 8. Number System Table 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Hexa Decimal Number System Octal Number System Binary Number System Decimal Number System
  9. 9. Conversion of decimal Number to Hexadecimal Number <ul><li>To convert, divide the decimal number by 16 successively </li></ul><ul><li>Example </li></ul><ul><li>To convert 540 to decimal </li></ul><ul><li>16 540 </li></ul><ul><li>16 33 -12 </li></ul><ul><li>2 - 1 </li></ul><ul><li>The decimal equivalent of 540 10 = 21C 16 </li></ul>
  10. 10. Conversion from Hexadecimal to Decimal <ul><li>Multiply the digits of the number by the powers of 16 and add </li></ul><ul><li>Example </li></ul><ul><li>To convert 21C 16 to its decimal equivalent </li></ul><ul><li>2 1 C </li></ul>C X16 0 = 12 X 1 = 12 1 X16 1 = 1 X 16 = 16 2 X16 2 = 2 X 256= 512 540
  11. 11. Conversion of Hexadecimal to Binary Number <ul><li>The binary equivalent of each digit is used </li></ul><ul><li>Example </li></ul><ul><li>To convert 5B 16 to binary equivalent: </li></ul><ul><li>5 B </li></ul><ul><li>01011011 2 </li></ul><ul><li>To convert B316 to binary equivalent: </li></ul><ul><li>B 3 </li></ul><ul><li>10110011 2 </li></ul>
  12. 12. Conversion of Binary to Decimal Number <ul><li>Sum of product of each digit with 2 raised to the power of positional value </li></ul><ul><li>Example: </li></ul><ul><li>To find the decimal equivalent of 1011 2 : </li></ul>
  13. 13. Conversion from Octal to Decimal <ul><li>Multiply the digits of the number by the powers of 8 and add </li></ul><ul><li>Example </li></ul><ul><li>To convert 215 8 to its decimal equivalent </li></ul><ul><li>2 1 5 </li></ul>5 X 8 0 = 5 X 1 = 5 1 X 8 1 = 1 X 8 = 8 2 X 8 2 = 2 X 64= 128 141
  14. 14. 9’s Complement <ul><li>Difference of each digit of a number from 9 </li></ul><ul><li>Example: </li></ul><ul><li>To find 9’s complement of 54 : </li></ul><ul><li>9 9 </li></ul><ul><li>5 4 </li></ul><ul><li>4 5 </li></ul>
  15. 15. 10’s Complement <ul><li>Equivalent to the negative of a number </li></ul><ul><li>Obtained by adding 1 to the 9’s complement of a number </li></ul><ul><li>Example: </li></ul><ul><li>To find 10’s complement of 54 </li></ul><ul><li>= 9’s complement of 54 + 1 </li></ul><ul><li>= 45 + 1 </li></ul><ul><li>= 46 </li></ul>
  16. 16. 1’s Complement of binary number <ul><li>Similar to 9’s complement of decimal number </li></ul><ul><li>Obtained by subtracting each digit from 1 </li></ul><ul><li>Example </li></ul><ul><li>To find 1’s complement of 101 </li></ul><ul><li>1 1 1 </li></ul><ul><li>1 0 1 </li></ul><ul><li>0 1 0 </li></ul>
  17. 17. 2’s complement of a binary number <ul><li>Equivalent to 10’s complement of a decimal number </li></ul><ul><li>Represents the negative equivalent of that number </li></ul><ul><li>Example </li></ul><ul><li>To find the 2’s complement of 1010 </li></ul><ul><li>= 1’s complement of 1010 + 1 </li></ul><ul><li>= 0101 + 1 </li></ul><ul><li>= 0110 </li></ul>
  18. 18. Binary Subtraction <ul><ul><ul><ul><li>To subtract 1010 from 1100 </li></ul></ul></ul></ul><ul><li>Find 2’s complement of 1010 </li></ul><ul><li>Number : 1010 </li></ul><ul><li>1’s complement : 0101 </li></ul><ul><li>2’s complement : 0110 </li></ul><ul><li>Add 2’s complement of 1010 with 1100 </li></ul><ul><ul><ul><ul><ul><li>1100 </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>0110 </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>0010 </li></ul></ul></ul></ul></ul>
  19. 19. BCD <ul><li>Each digit is represented by four bits </li></ul>00010101 15 00010100 14 00010011 13 00010010 12 00010001 11 00010000 10 00001001 9 00001000 8 BCD Decimal Number 0111 7 0110 6 0101 5 0100 4 0011 3 0010 2 0001 1 0000 0 BCD Decimal Number
  20. 20. Gray Code <ul><li>Only one bit changes for each consecutive numbers </li></ul>1000 15 1001 14 1011 13 1010 12 1110 11 1111 10 1101 9 1100 8 Gray Code Decimal Number 0100 7 0101 6 0111 5 0110 4 0010 3 0011 2 0001 1 0000 0 Gray Code Decimal Number
  21. 21. ASCII Codes <ul><li>American Standard Code for Information Interchange </li></ul><ul><li>7 bit code </li></ul><ul><li>Represents upto 128 characters </li></ul><ul><li>First 3 bits-zone bits </li></ul><ul><li>Second 4 bits-numeric bits </li></ul>
  22. 22. ASCII Codes Character ASCII Code DLE 10 S0 0F S1 0E CR 0D FF 0C VT 0B LF 0A HT 09 BS 08 BEL 07 ACK 06 ENQ 05 EOT 04 ETX 03 STX 02 SOH 01 NUL 00 Character ASCII Code ! 21 SP 20 US 1F RS 1E GS 1D FS 1C ESC 1B SUB 1A EM 19 CAN 18 ETB 17 SYN 16 NAK 15 DC4 14 DC3 (X-off) 13 DC2 (Tape) 12 DC1 (X-on) 11
  23. 23. ASCII Code 1 31 0 30 / 2F . 2E - 2D , 2C + 2B * 2A ) 29 ( 28 ‘ 27 & 26 % 25 $ 24 # 23 “ 22 Character ASCII Code A 41 @ 40 ? 3F > 3E = 3D < 3C ; 3B : 3A 9 39 8 38 7 37 6 36 5 35 4 34 3 33 2 32 Character ASCII Code
  24. 24. U 55 T 54 S 53 R 52 Q 51 P 50 O 4F N 4E M 4D L 4C K 4B J 4A I 49 H 48 G 47 F 46 E 45 D 44 C 43 B 42 Character ASCII Code j 6B i 6A Characters ASCII h 69 g 67 f 66 e 65 d 64 c 63 b 62 a 61 - ( ) 5F ^ ( ) 5E ] 5D 5C [ 5B Z 5A Y 59 X 58 W 57 V 56
  25. 25. DEL 7F ~ 7E } 7D | 7C { 7B z 7A y 79 x 78 w 77 v 76 u 75 t 74 s 73 r 72 q 71 p 70 o 6F n 6E m 6D l 6C k 6B Character ASCII Code
  26. 26. ASCII -8 Code <ul><li>Uses 8 bit code </li></ul><ul><li>Represents upto 256 characters </li></ul><ul><li>First 4 bits-zone bits </li></ul><ul><li>Second 4 bits-numeric bits </li></ul>
  27. 27. Logic Gates <ul><li>NOT gate or Inverter </li></ul><ul><li>output is opposite of input </li></ul><ul><li>Truth Table </li></ul><ul><ul><ul><ul><ul><li>I/P 0/P </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>0 1 </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>1 0 </li></ul></ul></ul></ul></ul>I/P O/P
  28. 28. <ul><li>AND Gate </li></ul><ul><li>Truth Table </li></ul><ul><ul><ul><ul><ul><li>I/P1 I/P2 O/P </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>0 0 0 </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>0 1 0 </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>1 0 0 </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>1 1 1 </li></ul></ul></ul></ul></ul>I/P1 I/P2 O/P
  29. 29. <ul><li>NAND Gate </li></ul><ul><li>Truth Table </li></ul><ul><ul><ul><ul><ul><li>I/P1 I/P2 O/P </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>0 0 1 </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>0 1 1 </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>1 0 1 </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>1 1 0 </li></ul></ul></ul></ul></ul>I/P1 I/P2 O/P
  30. 30. <ul><li>OR Gate </li></ul><ul><li>Truth Table </li></ul><ul><li>I/P1 I/P2 O/P </li></ul><ul><li>0 0 0 </li></ul><ul><li>0 1 1 </li></ul><ul><li>1 0 1 </li></ul><ul><li>1 1 1 </li></ul>I/P1 I/P2 O/P
  31. 31. <ul><li>NOR Gate </li></ul><ul><li>Truth Table </li></ul><ul><li>I/P1 I/P2 O/P </li></ul><ul><li>0 0 1 </li></ul><ul><li>0 1 0 </li></ul><ul><li>1 0 0 </li></ul><ul><li>1 1 0 </li></ul>I/P1 I/P2 O/P
  32. 32. <ul><li>XOR Gate </li></ul><ul><li>Truth Table </li></ul><ul><li>I/P1 I/P2 O/P </li></ul><ul><li>0 0 0 </li></ul><ul><li>0 1 1 </li></ul><ul><li>1 0 1 </li></ul><ul><li>1 1 0 </li></ul>I/P1 I/P2 O/P
  33. 33. <ul><li>XNOR Gate </li></ul><ul><li>Truth Table </li></ul><ul><li>I/P1 I/P2 O/P </li></ul><ul><li>0 0 1 </li></ul><ul><li>0 1 0 </li></ul><ul><li>1 0 0 </li></ul><ul><li>1 1 1 </li></ul>I/P1 I/P2 O/P
  34. 34. Boolean Algebra <ul><li>Algebra of binary values(1 & 0) </li></ul><ul><li>Types of operations </li></ul><ul><ul><ul><ul><ul><li>OR (+) </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>AND ( . ) </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>NOT (- or ‘ ) </li></ul></ul></ul></ul></ul><ul><li>Minimizes the basic circuits to perform digital operations </li></ul>
  35. 35. Algebraic Theorems <ul><li>OR Laws </li></ul><ul><ul><li>A + 0 = A </li></ul></ul><ul><ul><li>A + 1 =1 </li></ul></ul><ul><ul><li>A + A = A </li></ul></ul><ul><ul><li>A + A = 1 </li></ul></ul><ul><li>AND Laws </li></ul><ul><ul><li>A . 0 = 0 </li></ul></ul><ul><ul><li>A . 1 = A </li></ul></ul><ul><ul><li>A . A = A </li></ul></ul><ul><ul><li>A . A = 0 </li></ul></ul>
  36. 36. <ul><li>Laws of Complementation </li></ul><ul><li>A = A </li></ul><ul><li>1 = 0 </li></ul><ul><li>0 = 1 </li></ul><ul><li>If A=0, then A =1 </li></ul><ul><li>If A=1, then A = 0 </li></ul><ul><li>Commutative Laws </li></ul><ul><li>A + B = B + A </li></ul><ul><li>A .B = B .A </li></ul><ul><li>Associative Laws </li></ul><ul><li>(A + B) + C = A + (B + C) = A + B + C </li></ul><ul><li>(A.B).C = A.(B.C) = A.B.C </li></ul>
  37. 37. <ul><li>Distributive Laws </li></ul><ul><li>A . (B+C) = A .B + A .C </li></ul><ul><li>A + B.C = (A + B) . (A + C) </li></ul><ul><li>Other Expressions </li></ul><ul><li>A + AB = A </li></ul><ul><li>A . (A + B) = A </li></ul><ul><li>A + AB = A + B </li></ul><ul><li>A . (A + B) = AB </li></ul><ul><li>AB + AB = A </li></ul><ul><li>(A + B)(A + B) = A </li></ul><ul><li>AB + AC = (A + C) . (A + B) </li></ul><ul><li>(A + B) ( A + C) = AC + AB </li></ul><ul><li>AB + AC + BC = AB + AC </li></ul><ul><li>(A + B)(A + C)(B + C) = (A + B)(A + C) </li></ul>
  38. 38. Half Adder <ul><li>Has two inputs (the bits to be summed) </li></ul><ul><li>Has two outputs (the sum bit and the carry bit) </li></ul>AB CD 00 01 10 11 00 10 10 01
  39. 39. Full Adder – Truth Table a n b n c n   s n c n+1 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1
  40. 40. 7 Segment LED Display
  41. 42. 7 Segment LED Display – Truth Table   0 0 0 0 0 1 0 0 0 1 2 0 0 1 0 3 0 0 1 1 4 0 1 0 0 5 0 1 0 1 6 0 1 1 0 7 0 1 1 1 8 1 0 0 0 9 1 0 0 1     1 1 1 1 1 1 0 0 1 1 0 0 0 0 1 1 0 1 1 0 1 1 1 1 1 0 0 1 0 1 1 0 0 1 1 1 0 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1   INPUTS X Y Z W A B C D E F G OUTPUT L E G A L   D I G I T S 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1   1 0 0 1 1 1 1 1 0 0 1 1 1 1 1 0 0 1 1 1 1 1 0 0 1 1 1 1 1 0 0 1 1 1 1 1 0 0 1 1 1 1     E R R O R
  42. 43. TTL Circuit <ul><li>Stands for transistor - transistor logic. </li></ul><ul><li>Operates between cut-off and saturation. </li></ul><ul><li>Advantages: </li></ul><ul><ul><li>Speed </li></ul></ul><ul><ul><li>good fan – in and fan – out </li></ul></ul><ul><ul><li>easy interface with other digital circuitry </li></ul></ul>
  43. 44. Flip Flop <ul><li>Stores a binary digit </li></ul><ul><li>Stable till a signal switches it </li></ul><ul><li>Types of Types of flip flop </li></ul><ul><ul><li>S-R flip flop </li></ul></ul><ul><ul><li>J-K flip flop </li></ul></ul><ul><ul><li>D flip flop </li></ul></ul><ul><ul><li>T flip flop </li></ul></ul>
  44. 45. Registers <ul><li>Group of flip-flops </li></ul><ul><li>Connected in parallel </li></ul><ul><li>D flip-flop commonly used </li></ul><ul><ul><ul><ul><li>Shift Register </li></ul></ul></ul></ul><ul><li>Shifts content unchanged </li></ul><ul><li>Temporary storage </li></ul><ul><li>Types: </li></ul><ul><ul><ul><ul><ul><li>Serial-in, serial-out </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Serial-in, parallel-out </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Parallel in, serial-out </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Parallel in, parallel out </li></ul></ul></ul></ul></ul>
  45. 46. Counters <ul><li>Counts no. of pulses </li></ul><ul><li>Modulus of Counter </li></ul><ul><ul><li>Binary Counter </li></ul></ul><ul><ul><li>Decade Counter </li></ul></ul><ul><ul><li>Pre settable Counter </li></ul></ul><ul><ul><ul><ul><ul><li>Binary Counter </li></ul></ul></ul></ul></ul>CLK 3 2 1 0 J k Q Q J k Q Q J k Q Q J k Q Q
  46. 47. <ul><li>Types of Counters </li></ul><ul><ul><ul><ul><ul><li>Up Counter </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Down Counter </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Up-Down Counter </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Controlled Counter </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Ring Counter </li></ul></ul></ul></ul></ul>Synchronous Asynchronous
  47. 48. Computer Languages <ul><li>Machine Language </li></ul><ul><li>– 0 and 1 </li></ul><ul><li>Assembly Language </li></ul><ul><li>– mnemonics </li></ul><ul><li>– assembler </li></ul><ul><li>High Level Language </li></ul><ul><li>– English like language </li></ul><ul><li>– Interpreters and Compilers </li></ul>
  48. 49. Execution of Assembly Language program <ul><li>One to One Translation </li></ul>Source Program Assembler Object Program Loader Floppy Disk Floppy Disk
  49. 50. Execution of High Level Language Source Code Translator Object Code 1 Object Code 2 Object Code 3 <ul><li>One to Many Translation </li></ul>
  50. 51. Compiler & Interpreter <ul><li>Interpreter translates line by line </li></ul><ul><li>- Slower </li></ul><ul><li>Compiler translates the entire code </li></ul><ul><li>- faster </li></ul>
  51. 52. Session II <ul><li>Microprocessor – an Introduction </li></ul><ul><li>General Architecture of Microprocessor </li></ul><ul><li>Memory </li></ul><ul><li>I/O </li></ul><ul><li>Architecture of 8085 Microprocessor </li></ul>
  52. 53. Microprocessor – An Introduction <ul><li>Programmable Logical device </li></ul><ul><li>Functionality </li></ul><ul><ul><li>manipulates data </li></ul></ul><ul><ul><li>Controls timing of various operations </li></ul></ul><ul><ul><li>communicates with peripherals </li></ul></ul><ul><li>Applications </li></ul><ul><ul><li>Automation & Control </li></ul></ul>
  53. 54. Architecture & Operations of MPU <ul><li>Architecture </li></ul><ul><li>- Logical design of microprocessor </li></ul><ul><li>Types of Operations </li></ul><ul><ul><li>Microprocessor initiated operations </li></ul></ul><ul><ul><li>Internal Data Operations </li></ul></ul><ul><ul><li>Peripheral initiated Operation </li></ul></ul>
  54. 55. Microprocessor initiated operations <ul><li>Communications Operations </li></ul><ul><ul><li>Memory Read </li></ul></ul><ul><ul><li>Memory Write </li></ul></ul><ul><ul><li>I/O Read </li></ul></ul><ul><ul><li>I/O Write </li></ul></ul><ul><li>Steps involved </li></ul><ul><ul><li>Location Identification </li></ul></ul><ul><ul><li>Transfer of data </li></ul></ul><ul><ul><li>Providing Timing or synchronization signals </li></ul></ul>
  55. 56. <ul><li>Requirement </li></ul><ul><li>Address Bus </li></ul><ul><ul><li>Unidirectional </li></ul></ul><ul><ul><li>Arbitrary number – (commonly used 16) </li></ul></ul><ul><ul><li>Capable of Addressing 2 n </li></ul></ul><ul><li>Data Bus </li></ul><ul><ul><li>Bidirectional </li></ul></ul><ul><ul><li>Decides the range of data being handled </li></ul></ul><ul><ul><li>Determines the word length and the register size </li></ul></ul>
  56. 57. <ul><li>Control Bus </li></ul><ul><ul><li>A number of Single lines </li></ul></ul><ul><ul><li>Provides timing signals </li></ul></ul><ul><li>Communication Process </li></ul><ul><li>To Read an instruction </li></ul><ul><ul><li>Location is identified by placing the address in Address Bus </li></ul></ul><ul><ul><li>A pulse for initiating a READ is sent </li></ul></ul><ul><ul><li>Data Bus brings the data to MPU </li></ul></ul>
  57. 58. Internal Data Operations <ul><li>Processing of Data and its Storage </li></ul><ul><ul><li>Arithmetic & Logical Operation </li></ul></ul><ul><ul><li>Condition Testing </li></ul></ul><ul><ul><li>Order of Execution </li></ul></ul><ul><ul><li>Storing of Data </li></ul></ul><ul><li>Requirement </li></ul><ul><ul><li>Accumulator </li></ul></ul><ul><ul><li>Flag Register </li></ul></ul><ul><ul><li>General purpose Registers </li></ul></ul><ul><ul><li>Program Counter </li></ul></ul><ul><ul><li>Stack </li></ul></ul>
  58. 59. <ul><li>(8085 Microprocessor) </li></ul><ul><li>Accumulator </li></ul><ul><ul><li>Performs Arithmetic and logical Operations </li></ul></ul><ul><ul><li>8 bit Register </li></ul></ul><ul><li>Flag Register </li></ul><ul><ul><li>Used for Decision Making </li></ul></ul><ul><ul><li>5 Flags – Carry, Zero, Auxiliary Carry, Sign, Parity </li></ul></ul><ul><li>Program Status Word </li></ul>
  59. 60. <ul><li>Registers </li></ul><ul><ul><li>Stores Data during Execution </li></ul></ul><ul><ul><li>6 8-bit registers – B, C, D, E, H and L </li></ul></ul><ul><ul><li>Register Combination – BC, DE and HL </li></ul></ul><ul><li>Program Counter (PC) </li></ul><ul><ul><li>16 Bit Memory Pointer </li></ul></ul><ul><ul><li>Sequences the Execution </li></ul></ul><ul><li>Stack Pointer (SP) </li></ul><ul><ul><li>16 Bit Memory Pointer </li></ul></ul><ul><ul><li>Points to location in R/W Memory </li></ul></ul>
  60. 61. <ul><li>Peripheral initiated Operation </li></ul><ul><li>Operations initiated by external devices </li></ul><ul><li>Reset </li></ul><ul><ul><li>Program Counter is cleared </li></ul></ul><ul><li>Interrupt </li></ul><ul><ul><li>Normal Execution interrupted to execute Service Routine </li></ul></ul><ul><li>Ready </li></ul><ul><ul><li>Synchronizes MPU operations with Peripherals </li></ul></ul><ul><li>Hold </li></ul><ul><ul><li>Peripherals takes Control of Buses </li></ul></ul>
  61. 62. Memory <ul><li>Stores Binary Values </li></ul><ul><li>Types </li></ul><ul><ul><li>Read Write Memory (R/W M) </li></ul></ul><ul><ul><li>Read Only Memory (ROM) </li></ul></ul><ul><li>R/W Memory (Random Access Memory) </li></ul><ul><ul><li>Volatile </li></ul></ul><ul><ul><li>processes data </li></ul></ul><ul><ul><li>Types:- Static & Dynamic </li></ul></ul>
  62. 63. <ul><li>Static R/W Memory </li></ul><ul><ul><li>Flip-flops </li></ul></ul><ul><ul><li>Stored as Voltage </li></ul></ul><ul><li>Dynamic R/W Memory </li></ul><ul><ul><li>MOS Transistor </li></ul></ul><ul><ul><li>Stored as charges </li></ul></ul><ul><ul><li>Faster </li></ul></ul><ul><ul><li>Refreshing Circuit </li></ul></ul>
  63. 64. <ul><li>ROM Memory </li></ul><ul><ul><li>Non Volatile </li></ul></ul><ul><ul><li>Used for subroutines </li></ul></ul><ul><ul><li>Cheap & Dense </li></ul></ul><ul><ul><li>Types: - </li></ul></ul><ul><ul><ul><li>Masked ROM </li></ul></ul></ul><ul><ul><ul><li>PROM (Programmable Read Only Memory) </li></ul></ul></ul><ul><ul><ul><li>EPROM (Erasable Programmable Read Only Memory) </li></ul></ul></ul><ul><ul><ul><li>EEPROM (Electrically Erasable PROM) </li></ul></ul></ul>
  64. 65. <ul><li>Memory Organization </li></ul><ul><li>A memory requires: </li></ul><ul><ul><li>Chips containing Registers </li></ul></ul><ul><ul><li>Chip Select line </li></ul></ul><ul><ul><li>R/W line </li></ul></ul><ul><ul><li>Address lines </li></ul></ul><ul><ul><li>I/O lines </li></ul></ul><ul><li>Memory Map </li></ul><ul><ul><li>Assigning a unique address for each register </li></ul></ul>
  65. 66. <ul><li>Size of Memory </li></ul><ul><ul><li>Number of Register </li></ul></ul><ul><ul><li>Number of I/O lines </li></ul></ul>CS Control Logic A D D R E S S D E C O D E R R/W D 7 D 6 D 5 D 4 D 3 D 2 D 1 D 0 A 2 A 1 A 0 110 110 101 100 011 010 001 000
  66. 67. <ul><li>Input / Output </li></ul><ul><ul><li>Communicates to the external world </li></ul></ul><ul><li>Methods of Communication </li></ul><ul><ul><li>Peripheral or Direct I/O </li></ul></ul><ul><ul><li>Memory-Mapped I/O </li></ul></ul>
  67. 68. <ul><ul><li>Peripheral or Direct I/O </li></ul></ul><ul><ul><ul><li>IN/OUT Transfers data </li></ul></ul></ul><ul><ul><ul><li>8 Address Lines - 256 devices – Port Numbers </li></ul></ul></ul><ul><ul><ul><li>Uses Control Lines – IOW & IOR </li></ul></ul></ul><ul><ul><li>Memory-Mapped I/O </li></ul></ul><ul><ul><ul><li>16 Address Lines </li></ul></ul></ul><ul><ul><ul><li>Memory Map is shared </li></ul></ul></ul><ul><ul><ul><li>Uses Control Lines – MEMW & MEMR </li></ul></ul></ul>
  68. 69. <ul><li>Interfacing Devices </li></ul><ul><li>Tri-State Device </li></ul><ul><ul><li>3 stages – logic 1, logic 0 and high impedance </li></ul></ul><ul><li>Buffer </li></ul><ul><ul><li>Logic circuit which amplifies the current </li></ul></ul><ul><li>Latch </li></ul><ul><ul><li>a D flip-flop </li></ul></ul><ul><ul><li>Types :- </li></ul></ul>Transparent Latch Positive Edge Triggered D G Q Q D CK Q Q PR CLR
  69. 70. <ul><li>Decoder </li></ul><ul><ul><li>Displays an output based on the combination of input </li></ul></ul><ul><li>Encoder </li></ul><ul><ul><li>Outputs a code based on the input </li></ul></ul>Output Output Input Input 2 to 4 Decoder 2 to 4 Encoder
  70. 71. 8085 Microprocessor <ul><li>Features </li></ul><ul><ul><li>8 bit </li></ul></ul><ul><ul><li>Has 40 pins </li></ul></ul><ul><ul><li>Multiplexed Address/ Data Bus </li></ul></ul>
  71. 72. 8085 PINOUT X 1 X 2 RESET OUT SOD SID TRAP RST 7.5 RST 6.5 RST 5.5 INTR INTA AD 0 AD 1 AD 2 AD 3 AD 4 AD 5 AD 6 AD 7 V SS V cc HOLD HLDA CLK(OUT) RESET IN READY IO/M S1 RD WR ALE S0 A 15 A 14 A 13 A 12 A 11 A 10 A 9 A 8 1 2 3 4 5 6 7 8 9 10 11 12 14 14 15 16 17 18 19 20 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21
  72. 73. +5V GND Serial I/O Ports Interrupts & Externally Initiated Signals External Signal Acknowledgement Control And Status Signals 8085 Signals RESET CLK OUT OUT X1 X2 Vcc Vss ALE S0 S1 IO/M RD WR SID SOD TRAP RST 7.5 RST 6.5 RST 5.5 INTR READY HOLD RESET IN INTA HLDA High-Order Address Bus Multiplexed Address/Data Bus A 15 A 8 AD 7 AD 0
  73. 74. <ul><li>8085 Microprocessor Signal Groups </li></ul><ul><li>Address Bus </li></ul><ul><ul><li>UniDirectional </li></ul></ul><ul><ul><li>8 Higher Order Address Bus </li></ul></ul><ul><li>Multiplexed Address/Data Bus </li></ul><ul><ul><li>BiDirectional </li></ul></ul><ul><ul><li>Bus Multiplexing </li></ul></ul><ul><ul><li>Latching of Low - order Address Bus – ALE </li></ul></ul>
  74. 75. <ul><li>Control and Status Signal </li></ul><ul><li>ALE (Address Latch Enable) </li></ul><ul><ul><li>Generated in the beginning of each operation </li></ul></ul><ul><ul><li>Latches low - order address from the multiplexed bus </li></ul></ul><ul><li>RD (Read) </li></ul><ul><ul><li>Active low Control Signal </li></ul></ul><ul><ul><li>Reads from Memory / IO </li></ul></ul><ul><li>WR (Write) </li></ul><ul><ul><li>Active low Control Signal </li></ul></ul><ul><ul><li>Writes to selected Memory / IO </li></ul></ul>
  75. 76. IO/M RD 8085 WR A 15 A 8 ALE AD 7 AD 0 EN LATCH A 15 A 8 A 7 A 0 D 7 D 0 Data Bus MEMR MEMW IOR IOW Control Signals
  76. 77. <ul><li>IO/M </li></ul><ul><ul><li>High – IO Operation </li></ul></ul><ul><ul><li>Low – Memory Operation </li></ul></ul><ul><li>S 1 and S 0 </li></ul><ul><ul><li>Status Signal – rarely used </li></ul></ul><ul><ul><li>Identifies various operations </li></ul></ul><ul><ul><ul><ul><ul><li>S1 So Desc. </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>0 0 HALT </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>0 1 WRITE </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>1 0 READ </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>1 1 FETCH </li></ul></ul></ul></ul></ul>
  77. 78. <ul><li>Power Supply and Clock Frequency </li></ul><ul><ul><li>+5V power supply (Vcc) </li></ul></ul><ul><ul><li>3 MHz clock (X1 & X2) </li></ul></ul><ul><ul><li>CLK – Used as System Clock for other devices </li></ul></ul><ul><li>Interrupts and Externally Initiated Operations </li></ul><ul><ul><li>Interrupts transfer the program control to specific memory location </li></ul></ul><ul><li>INTR (Interrupt Request) </li></ul><ul><ul><li>A general-purpose interrupt . </li></ul></ul><ul><li>INTA (Interrupt Acknowledge) </li></ul><ul><ul><li>Acknowledges an interrupt </li></ul></ul>
  78. 79. <ul><li>RST 7.5 (Restart Interrupt) </li></ul><ul><ul><li>Highest priority Vectored Interrupt </li></ul></ul><ul><li>RST 6.5 (Restart Interrupt) </li></ul><ul><ul><li>Vectored interrupt with a priority less than RST 7.5, but more than RST 5.5 and INTR. </li></ul></ul><ul><li>RST 5.5 (Restart Interrupt) </li></ul><ul><ul><li>Vectored interrupt with the least priority among Restart Interrupts but more priority than INTR signals. </li></ul></ul><ul><li>TRAP (Input) </li></ul><ul><ul><li>A non-maskable restart interrupt. </li></ul></ul><ul><ul><li>highest priority of any interrupt. </li></ul></ul><ul><ul><li>Externally initiated signals are instantiated by an external device </li></ul></ul>
  79. 80. <ul><li>HOLD </li></ul><ul><ul><li>Indicates a peripheral’s request to use address and data buses. </li></ul></ul><ul><li>HLDA ( Hold Acknowledge) </li></ul><ul><ul><li>Acknowledges the HOLD request. </li></ul></ul><ul><li>READY </li></ul><ul><ul><li>Delays microprocessor’s operation to work in pace with the slow peripherals connected to it. </li></ul></ul><ul><li>RESET IN </li></ul><ul><ul><li>Sets program counter to zero </li></ul></ul><ul><ul><li>The buses are tri-stated and MPU is reset. </li></ul></ul><ul><li>RESET OUT </li></ul><ul><ul><li>Indicates MPU is being reset </li></ul></ul><ul><ul><li>Can be used to reset other devices. </li></ul></ul>
  80. 81. <ul><li>Serial I/O Ports </li></ul><ul><li>SID (Input) </li></ul><ul><ul><li>Serial input data Line </li></ul></ul><ul><ul><li>The data on SID is loaded into accumulator when a RIM instruction is executed. </li></ul></ul><ul><li>SOD (output) </li></ul><ul><ul><li>Serial output data line. </li></ul></ul><ul><ul><li>The output SOD is set or reset as specified by the SIM instruction. </li></ul></ul>
  81. 82. Address Buffer Temp Reg. (8) Arithmetic Logic Unit (ALU) (8) Flag (5) Flip-flops Data Address Buffer (8) Multiplexer Timing and Control CLK Reset GEN Control Status DMA Reg. Select Serial I/O Control SID Interrupt Control TRAP RST 7.5 RST 6.5 RST 5.5 INTA INTR SOD Ready RD WR ALE S 0 S 1 IO/M HLDA RESET OUT RESET IN HOLD A 15 – A 8 Address Bus AD 7 – AD 0 Address/Data Bus X1 x2 Register Array Accumulator (8) Instruction Decoder and Machine Cycle Encoding Instruction Register (8) W Temp. Reg. Z Temp. Reg. B Reg. D Reg. H Reg. Stack Program Counter C Reg. E Reg. L Reg. Address Latch (16)
  82. 83. Registers Has the Memory Pointer Address SP (Stack Pointer) 16 Bits Has the Program Pointer Address PC (Program Counter) 16 Bits H & L combined to form 16 Bits L 8 Bits H 8 Bits D & E combined to form 16 Bits E 8 Bits D 8 Bits B & C combined to form 16 Bits C 8 Bits B 8 Bits Arithmetic Operations Logical Operations A (Accumulator) 8 Bits
  83. 84. Flags D 7 D 6 D 5 D 4 D 3 D 2 D 1 D 0 CY P AC Z S Set – Carry Exists Reset – No Carry exists Carry CY Set – Even Reset – Odd Parity P Set – Carry From D3 to D4 Reset – No Carry From D3 to D4 Auxiliary Carry AC Set – Zero Reset – Non-Zero Zero Z Set – Positive Reset – Negative Sign S
  84. 85. <ul><li>Bus Timings </li></ul><ul><ul><li>Sequence of operations called instruction cycle executes an instruction </li></ul></ul><ul><ul><li>Instruction Cycle is divided into few basic machine cycles </li></ul></ul><ul><ul><li>Machine cycles are in turn divided into System Clock Period. </li></ul></ul><ul><li>Example: </li></ul><ul><ul><li>To fetch a data 10101010 from a location 2005H </li></ul></ul>
  85. 86. T1 T2 T3 CLK A 15 – A 8 AD 7 –AD 0 ALE IO/M RD Low -Order Memory Address Memory Contents M High –Order Memory Address
  86. 87. ALU Instruction Decoder Control Logic Address Bus Data Bus Memory B D H Stack Program Counter C E L
  87. 88. Instruction Set of 8085 <ul><li>Instruction </li></ul><ul><ul><li>A command to perform a given task. </li></ul></ul><ul><ul><li>A binary pattern designed inside a microprocessor to perform a specific function on a specified data. </li></ul></ul><ul><li>Instruction Set </li></ul><ul><ul><li>Entire group of instructions that determines what functions the microprocessor can perform. </li></ul></ul><ul><li>Parts of Instruction: </li></ul><ul><ul><li>Task to be performed – operation code (opcode) </li></ul></ul><ul><ul><li>Data to be operated on – operand. </li></ul></ul>
  88. 89. <ul><li>Classification </li></ul><ul><ul><li>Instruction Word Size </li></ul></ul><ul><ul><ul><li>One-word or 1-byte instructions </li></ul></ul></ul><ul><ul><ul><li>Two-word or 2-byte instructions </li></ul></ul></ul><ul><ul><ul><li>Three-word or 3-byte instructions </li></ul></ul></ul><ul><ul><li>Functionality </li></ul></ul><ul><ul><ul><li>Data transfer (copy) operations </li></ul></ul></ul><ul><ul><ul><li>Arithmetic operations </li></ul></ul></ul><ul><ul><ul><li>Logical operations </li></ul></ul></ul><ul><ul><ul><li>Branching operations </li></ul></ul></ul><ul><ul><ul><li>Machine-control operations. </li></ul></ul></ul>
  89. 90. <ul><li>ONE-BYTE INSTRUCTIONS </li></ul><ul><ul><li>Includes opcode and operand in single byte. </li></ul></ul><ul><ul><li>Operand(s) are internal register </li></ul></ul><ul><li>Example: </li></ul><ul><ul><li>MOV C,A </li></ul></ul><ul><ul><ul><li>Both operand registers are specified. </li></ul></ul></ul><ul><ul><li>ADD B </li></ul></ul><ul><ul><ul><li>The operand B is specified and the accumulator is assumed. </li></ul></ul></ul><ul><ul><li>CMA </li></ul></ul><ul><ul><ul><li>Accumulator is assumed to be the implicit operand </li></ul></ul></ul>
  90. 91. <ul><li>TWO-BYTE INSTRUCTIONS </li></ul><ul><ul><li>Uses two-bytes </li></ul></ul><ul><ul><ul><li>First byte specifies the operation code </li></ul></ul></ul><ul><ul><ul><li>Second byte specifies the operand. </li></ul></ul></ul><ul><ul><ul><li>Source operand is a data byte </li></ul></ul></ul><ul><ul><li>Example </li></ul></ul><ul><ul><ul><li>MVI A, 32H </li></ul></ul></ul><ul><li>THREE-BYTE INSTRUCTION </li></ul><ul><ul><li>First byte specifies the opcode </li></ul></ul><ul><ul><li>Following two bytes specify the 16-bit address. </li></ul></ul><ul><ul><ul><li>second byte – low-order address or data </li></ul></ul></ul><ul><ul><ul><li>third byte is the high-order address or data </li></ul></ul></ul><ul><ul><li>Example </li></ul></ul><ul><ul><ul><li>JMP 2085H, LXI H, 2050H </li></ul></ul></ul>
  91. 92. <ul><li>DATA TRANSFER (COPY) OPERATIONS </li></ul><ul><ul><li>Copies data from a location called a source to another location called a destination </li></ul></ul><ul><ul><li>Contents of source not modified </li></ul></ul><ul><ul><li>Types of data transfer : </li></ul></ul><ul><ul><ul><li>Between Registers. </li></ul></ul></ul><ul><ul><ul><li>Specific data byte to a register or a memory location. </li></ul></ul></ul><ul><ul><ul><li>Between a memory location and a register </li></ul></ul></ul><ul><ul><ul><li>Between an I/O device and the accumulator. </li></ul></ul></ul>
  92. 93. <ul><li>MOV </li></ul><ul><ul><li>Copies data from one register to another </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>MOV R d , R s </li></ul></ul></ul><ul><ul><li>Example: </li></ul></ul><ul><ul><ul><li>MOV A, B </li></ul></ul></ul><ul><li>MVI </li></ul><ul><ul><li>Copies 8 Bit data to a specific register </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>MVI Rd, D </li></ul></ul></ul><ul><ul><li>Example: </li></ul></ul><ul><ul><ul><li>MVI C, 5 </li></ul></ul></ul>
  93. 94. <ul><li>OUT </li></ul><ul><ul><li>Copies the Contents of Accumulator to Port </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>OUT PortNo. </li></ul></ul></ul><ul><ul><li>Example: </li></ul></ul><ul><ul><ul><li>OUT 56 </li></ul></ul></ul><ul><li>IN </li></ul><ul><ul><li>Copies the Contents of the Port to Accumulator </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>IN PortNo. </li></ul></ul></ul><ul><ul><li>Example: </li></ul></ul><ul><ul><ul><li>IN 57 </li></ul></ul></ul>
  94. 95. Between Registers Between Registers and Memory 1 Bytes Copies data From Source Register Rs to Destination Register Rd Rd, Rs MOV Description Operand OP Code Description Bytes Operand OP Code Copies data From memory M to Destination Register Rd 1 Rd, M MOV Copies data From Source Register Rs to Memory M 1 M, Rs MOV
  95. 96. Data to/from Register, Memory or I/O Port Copies the content of the Register L to memory location pointed out by 16 bit address and content of Register H to next memory location 3 16 Bit Address SHLD Copies the content of the memory location pointed out by 16 bit address to Register L and content of next memory location to Register H 3 16 Bit Address LHLD Loads the Data to the Specified Register 2 R, Data (8 Bits) MVI Copies data From Accumulator A to Specified port Address 2 8 Bit Port Address OUT 2 Bytes Copies data From Specified port Address to Accumulator A 8 Bit Port Address IN Description Operand OP Code
  96. 97. Data to/from Register, Memory or I/O Port Contents of Register H is exchanged with Register D and Contents of Register L is exchanged with Register E 1 None XCHG Loads the 16 bit data into the Register Pair 3 RP, 16 Bit Data LXI Copies the content of Memory Location Accumulator A to Specified in Register Pair B or D 1 RP B/D STAX Copies the content of Accumulator A to Memory location specified by 16 bit address 3 16 Bit Address STA Copies the content of Memory Location Specified in Register Pair B or D to Accumulator A 1 RP B/D LDAX 3 Bytes Copies the content of Memory location specified by 16 bit address to Accumulator A 16 Bit Address LDA Description Operand OP Code
  97. 98. <ul><li>ARITHMETIC OPERATIONS </li></ul><ul><ul><li>Performs addition, subtraction, increment and decrement. </li></ul></ul><ul><li>Addition </li></ul><ul><ul><li>Adds an 8-bit data to the accumulator </li></ul></ul><ul><ul><li>Carry Flag is set if the sum exceeds 8-bits </li></ul></ul><ul><li>ADD </li></ul><ul><ul><li>Adds a register’s content to the accumulator </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>ADD R </li></ul></ul></ul><ul><li>ADI </li></ul><ul><ul><li>Adds an 8-bit data to the accumulator </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>ADI 8-bit Data </li></ul></ul></ul>
  98. 99. <ul><li>Subtraction </li></ul><ul><ul><li>Subtracts an 8-bit data to the accumulator and the stores the difference in it. </li></ul></ul><ul><ul><li>Performed in 2's complement method </li></ul></ul><ul><li>SUB </li></ul><ul><ul><li>Subtracts a register’s content from the accumulator </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>SUB R </li></ul></ul></ul><ul><li>SUI </li></ul><ul><ul><li>Subtracts an 8-bit data from the accumulator </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>SBI 8-bit Data </li></ul></ul></ul>
  99. 100. <ul><li>Increment/Decrement </li></ul><ul><ul><li>Increments/Decrements 8-bit content by 1. </li></ul></ul><ul><ul><li>Increments/Decrements 16-bit contents of a register pair (such as BC) </li></ul></ul><ul><li>INR </li></ul><ul><ul><li>Increments the content of a register </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>INR B </li></ul></ul></ul><ul><li>DCR </li></ul><ul><ul><li>Decrements the content of a register </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>DCR B </li></ul></ul></ul>
  100. 101. Arithmetic Operations The content of the specified Register or Memory is decremented by 1 1 R/M DCR The content of the specified Register or Memory is incremented by 1 1 R/M INR 8 Bit Data is subtracted from the content of Accumulator and the result is stored in Accumulator 2 8 Bit Data SUI 8 Bit Data is added to the Accumulator content and stores the result in Accumulator 2 8 Bit Data ADI Content of the Register or Memory is subtracted from the content of Accumulator and the result is stored in Accumulator 1 R/M SUB 1 Bytes Content of the Register or Memory is added to the content of Accumulator and the result is stored in Accumulator R/M ADD Description Operand OP Code
  101. 102. <ul><li>LOGICAL OPERATIONS </li></ul><ul><ul><li>Performs logical operations with accumulator content </li></ul></ul><ul><li>AND, OR, Exclusive-OR </li></ul><ul><ul><li>Performed on an 8-bit data and accumulator content </li></ul></ul><ul><li>AND </li></ul><ul><ul><li>Logically AND the Register Content with Accumulator Content </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>AND R </li></ul></ul></ul><ul><li>ANI </li></ul><ul><ul><li>Logically ANd Immediately 8-Bit Data with Accumulator Content </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>ANI 14 </li></ul></ul></ul>
  102. 103. <ul><li>ORA </li></ul><ul><ul><li>Logically OR contents of Register with Accumulator </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>ORA C </li></ul></ul></ul><ul><li>ORI </li></ul><ul><ul><li>Logically OR Immediately 8 Bit Data with Accumulator </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>ORI D </li></ul></ul></ul>
  103. 104. <ul><li>XRA </li></ul><ul><ul><li>Logically Exclusive - OR the contents of Register with Accumulator </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>XRA C </li></ul></ul></ul><ul><li>XRI </li></ul><ul><ul><li>Logically Exclusively - OR immediately 8 Bit Data with Accumulator </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>XRI 6 </li></ul></ul></ul>
  104. 105. <ul><li>CMA </li></ul><ul><ul><li>Complements the contents of accumulator </li></ul></ul><ul><ul><li>No Flags are affected </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>CMA </li></ul></ul></ul><ul><li>Rotate </li></ul><ul><ul><li>Shifts Bits in the accumulator either left or right </li></ul></ul><ul><li>Compare </li></ul><ul><ul><li>Compares an 8-bit data with accumulator content </li></ul></ul>
  105. 106. <ul><li>BRANCHING OPERATIONS </li></ul><ul><ul><li>Alters program execution sequence either conditionally or unconditionally. </li></ul></ul><ul><li>Jump </li></ul><ul><ul><li>Conditional jump </li></ul></ul><ul><ul><ul><li>Alters program sequence when condition test is true </li></ul></ul></ul><ul><ul><li>Unconditional jump </li></ul></ul><ul><ul><ul><li>Alters program sequence without condition checking </li></ul></ul></ul><ul><li>Call </li></ul><ul><ul><li>Changes sequence of a program by calling a subroutine </li></ul></ul><ul><li>Return </li></ul><ul><ul><li>Changes sequence of a program by returning from a subroutine </li></ul></ul>
  106. 107. <ul><li>Unconditional jump </li></ul><ul><li>JMP </li></ul><ul><ul><li>The program control is transferred to a particular memory address </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>JMP Address </li></ul></ul></ul><ul><ul><li>Example: </li></ul></ul><ul><ul><ul><li>JMP F200 </li></ul></ul></ul>
  107. 108. <ul><li>Conditional Jump </li></ul><ul><ul><li>Based on Condition of the flags </li></ul></ul><ul><ul><li>All Instructions are followed by a 16-Bit address </li></ul></ul><ul><li>JC </li></ul><ul><ul><li>Transfers program control to a particular address if Carry Flag is Set </li></ul></ul><ul><li>JNC </li></ul><ul><ul><li>Transfers program control to a particular address if Carry Flag is not Set </li></ul></ul><ul><li>JZ </li></ul><ul><ul><li>Transfers program control if Zero Flag is Set </li></ul></ul><ul><li>JNZ </li></ul><ul><ul><li>Transfers program control if Zero Flag is not Set </li></ul></ul>
  108. 109. <ul><li>JP </li></ul><ul><ul><li>Transfers program control if Sign Flag is not Set </li></ul></ul><ul><li>JM </li></ul><ul><ul><li>Transfers program control if Sign Flag is Set </li></ul></ul><ul><li>JPE </li></ul><ul><ul><li>Transfers program control if Parity Flag is Set </li></ul></ul><ul><li>JPO </li></ul><ul><ul><li>Transfers program control if Parity Flag is not Set </li></ul></ul>
  109. 110. <ul><li>MACHINE CONTROL OPERATIONS </li></ul><ul><ul><li>Controls machine functions </li></ul></ul><ul><ul><li>Examples: </li></ul></ul><ul><ul><ul><li>Halt, Interrupts, No Operation </li></ul></ul></ul><ul><li>Halt </li></ul><ul><ul><li>Processor Stops Executing </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>HLT </li></ul></ul></ul><ul><li>No Operation </li></ul><ul><ul><li>No Operation is performed </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>NOP </li></ul></ul></ul>
  110. 111. <ul><li>8085 ADDRESSING MODES </li></ul><ul><ul><li>Addressing Modes specifies various formats for operands </li></ul></ul><ul><ul><ul><li>a register, an input/ output port, or an 8-bit number </li></ul></ul></ul><ul><li>Types: </li></ul><ul><ul><li>Immediate addressing. </li></ul></ul><ul><ul><li>Register addressing. </li></ul></ul><ul><ul><li>Direct addressing. </li></ul></ul><ul><ul><li>Indirect addressing. </li></ul></ul>
  111. 112. <ul><li>Immediate Addressing </li></ul><ul><ul><li>Data is present in the instruction </li></ul></ul><ul><ul><li>Example: </li></ul></ul><ul><ul><ul><li>MVI R,data </li></ul></ul></ul><ul><li>Register addressing </li></ul><ul><ul><li>Data is provided through the registers. </li></ul></ul><ul><ul><li>Example: </li></ul></ul><ul><ul><ul><li>MOV Rd, Rs </li></ul></ul></ul>
  112. 113. <ul><li>Direct addressing </li></ul><ul><ul><li>Accepts data from or sends data to the outside device. </li></ul></ul><ul><ul><li>Example: </li></ul></ul><ul><ul><ul><li>IN 00H or OUT 01H </li></ul></ul></ul><ul><li>Indirect Addressing </li></ul><ul><ul><li>Effective Address is calculated by the processor </li></ul></ul><ul><ul><li>The contents of the address (and the one following) is used to form a second address where the data is stored </li></ul></ul>
  113. 114. Assembly Language Programming <ul><li>Memory Address </li></ul><ul><ul><li>16 bit address of System Memory </li></ul></ul><ul><li>Machine Code </li></ul><ul><ul><li>Hexadecimal entered in System Memory </li></ul></ul><ul><li>Opcode </li></ul><ul><ul><li>Abbreviated Symbols specified by manufacturer </li></ul></ul><ul><li>Operand </li></ul><ul><ul><li>Item to be processed </li></ul></ul><ul><li>Comments </li></ul><ul><ul><li>Documentation explaining purpose of instructions used </li></ul></ul>
  114. 115. Assembly Language Program <ul><li>Program to accept and display a number </li></ul><ul><li>Task Mnemonics </li></ul><ul><li>Load Register B with 4EH MVI B, 4EH </li></ul><ul><li>Copy the Number to Accumulator MOV A, B </li></ul><ul><li>Sent the Number to Output Port OUT, Port1 </li></ul><ul><li>End of the Program HLT </li></ul>
  115. 116. Programming Format End of the Program None HLT Sends 37H to Port ‘ Port1 ’ Port1 OUT Copies Content of Register B to Accumulator A, B MOV Loads 37H to Register B B, 37H MVI Description Operand OP Code
  116. 117. Arithmetic Operations The content of the specified Register or Memory is decremented by 1 1 R/M DCR The content of the specified Register or Memory is incremented by 1 1 R/M INR 8 Bit Data is subtracted from the content of Accumulator and the result is stored in Accumulator 2 8 Bit Data SUI 8 Bit Data is added to the content of Accumulator and the result is stored in Accumulator 2 8 Bit Data ADI Content of the Register or Memory is subtracted from the content of Accumulator and the result is stored in Accumulator 1 R/M SUB 1 Bytes Content of the Register or Memory is added to the content of Accumulator and the result is stored in Accumulator R/M ADD Description Operand OP Code
  117. 118. <ul><li>Loops </li></ul><ul><ul><li>Executes a set of instructions repeatedly </li></ul></ul><ul><ul><li>Types </li></ul></ul><ul><ul><ul><li>Continuous Loop </li></ul></ul></ul><ul><ul><ul><li>Conditional Loop </li></ul></ul></ul><ul><li>Continuous Loop </li></ul><ul><ul><li>Uses unconditional jump </li></ul></ul><ul><li>Conditional Loop </li></ul><ul><ul><li>Uses Conditional Jump </li></ul></ul>
  118. 119. <ul><li>Counter </li></ul><ul><ul><li>Executes certain set of instructions a specified number of times </li></ul></ul><ul><ul><li>Uses the concept of conditional loop </li></ul></ul><ul><ul><li>Can be incremented or decremented </li></ul></ul>
  119. 120. First Program <ul><li>Load a number to Register B and display the output in Port1 </li></ul><ul><li>Steps: </li></ul><ul><li>1. Load register B with a Number </li></ul><ul><li>2. Send to Output to Port1 </li></ul><ul><li>Algorithm </li></ul>Start Input Number In Register Output Number Stop
  120. 121. CA & µP Unit IV
  121. 122. Setting up a Counter <ul><li>Executes certain set of instructions a specified number of times </li></ul><ul><li>A Register is Loaded with a number </li></ul><ul><li>Using INR (Increment) or DCR (Decrement) the number is Incremented or Decremented </li></ul><ul><li>Uses the concept of conditional loop </li></ul><ul><li>Time delay required </li></ul><ul><li>If the register reaches the final count the loop is terminated </li></ul>
  122. 123. Flowchart Start Initialize Update Is the Final Count End No Yes
  123. 124. Time Delay
  124. 125. T - States <ul><li>One Subdivision of the operation performed in one clock period </li></ul>Frequency & Time/Clock Period Frequency in the Processing Speed of a Processor Time Period = (Frequency) -1 Time Period = 1 Frequency
  125. 126. Time Delay <ul><li>Uses the concept of counter </li></ul><ul><li>No. of Counts depends on T-States. </li></ul><ul><li>Calculation of Time for Execution: </li></ul><ul><li>Clock Period = 1/frequency </li></ul><ul><li>Time for Execution of Instruction = No. of T-States X Clock Period </li></ul>
  126. 127. Simple Time Delay Program <ul><li>MVI B, 77H - 7 T-States </li></ul><ul><li>Loop: DCR B - 4 T-States </li></ul><ul><li>JNZ LOOP - 10/7 T-States </li></ul><ul><li>HLT - 5 T-States </li></ul>
  127. 128. Time Delay <ul><li>Time Delay in executing the Loop </li></ul><ul><li>T L = (Time Period T X Loop T-States X Equivalent Decimal Number N 10 ) </li></ul><ul><li>Total Time Delay in executing the Loop </li></ul><ul><li>T LA = T L – Time Adjustment </li></ul>
  128. 129. Time Delay for the Program <ul><li>Let us Assume the Frequency of the Processor is 2MHz </li></ul><ul><li>f = 2 MHz </li></ul><ul><li>T = 1/f </li></ul><ul><li>T = 1/2 MHz </li></ul><ul><li>T = 0.5 µSec. </li></ul>Count FFH = 255 10 T-States Inside the Loop DCR B - 4 JNZ LOOP - 10 Total = 14 T-States Outside the Loop MVI B, FFH - 7 HLT - 5 Total = 12
  129. 130. Time Delay Inside the Loop <ul><li>T L = T x T States x N 10 </li></ul><ul><li>T L = 0.5 µSec. x 14 x 255 </li></ul><ul><li>T L = 1785 µSec. </li></ul><ul><li>T L = 1.785 mSec. </li></ul><ul><li>Total Time </li></ul><ul><li>T LA = 1.785 mSec. - (10-7) x 0.5 µSec. </li></ul><ul><li>T LA = 1.785 mSec. - 0.0015 mSec. </li></ul><ul><li>T LA = 1.7835 mSec. </li></ul>
  130. 131. Total Time Delay <ul><li>Time to Execute the instruction outside the loop </li></ul><ul><li>T D = + </li></ul><ul><li>Time taken to execute the instruction inside the loop </li></ul><ul><li>T D = T O + T LA </li></ul><ul><li>Where T O = T-States Outside the loop X Time Period </li></ul>
  131. 132. Total Time Delay <ul><li>T O = 12 x 0.5 µSec. </li></ul><ul><li>T O = .006 mSec. </li></ul><ul><li>T D = T O + T LA </li></ul><ul><li>T D = 0.006 mSec + 1.7835 mSec. </li></ul><ul><li>T D = 1.7895 mSec. </li></ul><ul><li>T D ≈ 1.8 mSec. </li></ul><ul><li>Total Time Required to execute the program is 1.8 milli Seconds (Approx.) </li></ul>
  132. 133. Note: <ul><li>Time Delay can be Varied by changing the Count number FFH. </li></ul><ul><li>To Increase the time delay more the 1.8 mSec. the user should use the Additional Instruction or Register Pair. </li></ul>
  133. 134. Time Delay Using Register Pair <ul><li>Program </li></ul><ul><li>LXI B, FFFFH - 10 T-States </li></ul><ul><li>Loop: DCX B - 6 T-States </li></ul><ul><li>MOV A, C - 4 T-States </li></ul><ul><li>ORA B - 4 T-States </li></ul><ul><li>JNZ Loop - 10/7 T-States </li></ul><ul><li>HLT - 5 T-States </li></ul>
  134. 135. Time Delay <ul><li>Let us Assume the Frequency of the Processor is 2MHz </li></ul><ul><li>f = 2 MHz </li></ul><ul><li>T = 1/f </li></ul><ul><li>T = 1/2 MHz </li></ul><ul><li>T = 0.5 µSec. </li></ul>T-States Inside the Loop DCX B - 6 MOV A,C - 4 ORA B - 4 JNZ LOOP - 10 Total = 24 T-States Outside the Loop LXI B, FFFFH - 10 HLT - 5 Total = 15 Count FFFFH = 65535 10
  135. 136. Time Delay in the Loop <ul><li>T L = T x T States x N 10 </li></ul><ul><li>T L = 0.5 µSec. x 24 x 65535 </li></ul><ul><li>T L = 786420 µSec. </li></ul><ul><li>T L = 786.42 mSec. </li></ul><ul><li>Total Time </li></ul><ul><li>T LA = 786.42 mSec. - (10-7) x 0.5 µSec. </li></ul><ul><li>T LA = 786.42 mSec. - 0.0015 mSec. </li></ul><ul><li>T LA = 786.4185 mSec. </li></ul>
  136. 137. Total Time Delay <ul><li>T O = 15 x 0.5 µSec. </li></ul><ul><li>T O = .0075 mSec. </li></ul><ul><li>T D = T O + T LA </li></ul><ul><li>T D = 0.0075 mSec + 786.4185 mSec. </li></ul><ul><li>T D = 786.426 mSec. </li></ul><ul><li>T D ≈ 786.4 mSec. </li></ul><ul><li>Total Time Required to execute the program is 786.4 milli Seconds (Approx.) </li></ul>
  137. 138. Flowchart Start Initialize Loop2 Update Is the Final Count End Initialize Loop1 Update Is the Final Count No No Yes Yes
  138. 139. Time Delay Using Loop within a Loop <ul><li>Program </li></ul><ul><li>MVI B, FFH - 10 T-States </li></ul><ul><li>Loop2: MVI C, FFH - 10 T-States </li></ul><ul><li>Loop1: DCR C - 6 T-States </li></ul><ul><li>JNZ Loop1 - 10/7 T-States </li></ul><ul><li>DCR B - 6 T-States </li></ul><ul><li>JNZ Loop2 - 10/7 T-States </li></ul><ul><li>HLT - 5 T-States </li></ul>L1 L2
  139. 140. Time Delay <ul><li>Let us Assume the Frequency of the Processor is 2MHz </li></ul><ul><li>f = 2 MHz </li></ul><ul><li>T = 1/f </li></ul><ul><li>T = 1/2 MHz </li></ul><ul><li>T = 0.5 µSec. </li></ul>T-States Inside the Loop1 DCR C - 4 JNZ Loop1 - 10 Total = 14 T-States Inside the Loop2 DCR C - 4 JNZ Loop1 - 7 DCR B - 4 JNZ Loop2 - 10 Total = 21 Count Loop1 Count = FFH = 255 10 Loop2 Count = FFH = 255 10 T-States Outside the Loops MVI B, FFH - 7 MVI C, FFH - 7 HLT - 5 Total = 19
  140. 141. Time Delay in the Loop1 <ul><li>T L1 = T x T States x N 10 </li></ul><ul><li>T L1 = 0.5 µSec. x 14 x 255 </li></ul><ul><li>T L1 = 1785 µSec. </li></ul><ul><li>T L1 = 1.785 mSec. </li></ul><ul><li>Total Time </li></ul><ul><li>T LA1 = 1.785 mSec. - (10-7) x 0.5 µSec. </li></ul><ul><li>T LA1 = 1.785 mSec. - 0.0015 mSec. </li></ul><ul><li>T LA1 = 1.7835 mSec. </li></ul>
  141. 142. Time Delay in the Loop2 <ul><li>T L2 = (T LA1 + T-States X Time Period) X Count N 10 </li></ul><ul><li>T L2 = (1.7835 mSec. + 21 x 0.5 µSec.) x 255 </li></ul><ul><li>T L2 = 457470 µSec. </li></ul><ul><li>T L2 = 457.47 mSec. </li></ul><ul><li>Total Time </li></ul><ul><li>T LA2 = 457.47 mSec. - (10-7) x 0.5 µSec. </li></ul><ul><li>T LA1 = 457.47 mSec. - 0.0015 mSec. </li></ul><ul><li>T LA1 = 457.4685 mSec. </li></ul>
  142. 143. Total Time Delay <ul><li>T O = 19 x 0.5 µSec. </li></ul><ul><li>T O = .0095 mSec. </li></ul><ul><li>T D = T O + T LA2 </li></ul><ul><li>T D = 0.0095 mSec + 457.4685 mSec. </li></ul><ul><li>T D = 457.478 mSec. </li></ul><ul><li>T D ≈ 457.5 mSec. </li></ul><ul><li>Total Time Required to execute the program is 457.5 milli Seconds (Approx.) </li></ul>
  143. 144. Sample Program <ul><li>Write a program to count continuously in hexadecimal from FFH to 00H in a system with a clock period of 0.5 µSec. Use Register D to setup one millisecond delay between each count and display the count in one of the Output Ports </li></ul><ul><li>Note: </li></ul><ul><li>To Count from FFH the register to be initialized with 0OH </li></ul><ul><li>Separate Time Delay Loop to be Set </li></ul><ul><li>The Count to be Displayed in Output Port </li></ul>
  144. 145. Program <ul><li>MVI E, 00H - 7 T-states </li></ul><ul><li>Count: DCR E - 4 T-states </li></ul><ul><li>MVI D, Count No. - 7 T-states </li></ul><ul><li>Delay: DCR D - 4 T-states </li></ul><ul><li>JNZ Delay - 10/7 T-states </li></ul><ul><li>MOV A, B - 4 T-states </li></ul><ul><li>OUT Port - 10 T-states </li></ul><ul><li>JMP Count - 10 T-states </li></ul>
  145. 146. To Calculate Time Delay Count No. <ul><li>T = 0.5 µSec. </li></ul><ul><li>T L = (T-States x T) x Count No. </li></ul><ul><li>T L = (14 x 0.5 µSec.) x Count No. </li></ul><ul><li>T L = 0.007 mSec. x Count No. </li></ul><ul><li>T LA = (0.007 mSec. x Count) - 0.0015 mSec. </li></ul><ul><li>T O = 35 x 0.5 µSec. = 0.0175 mSec . </li></ul><ul><li>T D = (0.007 mSec. x Count) - 0.0015 mSec. + 0.0175 mSec. </li></ul><ul><li>1 mSec. = (0.007 mSec. x Count) + 0.016 mSec. </li></ul><ul><li> 1 mSec. – 0.016 mSec. </li></ul><ul><li>Count No . = = 140.571 ≈ 141 10 ≈ 8CH </li></ul><ul><li> 0.007 mSec. </li></ul><ul><li> Count No. = 8CH, 8CH should be loaded into register D to set 1 millisecond delay </li></ul>
  146. 147. Stack <ul><li>Set of Memory Locations in R/W memory </li></ul><ul><li>Used to store binary information temporarily during the execution of a program </li></ul><ul><li>Beginning of Stack is defined using </li></ul><ul><li>LXI SP, 16 bit Address </li></ul><ul><li>Stack pointer is decremented by one </li></ul><ul><li>The byte stored to stack with the address specified in Stack Pointer </li></ul><ul><li>The Storage & Retrieval on stack follows LIFO (Last in First Out) </li></ul>
  147. 148. Storing Register Pair Content to Stack <ul><li>Using Inst. PUSH the contents of a Register Pair can be copied to stack </li></ul><ul><li>Using Inst. POP the contents from the stack is copied to Register Pair </li></ul>Description Bytes Operand OP Code Copy the content of the stack which is pointer by stack pointer to lower order register (C, E, L, Flags) and increment the stack pointer by one then Copy the content of the stack which is pointer by stack pointer to higher order register (B, D, H, A) 1 Rp. POP Decrement the Stack Pointer by one the content of higher order (B, D, H, A) is copied into stack then the Stack Pointer is again decremented the lower order (C, E, L, Flags) is copied into stack 1 Rp. PUSH
  148. 149. Stack Instructions <ul><li>PUSH B - From Rp. BC to Stack </li></ul><ul><li>PUSH D - From Rp. DE to Stack </li></ul><ul><li>PUSH H - From Rp. HL to Stack </li></ul><ul><li>PUSH PSW - From Accumulator & Flags to Stack </li></ul><ul><li>POP B - From Stack to Rp. BC </li></ul><ul><li>POP D - From Stack to Rp. DE </li></ul><ul><li>POP H - From Stack to Rp. HL </li></ul><ul><li>POP PSW - From Stack to Accumulator & Flags </li></ul><ul><li>Note: PSW stands for Program Status Word </li></ul>
  149. 150. Example: <ul><li>Program: </li></ul><ul><li>1 LXI SP, 2000H </li></ul><ul><li>2 LXI H, 4253H </li></ul><ul><li>3 PUSH H </li></ul><ul><li>4 NOP </li></ul><ul><li>5 POP B </li></ul><ul><li>6 HLT </li></ul>
  150. 151. Register Contents after executing first 2 Instructions A B D H SP Register Contents after executing PUSH Instructions X X 2000 53 42 A B D 1FFE H 1FFF SP 2000 X X 2000 53 42 X 42 53 Memory
  151. 152. Register Contents after executing POP Instructions A Flags B C D E H L SP 53 42 2000 53 42 X 42 53 Memory
  152. 153. <ul><li>Program to Clear all Flags , Load 00H in the accumulator and demonstrate the zero flag is not affected by data transfer instruction. Logically OR the accumulator with itself to set the zero flag, and display the flag at Port1 or store all the flags on the stack. </li></ul><ul><li>LXI SP, 2000H - Initialize Stack Pointer </li></ul><ul><li>MVI L, 00H </li></ul><ul><li>PUSH H To Clear Flags </li></ul><ul><li>POP PSW </li></ul><ul><li>MVI A, 00H - Loading Accumulator with 00H </li></ul><ul><li>A Data Transfer Instruction </li></ul><ul><li>PUSH PSW </li></ul><ul><li>Getting Flag content to Reg. L </li></ul><ul><li>POP H </li></ul>
  153. 154. <ul><li>MOV A, L </li></ul><ul><li>Display Flags </li></ul><ul><li>OUT Port1 </li></ul><ul><li>ORA A - Reset CY & AC </li></ul><ul><li>PUSH PSW </li></ul><ul><li> Getting Flag content to Reg. L </li></ul><ul><li>POP H </li></ul><ul><li>MOV A, L </li></ul><ul><li>ANI 40H Masking all flags except Z & Display </li></ul><ul><li>OUT Port1 </li></ul><ul><li>HLT - End of the Program </li></ul>
  154. 155. Subroutine <ul><li>It is group of Instructions written separately from the main program to perform a function no. of times in the main program. </li></ul><ul><li>If a Time Delay is required for no. of times in a main program, to avoid repetition of same delay instruction, Subroutine is used </li></ul><ul><li>Instruction </li></ul>Description Bytes Operand OP Code The Program Sequence is transferred from subroutine to calling program. 1 None RET The Program Sequence is transferred to the specified 16 bit address 3 16 bit address CALL
  155. 156. CALL & RET <ul><li>Call Inst. </li></ul><ul><ul><li>Saves the contents of Program Counter on the stack </li></ul></ul><ul><ul><li>Jumps unconditionally to the memory location specified by 16 bit address (Note: Conditional Call Statements are also there) </li></ul></ul><ul><li>RET inst. </li></ul><ul><ul><li>Copies the content in the top two location of the stack </li></ul></ul><ul><ul><li>Unconditional Return from Subroutine (Note: Conditional Return Statements are also there) </li></ul></ul>
  156. 157. Example End of Subroutine RET 3002H Instructions of Subroutine Inst. 3001H Instructions of Subroutine Inst. 3000H End of Main Program HLT 2008H Other Instructions Inst. 2007H Calling the subroutine at 3000H CALL 3000H 2004H Initialize the stack pointer with 2400H LXI SP, 4000H 2000H Description Instruction Mem. Add.
  157. 158. Flow of Subroutine <ul><li>Main Program </li></ul><ul><ul><li>2000H Subroutine </li></ul></ul><ul><ul><li>… </li></ul></ul><ul><ul><li>2004H 3000H Start </li></ul></ul><ul><ul><li>2005H 3001H </li></ul></ul><ul><ul><li>2006H 3002H End </li></ul></ul><ul><ul><li>… … </li></ul></ul><ul><ul><li>… … </li></ul></ul><ul><ul><li>… </li></ul></ul>
  158. 159. Data Transfer During CALL Instruction 30 2006H 00 2005H CD 2004H Code (H) Mem. Add.
  159. 160. PC, Stack & SP during CALL Inst. CALL Program Counter Stack Pointer Register 3FFE 3FFF 4000 STACK 2007 2006 2005 2004 XX 20 07 3FFE 3FFF 4000
  160. 161. Data Transfer During CALL Instruction 20 07 (W) (Z) 2007 (W) (Z) M 1 Opcode Fetch 20 20 (Stack – I) 3FFF 4000 M 3 Opcode Fetch 07 07 (Stack) 3FFE 3FFF M 2 Opcode Fetch - C9 Opcode 3003 3002 3FFE M 1 Opcode Fetch Internal Registers (W) (Z) Data Bus (DB) Program Counter Address Bus (AB) Stack Pointer 3FFE Machine Cycles
  161. 162. Traffic Signal Controller <ul><li>Program to provide given on/off timer to three traffic lights (Green, Yellow, and Red) and two pedestrian signs (WALK and DON’T WALK). The signal lights and signs are turned on/off by the data bits of an output port as shown below: </li></ul><ul><li> Lights Data Bits On Time </li></ul><ul><li>1. Green D0 15 seconds </li></ul><ul><li>2. Yellow D2 5 seconds </li></ul><ul><li>3. Red D4 20 seconds </li></ul><ul><li>4. WALK D6 15 seconds </li></ul><ul><li>5. DON’T WALK D7 25 seconds </li></ul><ul><li>The traffic and pedestrian flow are in the same direction; the pedestrian should cross the road when the Green light is on. </li></ul>
  162. 163. The problem is primarily concerned with providing various time delays for a complete sequence of 40 seconds. The on/off times for the traffic signals and pedestrian signs are as follows:
  163. 164. <ul><li>The Green light and the WALK sign can be turned on by sending data byte 41H to the output port. </li></ul><ul><li>The 15-second delay can be provided by using a 1-second subroutine and a counter with a count of 1510. </li></ul><ul><li>Similarly, the next two bytes, 84H and 90H, will turn on/off the appropriate lights/signs as shown in the flowchart. </li></ul><ul><li>The necessary time delays are provided by changing the values of the count in the counter. </li></ul>
  164. 165. Main Program <ul><li>LXI SP, XX99 - Initialize Stack Pointer with XX99H </li></ul><ul><li>START: MVI A, 41H - Loading Accumulator with Pattern for Green & Walk </li></ul><ul><li>OUT PORT1 - Turn on corresponding lights </li></ul><ul><li>MVI B, 0FH - Reg. B is used to count 15 seconds </li></ul><ul><li>CALL DELAY - Call subroutine of one second delay </li></ul><ul><li>MVI A, 90H - Loading Accumulator with Pattern </li></ul><ul><li>OUT PORT1 - Turn on corresponding lights </li></ul><ul><li>MVI B, 05 - Reg. B is used to count 5 seconds </li></ul><ul><li>CALL DELAY - Call subroutine of one second delay </li></ul><ul><li>MVI A, 90H - Loading Accumulator with Pattern </li></ul><ul><li>OUT PORT1 - Turn on corresponding lights </li></ul><ul><li>MVI B, 14H - Reg. B is used to count 20 seconds </li></ul><ul><li>CALL DELAY - Call subroutine of one second delay </li></ul><ul><li>JMP START - Go to START to repeat the Sequence </li></ul>
  165. 166. Subroutine <ul><li>Delay: PUSH D Save the contents of DE & Accumulator </li></ul><ul><li>PUSH PSW </li></ul><ul><li>Sec: LXI D, COUNT No. - Load Rp. DE with Count No. </li></ul><ul><li>Loop: DCX D - Decrement Rp. DE by one </li></ul><ul><li>MOV A, D Check Rp. DE is Zero </li></ul><ul><li>ORA E </li></ul><ul><li>JNZ Loop - Jump to Loop if Zero Flag is not Set </li></ul><ul><li>DCR B - Decrement Reg. B </li></ul><ul><li>JNZ Sec - Jump to Sec if Zero Flag is not Set </li></ul><ul><li>POP PSW </li></ul><ul><li>POP D Retrieve contents of saved Registers </li></ul><ul><li>RET - Returning to Main Program </li></ul>
  166. 167. BCD – Binary Coded Decimal <ul><li>86 10 = (8 x 10) + 2 </li></ul><ul><li>Converting a 2-digit BCD number into its binary equivalent requires the following steps: </li></ul><ul><ul><li>Separate an 8-bit packed BCD number into two 4-bit unpacked BCD digits: BCD1 and BCD2. </li></ul></ul><ul><ul><li>Convert each digit into its binary value according to its position. </li></ul></ul><ul><ul><li>Add both binary numbers to obtain the binary equivalent of the BCD number. </li></ul></ul>
  167. 168. Example <ul><li>Convert (86)BCD into its binary equivalent </li></ul><ul><li>Solution: 86 10 = 1000 0110 BCD </li></ul><ul><li>0111 0010 </li></ul><ul><ul><li>00000110 Unpacked BCD1 </li></ul></ul><ul><ul><li>00001000 Unpacked BCD2 </li></ul></ul><ul><li>Multiply BCD2 by 10 (8 x 10) </li></ul><ul><li>Add BCD1 to the answer in Step 2. </li></ul>
  168. 169. 2 Digit BCD to Binary Conversion <ul><li>A BCD number between 0 and 99 is stored in a R/W memory location called the Input Buffer. Write a main program and a conversion subroutine (BCDBIN) to convert the BCD number into its equivalent binary number. Store the result in a memory location defined as the Output Buffer. </li></ul><ul><li>LXI SP, “STACK” - Initialize stack </li></ul><ul><ul><li>LXI H, “INBUF” - Initialize Input Location </li></ul></ul><ul><ul><li>LXI B, “OUTBUF” - Initialize Output Location </li></ul></ul><ul><ul><li>MOV A, M - Input of BCD No. </li></ul></ul><ul><ul><li>CALL BCDBIN - Calling Subroutine </li></ul></ul><ul><ul><li>STAX B - Storing Binary No. to Output Buf. </li></ul></ul><ul><ul><li>HLT - End of the Program </li></ul></ul>Main Program
  169. 170. Subroutine <ul><li>BCDBIN; BCD to Binary </li></ul><ul><li> ; I/P: packed BCD in Acc. </li></ul><ul><li> ; O/P: Binary in Acc. </li></ul><ul><li>PUSH B - Save Rp. </li></ul><ul><li>MOV B, A - Copies Acc. Contents to Reg. B </li></ul><ul><li>ANI 0FH - ANDing (A) with 0FH to mask MSB </li></ul><ul><li>MOV C, A - Copies Acc. Contents to Reg. C </li></ul><ul><li>MOV A, B - Copies Reg. B contents to Acc. </li></ul><ul><li>ANI F0H - ANDing (A) with F0H to mask LSB </li></ul><ul><li>RRC </li></ul><ul><li>RRC Making MSB as LSB </li></ul><ul><li>RRC </li></ul><ul><li>RRC </li></ul><ul><li>MOV D, A - Copies Acc. Contents to Reg. D </li></ul><ul><li>XRA A - Clearing Acc. & Flags </li></ul>Cont.
  170. 171. <ul><li>MVI E, 0AH - Load Reg. E with 0AH = 10 10 </li></ul><ul><li>Sum: ADD E - Add (E) to (A) </li></ul><ul><li>DCR D - Decrement (D) by one </li></ul><ul><li>JNZ Sum - Jump to location Sum in Zero flag is reset </li></ul><ul><li>ADD C - Add (C) to (A) </li></ul><ul><li>POP B - Retrieve (BC) </li></ul><ul><li>RET - Returning to Main Program </li></ul>Cont.
  171. 172. Binary to BCD <ul><li>A binary number is stored in memory location BINBYT. Convert the number into BCD, and store each BCD as unpacked BCD digits in the Output Buffer. To perform this task, write a main program and two subroutines: one to supply the powers of ten, and the other to perform the conversion. </li></ul><ul><li>Main Program </li></ul><ul><li>START :LXI SP, STACK - Initialize stack pointer </li></ul><ul><li>LXI H, BINBYT - Point HL index where binary number is stored </li></ul><ul><li>MOV A, M - Transfer byte </li></ul><ul><li>CALL PWRTEN - Call subroutine to load powers of 10 </li></ul><ul><li>HLT - End of the Program </li></ul>
  172. 173. Subroutine PWRTEN <ul><li>PWRTEN ; Loads the powers of 10 in register B and calls the binary to BCD </li></ul><ul><li> ;I/P: Binary number in the accumulator </li></ul><ul><li> ;O/P: Powers of ten and store BCD 1 in the first Output-Buffer </li></ul><ul><li> ;Calls BINBCD routine and modifies register B </li></ul><ul><li> </li></ul><ul><li> : LXI H, OUTBUF - Point HL index to Output-Buffer memory </li></ul><ul><li>MVI B, 64H - Load 100 in register B </li></ul><ul><li>CALL BINBCD - Call conversion </li></ul><ul><li>MVI B, 0AH - Load 10 in register B </li></ul><ul><li>CALL BINBCD - Calls BINBCD subroutine </li></ul><ul><li>MOV M, A - Store BCD 1 </li></ul><ul><li>RET - Returning to Main Program </li></ul>
  173. 174. Subroutine BINBCD <ul><li>BINBCD ;Converts a binary number into BCD and stores BCD2 and </li></ul><ul><li> ;BCD3 in the Out put Buffer. </li></ul><ul><li> ;I/P: Binary number in accumulator and powers of 10 in B </li></ul><ul><li> ;O/P: BCD2 and BCD3 in Output Buffer </li></ul><ul><li> ;Modifies accumulator contents </li></ul><ul><li>:MVI M, FFH - Load buffer with (0 -1) </li></ul><ul><li>NB: INR M - Clear buffer and increment for each subtraction SUB B - Subtract power of 10 from binary number </li></ul><ul><li>JNC NB - Is number > power of 10? If yes, add 1 to buffer </li></ul><ul><li>ADD B - If no, add power of 10 to get remainder </li></ul><ul><li>INX H - Go to next buffer location </li></ul><ul><li>RET - Returning to Subroutine PWRTEN </li></ul>
  174. 175. BCD to 7 Segment Display <ul><li>Write a main program and two subroutines, called UNPAK and LEDCOD, to unpack the BCD numbers and select an appropriate seven-segment code for each digit. The codes should be stored in the Output-Buffer memory. </li></ul><ul><li>Main Program </li></ul><ul><li>LXI SP, STACK - Initialize stack pointer </li></ul><ul><li>LXI H, XX50H - Point HL index where BCD digits are stored </li></ul><ul><li>MVI D, 03H - Number of digits to be converted is placed in D </li></ul><ul><li>CALL UNPAK - Call subroutine to unpack BCD numbers </li></ul><ul><li>HLT - End of Program </li></ul>
  175. 176. Subroutine UNPACK <ul><li>UNPAK; This subroutine unpacks the BCD number into two single digits. </li></ul><ul><li>;I/P: Starting memory address of the packed BCD numbers in HL ;registers: Number of BCDs to be converted in register D </li></ul><ul><li>;O/P: Unpacked BCD into acc. and Output Buffer address in BC </li></ul><ul><li>;Calls subroutine LEDCOD </li></ul><ul><li>LXI B, BUFFER - Point BC index to the buffer memory </li></ul><ul><li>NBCD : MOV A, M - Get packed BCD number </li></ul><ul><li>ANI F0H - Masked BCD1 </li></ul><ul><li>RRC Rotate four times to place BCD2 as </li></ul><ul><li>RRC unpacked single digit BCD </li></ul><ul><li>RRC </li></ul><ul><li>RRC </li></ul>
  176. 177. Subroutine UNPACK <ul><li>CALL LEDCOD - Find seven-segment code </li></ul><ul><li>INX B - Point to next buffer location </li></ul><ul><li>MOV A, M - Get BCD number again </li></ul><ul><li>ANI 0FH - Separate BCD1 </li></ul><ul><li>CALL LEDCOD - </li></ul><ul><li>INX B - </li></ul><ul><li>INX H - Point to next BCD </li></ul><ul><li>DCR D - Conversion complete, reduce BCD count </li></ul><ul><li>JNZ NBCD - If all BCDs are not yet converted, go back </li></ul><ul><li>to convert next </li></ul><ul><li>RET - Return to Main Program </li></ul>
  177. 178. Subroutine LEDCOD <ul><li>LEDCOD ;This subroutine converts an unpacked BCD into its seven-segment </li></ul><ul><li> ; LED code </li></ul><ul><li> ;I/P: An unpacked BCD in accumulator </li></ul><ul><li> ;Memory address of the buffer in BC register </li></ul><ul><li> ;O/P: Stores seven-segment code in the output buffer </li></ul><ul><li>: PUSH H - Save HL contents of the caller </li></ul><ul><li>LXI H, CODE - Point index to beginning of 7-segment code </li></ul><ul><li>ADD L - Add BCD digit to starting address of code </li></ul><ul><li>MOV L, A - Point HL to appropriate code </li></ul><ul><li>MOV A, M - Get seven-segment code </li></ul><ul><li>STAX B - Store code in buffer </li></ul><ul><li>POP H - Retrieve (HL) Rp. </li></ul><ul><li>RET - Return to Subroutine UNPACK </li></ul>
  178. 179. Binary to ASCII <ul><li>Write a program to Transfer the byte to the accumulator, Separate the two nibbles (as 09 and 0F). Call the subroutine to convert each nibble into ASCII Hex code and Store the codes in memory locations XX60H AND XX61H. Write a subroutine to convert a binary digit (0 to F) into ASCII Hex code.. An 8-bit binary number (e.g., 9FH) is stored in memory location XX50H. </li></ul><ul><li>Main Program </li></ul><ul><li>LXI SP, STACK - Initialize stack pointer </li></ul><ul><li>LXI H, XX50H - Point index where binary number is stored </li></ul><ul><li>LXI D, XX60H - Point index where ASCII code is to be stored </li></ul><ul><li>MOV A, M - Transfer byte </li></ul><ul><li>MOV B, A - Save byte </li></ul><ul><li>RRC Shift high-order nibble to the position of low- </li></ul><ul><li>RRC order nibble </li></ul><ul><li>RRC </li></ul><ul><li>RRC </li></ul>
  179. 180. Binary to ASCII <ul><li>Main Program – Cont. </li></ul><ul><li>CALL ASCII - Call conversion routine </li></ul><ul><li>STAX D - Store first ASCII Hex in XX60H </li></ul><ul><li>INX D - point to next memory location, get ready to </li></ul><ul><li>store next byte </li></ul><ul><li>MOV A, B - Get number again for second digit </li></ul><ul><li>CALL ASCII </li></ul><ul><li>STAX D </li></ul><ul><li>HLT </li></ul>
  180. 181. Binary to ASCII <ul><li>Subroutine – ASCII </li></ul><ul><li>ASCII ; Converts a binary digit between 0 and F to ASCII Hex code </li></ul><ul><li>;Input: Single binary number 0 to F in the accumulator </li></ul><ul><li>;Output: ASCII Hex code in the accumulator </li></ul><ul><li>:ANI 0FH - Mask high-order nibble </li></ul><ul><li>CIP 0AH - Is digit less than 1010? </li></ul><ul><li>JC CODE - If digit is less than 1010, go to CODE to add 30H </li></ul><ul><li>ADI 07H - Add 7H to obtain code for digits from A to F </li></ul><ul><li>CODE: ADI 30H - Add base number 30H </li></ul><ul><li>RET - Return to Main Program </li></ul>
  181. 182. ASCII to Binary <ul><li>Write a subroutine to convert an ASCII Hex number into its binary equivalent. A calling program places the ASCII number in the accumulator, and the subroutine should pass the conversion back to the accumulator. </li></ul><ul><li>Subroutine </li></ul><ul><li>ASCBIN ;This subroutine converts an ASCII Hex number into its binary </li></ul><ul><li> ;Input: ASCII Hex number in the accumulator </li></ul><ul><li> ;Output: Binary equivalent in the accumulator </li></ul><ul><li>:SUI 30H - Subtract 0 bias from the number </li></ul><ul><li>CPI 0AH - Check whether number is between 0 and 9 </li></ul><ul><li>RC - If yes, return to main program </li></ul><ul><li>SUI 07H - If not, sub. 7 to find number between A & F </li></ul><ul><li>RET - Return to Main Program </li></ul>
  182. 183. BCD Multiplication <ul><li>A multiplicand is stored in memory location XX50H and a multiplier is stored in location XX51H. Write a main program to transfer the two numbers from memory locations to the HL registers and store the product in the Output Buffer at XX90H. Write a subroutine to Multiply two unsigned numbers placed in registers H and L and Return the result into the HL pair. </li></ul><ul><li>Main Program </li></ul><ul><li>LXI SP, STACK </li></ul><ul><li>LHLD XX50H - Place contents of XX50 in L register and </li></ul><ul><li>contents of XX51 in H register </li></ul><ul><li>XCHG - Place multiplier in D and multiplicand in E </li></ul><ul><li>CALL MLTPLY - Multiply the two numbers </li></ul><ul><li>SHLD XX90H - Store the product in locations XX90 and 91H </li></ul><ul><li>HLT - End of the Program </li></ul>
  183. 184. BCD Multiplication <ul><li>Subroutine - MLTPLY </li></ul><ul><li>MLTPLY:MOV A, D - Transfer multiplier to accumulator </li></ul><ul><li>MVI D, 00H - Clear D to use in DAD instruction </li></ul><ul><li>LXI H, 0000H - Clear HL </li></ul><ul><li>MVI B, 08H - Set up register B to count eight rotations </li></ul><ul><li>NXTBIT:RAR - Check if multiplier bit is 1 </li></ul><ul><li>JNC NOADD - If not, skip adding multiplicand </li></ul><ul><li>DAD D - If multiplier is 1, add multiplicand to HL and place partial result in HL </li></ul><ul><li>NOADD:XCHG - Place multiplicand in HL </li></ul><ul><li>DAD H - And shift left </li></ul><ul><li>XCHG - Retrieve shifted multiplication </li></ul><ul><li>DCR B - One operation is complete, decrement counter </li></ul><ul><li>JNZ NXTBIT - Go back to next bit </li></ul><ul><li>RET - Return To Main Program </li></ul>
  184. 185. Interfacing Peripherals <ul><li>Primary Function of MPU is to accept and send data from I/P & to O/P Devices </li></ul><ul><li>These I/O & O/P Devices are called peripherals or I/Os </li></ul><ul><li>Interfacing is to enable the MPU to communicate with the peripherals. </li></ul>
  185. 186. Classification of Interfacing <ul><li>Communication </li></ul><ul><ul><li>Synchronous – Both transmitter & Receiver aer synchronized by same clock pulse </li></ul></ul><ul><ul><li>Asynchronous – Both of Irregular Intervals </li></ul></ul><ul><li>Transfer of Data </li></ul><ul><ul><li>Parallel – Entire word is transmitted at a time </li></ul></ul><ul><ul><li>Serial – One bit at a time over single line </li></ul></ul><ul><li>I/O Types </li></ul><ul><ul><li>Peripheral I/O – Identified with 8 bit address </li></ul></ul><ul><ul><li>Memory mapped I/O – Identified with 16 bit address </li></ul></ul>
  186. 187. Interrupt <ul><li>A computer input that temporarily suspends the normal sequence of operations and transfer control to a special routine. </li></ul><ul><li>Interrupt Process is controlled by Interrupt Enable flip-flop, which can be set or reset by using software Instruction. </li></ul><ul><li>INTR (pin 10) goes high the Microprocessor is interrupted, which is maskable & can be disabled </li></ul><ul><li>Microprocessor also has additional vectored interrupt signals. </li></ul>
  187. 188. Vectored Interrupt <ul><li>Maskable </li></ul><ul><ul><li>RST 7.5 - 003CH </li></ul></ul><ul><ul><li>RST 6.5 - 0034H </li></ul></ul><ul><ul><li>RST 5.5 - 002CH </li></ul></ul><ul><li>Non-maskable </li></ul><ul><ul><li>TRAP - 0024H </li></ul></ul>
  188. 189. Interrupt Instruction RST Instruction Description Bytes Operand OP Code The Interrupt Enable flip-flop is reset and all the interrupts except TRAP are disabled 1 None DI The Interrupt Enable flip-flop is set and all the interrupts are enabled 1 None EI 0038H FF RST 7 0030H F7 RST 6 0028H EF RST 5 0020H E7 RST 4 0018H DF RST 3 0010H D7 RST 2 0008H CF RST 1 0000H C7 RST 0 Call Location Hex Code Mnemonics
  189. 190. Real Time Example to Interrupt <ul><li>Interrupt Process is to compare it to a telephone line with a blinking light instead of ring when you are reading a book. </li></ul>If the line INTR is high and the interrupt is enabled, the microprocessor completes the current instruction, disables the Interrupt Enable flip-flop and sends a signal called INTA – Interrupt Acknowledge (active low). The processor cannot accept any interrupt requests until the interrupt flip-flop is enabled again. If you see a blinking light, you should pick up the receiver, say hello, and wait for a response. Once you pick up the phone, the line is busy, and no more calls can be received until you replace the receiver. Step 3: When the microprocessor is executing a program, it checks the INTR line during the execution of each instruction. Have glance at the light at certain intervals to check whether someone is calling Step 2: The interrupt process should be enabled by writing the instruction EI The Telephone System should be enabled Step 1:
  190. 191. Assuming that the task to be performed is written as a subroutine at the specified location, the processor performs the task. This subroutine is known as a service routine You replace the receiver on the hook Step 6: It saves the memory address of the next instruction on the stack and the program is transferred to the CALL location. You insert a bookmark on the page you are reading Step 5: The signal INTA is used to insert an instruction, preferably, a restart (RST) instruction, through additional hardware. The RST instruction is a 1-byte call instruction that transfers the program control to a specific memory location on page 00H and restarts the execution at that memory location after executing Next Step Assuming that the caller is you roommate, the request may be: It is going to rain today. Will you please shut all the windows in my room? Step 4:
  191. 192. To implement Step 4 in the interrupt process, insert one of RST instructions in the microprocessor by using external hardware and the signal INTA (Interrupt Acknowledge) At the end of the subroutine, the RET instruction retrieves the memory address where the program was interrupted and continues the execution. You go back your book, find your mark, and start reading again Step 8: The service routine should include the instruction EI to enable the interrupt again. This is similar to putting the receiver back on the hook You shut your roommate’s windows Step 7:
  192. 193. Buffer to enable RST 5
  193. 194. 8085 Interrupt & Vector Locations
  194. 195. Instruction to Read & Write Interrupts SIM Data Bytes Serial Output data Serial Data Enable 1 = Enable 0 = Disable Don’t Care Reset RST 7.5 If D 4 = 1 Mask Set Enable D 3 = 1 Mask Interrupts If bits = 1 Description Bytes Operand OP Code Multipurpose Instruction and used to read the 8085 interrupts and Serial Data Input 1 None RIM Multipurpose Instruction and used to implement the 8085 interrupts and Serial Data Output 1 None SIM M5.5 M6.5 M7.5 MSE R7.5 XXX SDE SOD D 0 D 1 D 2 D 3 D 4 D 5 D 6 D 7
  195. 196. RIM Data Bytes Serial Input Data Pending Interrupts 1 = Pending Interrupt Enable 1 = Enable Interrupt Masks 1 = Masked Instruction Set to enable all the interrupts of 8085 EI ;Enable Interrupts MVI A, 08H ;Load bit pattern to enable RST 7.5, 6.5 and 5.5 SIM ;Enable RST 7.5, 6.5 and 5.5 5.5 6.5 7.5 IE I 5 I 6 I 7 SID D 0 D 1 D 2 D 3 D 4 D 5 D 6 D 7
  196. 197. <ul><li>Assuming the microprocessor is completing an RST 7.5 interrupt request, check to see if RST 6.5 is pending. If it is pending, enable RST 6.5 without affecting any other interrupts; otherwise, return to the main program. </li></ul><ul><li>RIM ;Read interrupt mask. </li></ul><ul><li>MOV B,A ;Save mask information </li></ul><ul><li>ANI 20H ;Check whether RST 6.5 is pending </li></ul><ul><li>JNZ NEXT </li></ul><ul><li>EI </li></ul><ul><li>RET ;RST 6.5 is not pending, return to main program. </li></ul><ul><li>NEXT: MOV A, B ;Get bit patter, RST 6.5 is pending. </li></ul><ul><li>ANI 0DH ;Enables RST 6.5 by setting D1 = 0. </li></ul><ul><li>ORI 08H ;Enable SIM by setting D3 = 1 </li></ul><ul><li>SIM </li></ul><ul><li>JMP SERV ;Jump to service routine for RST 6.5 </li></ul>
  197. 198. Serial I/O <ul><li>I/O requirements </li></ul><ul><ul><li>I/O Mapped & Memory Mapped </li></ul></ul><ul><li>Transmission </li></ul><ul><ul><li>Synchronous Vs. Asynchronous </li></ul></ul><ul><ul><li>Simplex & Duplex (Half or Full) </li></ul></ul><ul><ul><li>Parity Check (Odd or Even) with bit D 7 = 1: Even </li></ul></ul><ul><li>BAUD </li></ul><ul><ul><li>No. of Signals / Second </li></ul></ul><ul><li>Modem </li></ul><ul><ul><li>FSK (Send bits according to frequency) </li></ul></ul>
  198. 199. 8155/8156 Programmable I/O & Timer <ul><li>Features </li></ul><ul><li>40 Pins </li></ul><ul><li>256 Bytes of R/W Memory </li></ul><ul><li>3 Programmable I/O Ports </li></ul><ul><ul><li>Two 8-bit parallel I/O ports (A and B) </li></ul></ul><ul><ul><li>One 6-bit port (C) </li></ul></ul><ul><li>Programmable 14 bit binary counter / Timer </li></ul><ul><li>Multiplexed Address & Data Buses </li></ul>
  199. 200. Pin Configuration PC 3 PC 4 TIMER IN RESET PC 5 TIMER OUT IO/M CE RD WR ALE AD 0 AD 1 AD 2 AD 3 AD 4 AD 5 AD 6 AD 7 V ss V cc PC 1 PC 2 PC 0 PB 7 PB 6 PB 5 PB 4 PB 3 PB 2 PB 1 PB 0 PA 7 PA 6 PA 5 PA 4 PA 3 PA 2 PA 1 PA 0 8155 / 8156 1 2 3 4 5 6 7 8 9 10 11 12 14 14 15 16 17 18 19 20 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21
  200. 201. Block Diagram 8155 256 X 8 Static RAM A B C Timer 8 8 6 Port A Port B Port C PA 0-7 PB 0-7 PC 0-5 AD 0-7 IO/M CE ALE RD WR RESET Timer CLK TIMER OUT Vcc (+5V) Vss (0V)
  201. 202. Expanded Block Diagram AD 7 AD 0 Port A Port B Port C Timer LSB Timer MSB Data Bus Control Register 5 4 Internal 3 Decoder 2 1 0 Internal Latch A 1 A 2 A 3 Timer MSB Timer MSB Port C Port B Port A Control Register A 7 CE
  202. 203. <ul><li>Port Address A 15 – A 8 is duplicated by A 7 – A 0 </li></ul><ul><li>A 15 & A 14 are Active Low Enable </li></ul><ul><li>A 13 , A 12 & A 11 are give as input to 8205 decoder </li></ul><ul><li>O 4 is give to the chip enable of 8155 </li></ul>Timer MSB 1 0 1 Timer LSB 0 0 1 Port C 1 1 0 Port B 0 1 0 Port A 1 0 0 Control Register 0 0 0 Control A 0 A 1 A 2
  203. 205. <ul><li>To enable o4 of 8205 A 13 =1, A 12 =0, A 11 =0 </li></ul><ul><li>The Following table give the address of Ports of 8155 </li></ul>25H 24H 23H 22H 21 H 20 H HEX Code 1 1 1 1 1 1 A 13 0 0 0 0 0 0 A 12 0 0 0 0 0 0 A 11 Timer MSB 1 0 1 Timer LSB 0 0 1 Port C 1 1 0 Port B 0 1 0 Port A 1 0 0 Control Register 0 0 0 Control A 0 A 1 A 2
  204. 206. Control Register 00 NOP 01 STOP/NOP 10 STOP after TC 11 START IE A IE B 1 – Enable 0 – Disable Port A Port B 0 – Input ; 1 - Output D 0 D 1 D 2 D 3 D 4 D 5 D 6 D 7 INTR A BF A STB A INTR B BF B STB B 0 1 INTR A BF A STB A O O O 1 0 O O O O O O 1 1 I I I I I I 0 0 PC 0 PC 1 PC 2 PC 3 PC 4 PC 5 D 2 D 3
  205. 207. Interfacing 7 segment LED Display <ul><li>Design 2 7-segment LED displays using Ports A & B of 8155 to display the data bytes. </li></ul><ul><li>Solution </li></ul><ul><li>HP 5082/7340 are inbuilt decoders- is attached to Port A </li></ul><ul><li>9370 decoder & 7-segment LEDs is attached with Port B </li></ul><ul><li>The Data Byte separated into nibbles and displayed </li></ul>
  206. 209. <ul><li>Control Word </li></ul><ul><li>Program </li></ul><ul><li>MVI A, 03H ; Initialize ports A and B as output ports. </li></ul><ul><li>OUT 20H </li></ul><ul><li>MVI A, BYTE1 </li></ul><ul><li>OUT 21H ; Display BYTE1 at port A. </li></ul><ul><li>MVI A, BYTE2 </li></ul><ul><li>OUT 22H ; Display BYTE2 at port B. </li></ul><ul><li>HLT </li></ul>= 03H No Effect on Timer Not Applicable Port C Is not Being used Port B As O/P Port A As O/P 1 1 0 0 0 0 0 0 D 0 D 1 D 2 D 3 D 4 D 5 D 6 D 7
  207. 210. Timer in 8155 <ul><li>Two 8bit Registers </li></ul><ul><li>14 bits are used for counters </li></ul><ul><li>2 bits for Timer Mode </li></ul><ul><li>Timer can be stopped </li></ul><ul><ul><li>At midst of Terminal Count </li></ul></ul><ul><ul><li>At end of Terminal Count </li></ul></ul>
  208. 211. Timer T 0 T 1 T 2 T 3 T 4 T 5 T 6 T 7 T 8 T 9 T 10 T 11 T 12 T 13 M 1 M 2 Continuous Pulse upon every TC 1 1 Single Pulse upon TC 0 1 Continuous Square Wave 1 0 One Square Wave 0 0 Description M 1 M 2
  209. 212. Example for using Timer <ul><li>The System Clock is connected to Timer IN of 8155. The clock has 3MHz Frequency. Write a program to produce continuous square wave with a frequency of 1KHz. Includes a start timer command, disable the port interrupts, make Port B&C as O/P ports and make Port A as I/P port. </li></ul><ul><li>LSB Timer </li></ul><ul><li>MSB Timer </li></ul><ul><li>Control Word </li></ul><ul><li>Timer </li></ul><ul><ul><li>3000 10 = 0BB8H </li></ul></ul><ul><ul><li>Timer M 2 , M 1 = 0,1 (Continuous Square Wave) </li></ul></ul><ul><li>Control Word </li></ul><ul><ul><li>D0, D1, D2 & D3 = 0,1,1&1 respectively (Port A is I/P & Port B&C are O/P </li></ul></ul><ul><ul><li>D6, D7 = 1, 1 (Start the Timer) </li></ul></ul>0 0 0 1 1 1 0 1 1 1 0 1 0 0 1 0 0 1 1 1 0 0 1 1
  210. 213. Program <ul><li>MVI A, B8H - Setting LSB of Timer </li></ul><ul><li>OUT 24H - Loading LSB Timer </li></ul><ul><li>MVI A, 4BH - Setting MSB Timer </li></ul><ul><li>OUT 25H - Loading MSB Timer </li></ul><ul><li>MVI A, CEH - Setting Control Word </li></ul><ul><li>OUT 20H - Loading Control Word </li></ul>
  211. 214. 8355 / 8755 <ul><li>2K memory of EPROM </li></ul><ul><li>2 8-bit I/O Ports </li></ul><ul><li>Data Direction Register </li></ul>
  212. 215. Pin Configuration CE 1 CE 2 CLK RESET N.C. READY IO/M IOR RD IOW ALE AD 0 AD 1 AD 2 AD 3 AD 4 AD 5 AD 6 AD 7 V ss V cc PB 7 PB 6 PB 5 PB 4 PB 3 PB 2 PB 1 PB 0 PA 7 PA 6 PA 5 PA 4 PA 3 PA 2 PA 1 PA 0 A 10 A 9 A 8 8355 / 8755 1 2 3 4 5 6 7 8 9 10 11 12 14 14 15 16 17 18 19 20 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21
  213. 216. Block Diagram 8355/8755 2K X 8 EPROM A B 8 8 Port A Port B PA 0-7 PB 0-7 AD 0-7 READY CE 2 ALE RD IOW RESET Prog/CE 1 V DD V CC V SS CLK IOR IO/M A 8-10
  214. 218. Address Bits DDR B 1 1 X 0 0 0 0 0 DDR A 0 1 X 0 0 0 0 0 Port B 1 0 X 0 0 0 0 0 0 AD 0 Port A Selected Register 0 X 0 0 0 0 0 AD 1 AD 2 A 11 /AD 3 A 12 /AD 4 A 13 /AD 5 A 14 /AD 6 A 15 /AD 7
  215. 219. Interfacing 8755 I/O Ports
  216. 220. Example <ul><li>Write initialization instructions to configure port A and port B as output ports, and display 32H at port A </li></ul><ul><li>Program: </li></ul><ul><li>MVI A, FFH ; Control word to set up all bits as output bits </li></ul><ul><li>OUT 02H ; Initialize port A as output </li></ul><ul><li>OUT 03H ; Initialize port B as output </li></ul><ul><li>MVI A, 32H </li></ul><ul><li>OUT 00H ; Display 32H at port A </li></ul><ul><li>HLT </li></ul>
  217. 221. 8279 Programmable Keyboard / Display Interface <ul><li>Simultaneous Keyboard Display Operation </li></ul><ul><li>8 character keyboard FIFO </li></ul><ul><li>2-key lockout or N-Key Roll over </li></ul><ul><li>Dual 8 or 16 numerical Display </li></ul><ul><li>Single 16 character display </li></ul><ul><li>Right or Left Entry 16 Byte display RAM </li></ul>
  218. 222. Major Segments <ul><li>Keyboard </li></ul><ul><ul><li>Connected to 64 contact key matrix </li></ul></ul><ul><ul><li>Entries are stored in FIFO </li></ul></ul><ul><ul><li>Interrupt sent for every entry </li></ul></ul><ul><li>Display </li></ul><ul><ul><li>Has 16 characters scanned display </li></ul></ul><ul><ul><li>16 character memory </li></ul></ul>
  219. 223. Pin Configuration RL 2 RL 3 CLK IRQ RL4 RL5 RL6 RL7 RESET RD WR DB 0 DB 1 DB 2 DB 3 DB 4 DB 5 DB 6 DB 7 V ss V cc RL 1 RL 2 CTRL/STB SHIFT SL 3 SL 2 SL 1 SL 0 OUT B 0 OUT B 1 OUT B 2 OUT B 3 OUT A 0 OUT A 1 OUT A 2 OUT A 3 BD CS A 0 8279 1 2 3 4 5 6 7 8 9 10 11 12 14 14 15 16 17 18 19 20 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21
  220. 224. Logical Symbol IRQ RL 0-7 Data Bus SHIFT RD CNTL/STB WR CS SL 0-3 A 0 OUT A 0-3 RESET OUT B 0-3 CLK BD 8 8 4 4 4 V cc V ss Scan Display Data Key Data CPU Interface
  221. 225. Pin Names Interrupt Request Output O IRQ Buffer Address I A0 Write Input I WR Read Input I RD Chip Select I CS Reset Input I RESET Clock Input I CLK Data Bus (Bi Directional) I/O DB 0-7 Blank Display Output O BD Display (B) Outputs O OUT B 0-3 Display (A) Outputs O OUT A 0-3 Control Strobe Input I CNTL/STB Shift Input I SHIFT Return Lines I RL 0-3 Scan Lines O SL 0-3
  222. 226. Logic Block Diagram
  223. 227. Different Sections <ul><li>Keyboard Section </li></ul><ul><li>Scan Section </li></ul><ul><li>Display Section </li></ul><ul><li>MPU Interface Section </li></ul>
  224. 228. Programming 8279 <ul><li>left or right entry and key rollover. </li></ul><ul><li>clock frequency prescaler. </li></ul><ul><li>starting address and incrementing mode of the FIFO RAM. </li></ul><ul><li>RAM address to read and write data and incrementing mode. </li></ul><ul><li>blanking format. </li></ul>
  225. 230. Circuit <ul><li>The 8279 Programmable Keyboard / Display Interface </li></ul><ul><li>A Matrix keyboard with 22 keys </li></ul><ul><li>Six seven-segment LEDs: DS1-DS6 </li></ul><ul><li>74LS156 decoder with open collector outputs. </li></ul><ul><li>Transistors as current Drivers </li></ul><ul><li>8205 decoder for the decoding logic </li></ul>
  226. 231. Port Address <ul><li>Keyboard/Display Mode </li></ul><ul><li>MVI A, 00H Control word to set mode: Left 0 0 0 D D K K K </li></ul><ul><li>entry, 8-character, 2-key lockout </li></ul><ul><li>encoded scan keyboard </li></ul><ul><li>STA 1900H Initialize 8279 </li></ul>
  227. 232. <ul><li>PUSH H </li></ul><ul><li>PUSH PSW Read FIFO RAM: Control Word </li></ul><ul><li>LXI H, 1900H Keyboard control 0 1 0 A1 X A A A </li></ul><ul><li>register address </li></ul><ul><li>MVI M, 40H Control word to read </li></ul><ul><li>from keyboard </li></ul><ul><li>DCR H Data Port Address 1800H </li></ul><ul><li>MOV A, M Read data Data Format D7 D6 D5 D4 D3 D2 D1 D0 </li></ul><ul><li>ANI 3FH Mask D7 and D6. CNTL SHFT ROW COL </li></ul><ul><li>CNTL, Shift keys are </li></ul><ul><li>not being used </li></ul><ul><li>STA IBUFF Store in R/W memory </li></ul><ul><li>POP PSW </li></ul><ul><li>POP H </li></ul><ul><li>RET </li></ul>
  228. 233. 8254 Programmable Interval Timer <ul><li>40 Pin </li></ul><ul><li>3 independent Counters </li></ul><ul><li>5 Modes of Operations </li></ul>
  229. 234. Signals of 8254
  230. 235. Modes of Operations <ul><li>Mode 0 </li></ul><ul><li>Interrupt on Terminal Count </li></ul><ul><ul><li>Count Begins one clock pulse after the count has been written in to counter </li></ul></ul><ul><ul><li>GATE 0 = 1, then counter 0 counts down </li></ul></ul><ul><ul><li>CLK 0 pulse then the counter decrements by 1 </li></ul></ul><ul><ul><li>GATE 0 = 0. then counts inhibited </li></ul></ul><ul><li>The operation is same for all the 3 counters </li></ul>
  231. 236. Read/Write Operations
  232. 237. Control Word
  233. 238. Memory, Port & Timer Address
  234. 239. Control Word for 8255A#1
  235. 240. Control Word for 8255A#2
  236. 241. Control Word for 8254
  237. 242. Program <ul><li>MVI A, CWR1 ;Get 8255A #1command word </li></ul><ul><li>OUT CR1 </li></ul><ul><li>MVI A, CWR2 ;Get 8255A #2 command word </li></ul><ul><li>OUT CR2 </li></ul><ul><li>MVI A, BLMSET ;Get byte to blank the LIMIT SET lamp. </li></ul><ul><li>OUT PORTC2 ;Send to port C of 8255 #2 </li></ul><ul><li>CALL RALARM ;Reset alarms. </li></ul><ul><li>CALL STCNTR0 ;Start counter 0. </li></ul><ul><li>EI ;Enable interrupts </li></ul><ul><li>RET ;End of subroutine. </li></ul>
  238. 243. Temperature Monitoring System <ul><li>General Controls </li></ul><ul><li>µprocessor based system is designed to control the temperature of a water bath, by controlling a heater ON or OFF </li></ul><ul><li>Accuracy of  1º C </li></ul><ul><li>Temperatures can be set by switches </li></ul><ul><li>7 segment Display is used to display the temperature </li></ul><ul><li>This involves both hardware & software design </li></ul>
  239. 244. Hardware Design <ul><li>A transducer is used to convert temperature into an equivalent analog electrical quantity </li></ul><ul><li>The analog signal is converted in digital by A/D Converters </li></ul><ul><li>A relay is used to switch heater ON & OFF </li></ul><ul><li>Two digit 7-segment display is used to display the temperature </li></ul><ul><li>All these hardware are interface to MPU through I/O ports </li></ul><ul><li>EPROM is used to store the Software </li></ul>
  240. 245. Block Diagram of Hardware Design Address, Data & Control Busses MPU EPROM 8 Bit I/O Port Relay Driver & Relay 8 bit I/O Port 8 Bit I/O Port Temp. Transducer & Buffer A/D Converter 7-segment Displays Switches SOD SID
  241. 246. Detailed Block Diagram
  242. 248. <ul><li>Memory </li></ul><ul><ul><li>No RAM is necessary </li></ul></ul><ul><ul><li>EPROM 2716 is used to used (2KB of Memory) </li></ul></ul><ul><li>I/O Port </li></ul><ul><ul><li>System requires 26 I/O lines (17 O/P & 9 I/P) </li></ul></ul><ul><ul><li>8255 (24 Ports) with SID & SOD </li></ul></ul><ul><li>A/D Converter </li></ul><ul><ul><li>ADC chips are quite costlier when compared to DAC. As fast conversion is not necessary </li></ul></ul><ul><ul><li>ADC can be implemented by using an external DAC and a comparator with MPU as Controller </li></ul></ul>
  243. 249. <ul><li>LED Display </li></ul><ul><ul><li>2 7-segment display is used </li></ul></ul><ul><li>Switches </li></ul><ul><ul><li>One Thumb wheel Switch is used(4 toggle switches) </li></ul></ul><ul><li>Transducer & Buffer </li></ul><ul><ul><li>A thermistor with 5K  is used at 25 ºC </li></ul></ul><ul><li>Relay & relay driver </li></ul><ul><ul><li>Temperature of Bath is controlled by immersion heater ON or OFF </li></ul></ul><ul><ul><li>Immersion heater is ON or OFF by a relay </li></ul></ul><ul><ul><li>This controlled by SID & SOD of MPU </li></ul></ul>
  244. 250. Software Design (Algorithm) <ul><li>Initialize I/O port of 8255. </li></ul><ul><li>ADC is performed by successive approximation </li></ul><ul><li>Getting Temperature for Bath. </li></ul><ul><li>Display measured temperature in LED Display </li></ul><ul><li>Read the desired temperature from Switches </li></ul><ul><li>Comparing measured temp. with desired temp. & making SOD low or high </li></ul><ul><li>Generate a delay of 2 Second </li></ul>
  245. 251. Flowchart Start Initialize I/O ports A/D Converter Get Desired Temp. Display measured Temp Read Desired Temp. Make Relay OFF .5 Sec Delay Make Relay ON Is MT = DT Yes NO
  246. 252. Program Get temp. from Table MOV A, M MVI H, 02H Table starts from 0200H MOV L, C NEXT: JMP REP Send next Digital Value INR C COUNTD: Check for Equality JMP NEXT JNC COUNTD Check for non-Equality RAL Get Comparator O/P RIM JNZ LOOP DCR D Wait for DAC MVI D, 08H Send to DAC OUT 00H MOV A, C REP: AGAIN: Initial Data Value MVI C,00H OUT 03H Initialize Port A & B as O/P, C as I/P MVI A, 89H
  247. 253. Program Switching OFF relay Else ON relay MVI A, 40H ON: SIM JMP DELAY Goto AGAIN to repeat the steps JMP AGAIN JNZ L2 DCR D JNZ L1 DCR E L1: MVI E, 00H L2: Time Delay MVI D, 00H DELAY: SIM MVI A, C0H OFF: JZ OFF If Temp. is High or Equal OFF relay JC OFF Compare Temp. in Mem. & Acc. CMP M Get switch setting IN 02H Display it OUT 01H

×