.Introducing Microprocessors

A new series on understanding microprocessors and how they work.

By Mike Tooley

he general learning objectives for 1.3.2 State the function of each of the The " equivalent" referred Tpart one of Introducing Micro­ principal internal elements of a repre­ to in the table provides us with a rough processors are that readers should be sentative microcomputer system. measure of the complexity of in­ able to: 1.3.3 Explain the bus system used to tegrated circuit and simply gives the (a) understand the terminology used to link the internal elements of a equivalent number of standard logic describe microcomputer and micro­ microcomputer system. gates. A logic gate is a basic circuit ele­ based systems 1.3.4 Distinguish between the following ment capable of performing a logical (b) identify the major logic families types of bus; address, data and control. function (such as AND, OR, NAND or and scale of integration employed NOR). A basic logic gate (e.g. a stand­ within integrated circuits Related Theory ard TTL two-input AND) would typi­ (c) draw a diagram showing the ar­ Explain the binary and hexadecimal cally employ the equivalent of six tran­ chitecture of a representative micro­ number systems. sistors, three diodes and six . system and state the function Convert binary, hexadecimal and At this stage, readers need not worry of the principal internal elements decimal numbers over the range 0 to too much about the function of a logic (d) understand binary and 65535 (decimal). gate as we shall be returning to this hexadecimal number systems and con­ Explain how negative numbers are later on. Readers need only be aware vert from/to decimal represented in microprocessor sys­ that such devices form the basis of cir­ The specific objectives for this part are tems. cuits which can perform logical as follows: Perform addition and subtraction of decisions. binary and hexadecimal numbers over Integrated circuits are encapsulated 1.1 Terminology the range 0 to 255 (decimal). in a variety of packages but the most 1.1.1 State the meaning of any of the Note: Rather than publish a complete popular type (and that with which most terms listed in the glossary 1.1.2 Distin­ glossary of terms, we shall be produc­ readers will already be familiar) is the guish between the terms; computer, ing a mini-glossary for each part; intro­ plastic dual in-line (DIL) type. These microprocessor, microcomputer, and ducing new terms as we progress are available with a differing number of single-chip microcomputer. through the series. pins depending upon the complexity of the in question and, Integrated Circuits in particular, the need to provide ex­ The vast majority of today's electronic ternal connections to the device. systems rely on the use of integrated Conventional logic gates, for ex­ 1.2 Integrated Circuit circuits in which hundreds of ample, are often supplied in 14- pin or Terminology and Logic thousands of components are fabri­ 16-pin DIL packages while Families cated on a single chip of silicon. A rela­ microprocessors (and their more com- 1.2.1 Define the terms SSI, MSI, LSI tive measure of the number of in­ and VLSI as applied to integrated cir­ dividual semiconductor devices within cuits. the chip is given by referring to its 1.2.2 State the characteristics of "scale of integration", as shown below: CMOS and TTL semiconductor tech­ nologies. Scale of. Logic gate 1.2.3 State the basic properties of integration Abbreviation equivalent CMOS and TTL logic families. Small SSI 1 to10 Medium MSI 10 to 100 1.3 System Architecture Large LSI 100 to 1000 1.3.1 Draw a block diagram showing Very large VLSI 1000 to 10000 the internal architecture of a repre­ Super large SLSI 10000 to 100000 Fig. 1 Some common DJL package sentative microcomputer system. outlines (top view).

E & TT March 1988 31 Introducing Microprocessors plex support devices) often require 40- CMOS devices are sometimes also pins or more. Fig. 1 shows some com­ given a suffix letter; A to denote the mon DIL package outlines together "original" (now obsolete) unbuffered with pin numbering. It should be noted series, and B to denote the improved that these are TOP views of the (buffered) series. A UB suffix denotes devices, i.e. they show how the device an unbuffered B-series device. appears when viewed from the com­ ponent side of the PCB, NOT from the Problem 1.2 underside. To which logic families do each of the In each case, the pins of the IC are following devices belong? numbered sequentially (starting at the (a) 7407 indentation) moving in an anti-clock­ (b) 74LS74 wise direction. Thus, in the case of a (c) 4052 14-pin DIL package viewed from the a. Using CMOS technology. top, pins one and 14 appear respective­ Power supplies ly on the left and-right-hand side of the Most TTL and CMOS logic systems indentation. are designed to operate from a single Problem 1.1 supply voltage rail of nominally + 5V. Fig. 2 shows the outline of an 8-pin With TTL devices, it is important for DIL device viewed from above. Iden­ this voltage to be very closely regu­ tify the pin numbers for this device. lated. Typical TTL IC specifications call for regulation of better than 5% INPUTS{: OUTPUT (i.e. the supply voltage should not fall outside the range 4.75V to 5.25V). CMOS logic devices are fortunately very much more tolerant of their supp­ ly voltage than their TTL counterparts. Most CMOS devices will operate from 0 b. Using TTL technology. a supply rail of anything between + 3V Fig. 2. An 8-pin DIL package. Fig. 3. Representative circuitry of and + 15V. This, coupled with a mini­ two-input AND gates. mal requirement for supply current (a Logic Families CMOS gate typically requires a supply The integrated circuit devices on which must be stressed that they have IDEN­ current of only a few microamps in the modern digital circuitry depends TICAL logical functions. quiescent state) makes them eminently belong to one of the other of several suited to portable battery powered "logic families". Readers should note TTL logic equipment. this term refers to the type of semi con­ The most common range of conven­ TTL devices require considerably ductor technology employed in the tional TTL logic devices is known as more supply current than their CMOS fabrication of the integrated circuit. the "74" series. These devices are, not equivalents. A typical TTL logic gate The semiconductor technology surprisingly, distinguished by the prefix requires a supply current of around employed in the fabrication of an in­ number 74 in their coding. Thus 8mA; approximately 1000 times that of tegrated circuit is instrumental in devices coded with the numbers 7400, its CMOS counterparts when operat­ determining its characteristics. This 7408, 7432, and 74121 are all members ing at a typical switching speed of encompasses such important criteria of this family which is often referred to 10kHz. as supply voltage, power dissipation, as "Standard TTL". Other versions (or switching speed, and immunity to "subfamilies") of standard TTL exist noise. and these are distinguished by ap­ CMOS versus TTL The most popular logic families, at propriate letters placed after the "74" Having spent some time in discussing least as far as the more basic general coding. Where "Low Power Schottky" the merits of CMOS and TTL devices purpose devices are concerned, are technology is used in the manufacture it is now worth summarizing three of Complementary Metal Oxide Semi­ of a TTL logic gate, for example, the important differences between conductor (CMOS) and device coding include the letters "LS". these logic families in tabular form: Logic (TTL), TTL also has a number Thus a 74LSOO device is a Low Power of sub-families including the popular Schottky version of a standard 7400 Problem 1.3 Low Power Schottky (LS-TTL) device. Which would be most variants. suited for use in a piece of equipment which has to operate over long periods For the curious we have shown the CMOS Logic from dry batteries? internal circuitry of representative The most popular CMOS family is the CMOS and TTL two-input AND gates "4000" series and devices have an ini­ Microprocessors in Fig. 3. Despite the obvious dis­ tial prefix of 4. Thus 4001, 4174, 4501 Having dealt with the basic building similarity of these two arrangements, it and 4574 are all CMOS devices. blocks of digital circuits we have at last 32 E & TTMIII'Ch 1988 Introducing Microprocessors

~ - CMOS TTL puter installation. The vast saving in hardware development can usefully be Speed of operation Relatively slow Fast devoted to the software aspects of a I (power consumption (power consumption project and future modifications ca n increases as switching substantially simply involve the substitution 0 f speed increases) constant) "firmware" (ROM based software).

Power consumption Negligible Appreciable Bits, Bytes and Buses (but see above) An 8-bit microprocessor fetches an d outputs data m groups of 8- bit s Supply voltage Operates over a wide Must be closely (known as "bytes"). This data is move d voltage range regulated at, or around on eight separate line s (typically 3V to 15V) near5V (labelled DO to D7) which collective! y fo r m a " data bus " . For the cunous, the arrived at the point at which we can in­ something of a minor miracle - a device word "bus" is a contraction of the troduce the microprocessor. which could replace countless other Greek work "omnibus" which simply Microprocessors are VLSI and SLSI chips and which could address a stag­ means "to all", thus aptly describing integrated circuit devices which are gering 16K of memory! By modern the concept of a system of wiring which capable of accepting, decoding and ex­ standards, the 8008 is extremely crude links together all of the components of ecuting instructions presented to them but it was not long before Intel intro­ a microprocessor system using a com­ in binary coded form. Microprocessors duced another device, the 8080. This mon set of shared lines. thus form the heart of all microcom­ time NMOS technology was employed Microprocessors determine the puter systems in which they act as the instead of the PMOS technology which source of data (when it is being (CPU). was used in the 8008. The 8080 had 16 "read") and the destination of data Despite this, the majority of address lines (thus being able to ad­ (when it is being "written") by output­ microprocessors are not capable of dress 64K of memory) and 78 software ting the location of the data in the form providing the complete range of instructions for the programmer to use. of a unique "address". This process in­ facilities expected of a computer (i.e. The 8080 was an instant success and volves placing a binary pattern on an input, processing, memory and out­ led the way to enhanced devices such "address bus". In the case of 8-bit put). Microprocessors require a cer­ as the 8085 and the Z80. microprocessors, the address bus in­ tain amount of external hardware and Other manufacturers were also variably comprises 16 separate lines, other support devices, not the least im­ developing microprocessor chips hard labelled AO to A15. portant of which are those which on the heels of Intel. These included The address at which the data is to be provide a memory for the sequences of Motorola (with the 6800) and MOS placed or from which it is to be fetched software instructions (i.e. programs) Technology (with the 6502). In sub­ can either constitute part of the and transient information (i.e. data) sequent years industry has not been "memory" of the system (i.e. RAM or used during processing. content to stand still and much effort ROM) or can be considered to be Some specialized microprocessors has been devoted into huge advances "input/output" (I/0). The allocation of incorporate their own internal memory into 16 and 32-bit technology. Despite the 64K memory address range of an 8- for data and program storage as well as this, all of these simple 8-bit bit microprocessor can usefully be input/output ports for the connection microprocessors (and their various en­ described using a "memory map". We of external devices such as keyboards hancements and derivatives) are still in shall discuss this in greater detail later and displays. These devices are aptly common use today. in the series. known as "single-chip Costs have fallen very significantly A further bus is used for a variety of microcomputers" and they are ideal and it is eminently possible to put general housekeeping functions such for use in low-cost stand- alone control together a microprocessor system as determining the direction of data systems. (comprising CPU and a handful of movement (i.e. whether a "read" or Microprocessors are often divided support chips) at a very moderate cost. "write" operation is being performed), into categories depending upon the Therefore, if one had the task of and placing the machine in an orderly size of the binary number on which designing, for example, a simple con­ state of power-up. This bus is known as they fundamentally perform opera­ trol system, one would almost certainly the "control bus" and often has be­ tions. Most modern microprocessors use a microprocessor (or single-chip tween five and 13 lines depending perform operations on groups of either microcomputer) to form the basis of upon the microprocessor. eight or 16 binary digits (bits). Whilst the controller. 16-bit microprocessors tend to be Such a system would not only be more powerful than their 8-bit System Architecture counterparts this is unimportant in capable of fulfilling all of the functions many simple applications. of its conventional counterpart but it We have already identified the prin­ would also provide a far more sophisti­ cipal elements within a microprocessor The first generation of 8-bit cated means of processing our data system as CPU (i.e. the microproces­ microprocessors appeared a little over coupled with the ability to store it and sor), RAM, ROM, and I/0. Before 14 years ago in the shape of an Intel examine it at a later date or even trans­ showing how they are interconnected device, the 8008. At the time, this was mit it to a remote supervisory com- within a typical microprocessor system, E& TTMBI'ch 1988 33 Introducing Microprocessors it is worth briefly restating the function of each: ADDRESS BUS Central processing unit (CPU) ~J The central processing unit in a microcomputer is a single VLSI v--=> ~- EXTERNAL device, the microprocessor. The device CPU ROM RAM !10 accepts instructions and data for Qf:VICES processing. It also provides control and K=>" synchronizing information for the rest of the system. We shall look more closely at the function of the microprocessor in Part Two. DATA BUS J I Random Access Memory I I I I (RAM) CONTROL BUS ~ All microprocessors require access to Fig. 4. Principal elements of a microprocessor system. read/write memory and, while single­ chip microcomputers contain their ' own low-capacity area of read/write memory, read/write memory is in­ t J_J. ~;-- l ~ variably provided by a number of semi­ I I conductor random access memories (RAM). p Read-only Memory (ROM) {'L ~'L Jj Microprocessors generally also require more permanent storage for their con­ trol programs and, where appropriate 11 '--· operating systems and high-level lan­ guage interpreters. This facility is in­ Fig. 5. Microprocessor system (see problem 1.4 ). variably provided by means of semi­ conductor read-only memories driven by address decoding logic (not only the RAM is selected and them­ (ROM). shown in Fig. 4). The inputs of the ad­ ternal buffers in the ROM and 1/0 dress decoding logic are derived from chips are kept in the tri-state output Input/Output Devices (1/0) one, or more, of the address bus lines. condition. To fulfil any useful function, the The address decoder effectively microprocessor needs to have links divides the available memory into Problem 1.4 with the outside world. These are blocks which each correspond to a par­ The diagram shown in Fig. 5 repre­ usually supplied by means of one, or ticular support device. Therefore, sents a microprocessor system. Com­ more, VLSI devices which may be con­ where the processor is reading and pare this diagram with that shown in figured under software control and are writing to RAM, for example, the ad­ Fig. 4 and hence label the diagram thus said to be "programmable". 1/0 dress decoding logic will ensure that fully. devices fall into two general categories; Table 1 Powers of two "parallel" (a byte is transferred at a ·-·------·- Number Systems time) or "serial" (one byte is trans­ n 2" Unfortunately, the decimal or decimal ferred after another along a single 0 1 number system with which we are all line). 1 2 very familiar, is not at all appropriate The basic configuration of a 2 4 to microcomputers. The reason is microprocessor system is shown in Fig. 3 8 simply that electronic logic circuits are 4, the principal elements; microproces­ 4 16 used on devices which have only two sor, ROM, RAM, and I/0 have been 5 32 states (variously known as "on/off" shown. Note that the three bus sys­ 6 64 "high/low'', and "true/false"). The tems; address, data, and control are 7 128 8 256 number system most appropriate is used to link the elements and thus an therefore binary in which only two essential requirement of a support 9 512 10 1024 digits (0 and 1) are used. Powers of two device is that it should have "tri- state" 11 2048 are shown in Table 1. outputs. It can thus be disconnected 12 4096 The process of converting binary to from the bus when it is not required. 13 8192 decimal and decimal to binary is quite Support devices (such as ROM, 14 16384 straightforward. The binary number RAM, etc.) are fitted with select or 15 32768 101, for example, can be converted to enable inputs. These lines are usually decimal as follows: 34 E & TT Mtuch 1988 Introducing Microprocessors

Problem 1.6 i = 2 Convert the following decimal num­ 0 0 0 bers to binary: (a) 33 The second method involves succes­ (b) 100 sively diving the decimal number by (c) 213 two and noting down the remainder each stage. The binary number is then Hexadecimal formed by reading the remainders as The binary number system is somewhat shown in the example below (note that tedious for human use since numbers 5 the least significant remainder be­ of any appreciable size are rather dif­ comes the most significant bit of the hi· ficult to handle. For this reason we set­ Now, taking a somewhat more dif­ nary number!). tle on the hexadecimal (base 16) num­ ficult example, let's convert the binary Suppose we wish to convert the ber system. This has the advantage that number 11001010 to decimal. We shall decimal number 50 to binary. it is relatively simple to convert from again write the number using column hexadecimal to binary and the headings but this time we shall simply hexadecimal numbers which can ap­ ignore the zeros in our addition: 2~ 25 remainder 0 ------. pear on an 8-bit data bus can be repre­ 27 = 128. 26 = 64 25 = 32 sented using just two digits (rather 1 1 0 than the eight binary digits which L__ _ ~ 128 2~ would otherwise be necessary). 12 remainder 1------, Since the hexadecimal numbering I • + 64 system employs more than 10 digits we 2l~ have to make use of the first six letters • + 8 I 6 remainder 0-----, of the alphabet ·to represent those 0 1 24 = 16 23 = 8 22 2 4 equivalent. to the decimal numbers 10 + 2 to 15. Hexadecimal digits thus range I 3 remainder 0----, from 0 to F as shown below left. 202 Numbers in excess of fifteen will, of i ~ 2 2° = 1 2l2_ course, require more than one There are two basic methods for con­ hexadecimal digit. Suppose, for ex­ verting decimal to binary. One involves ~ "maiode< 1~ ample, we wish to convert the taking the decimal number and sub­ 2 hexadecimal number 2A to decimal. tracting from it successively smaller Using a similar technique to that which numbers which are themselves powers 0 remainder 1 ~ l we employed when converting from bi­ of two. Where a power of two can be nary to decimal we would arrive at: subtracted (to leave zero or a 1 1 0 0 1 0 remainder), a 1 is placed in the ap­ propriate column of the binary num­ Therefore 50 decimal is equal to ber. This all sounds very much more 110010 binary. 2 ~10 difficult than it really is, so here is a Which of the two methods you ._I-----· + 32 simple example to illustrate the employ is entirely a matter of process. preference. If you can easily spot the 42 Suppose that we wish to convert the powers of two present in. a decimal Now, suppose that we wish to convert decimal number 21 to binary. The number it is probably best to use the 2A to binary.rather than decimal. This highest power of two which can be first method. If, on the other hand, you is an easy process (if is NOT necessary taken away from 21 is 24 ( = 16). This are uncertain ·as to which powers of to convert to decimal as an inter­ leaves a remainder of 21 - 16 = 5. 23 two make up a number it is best to use mediate step!) as shown below: ( = 8) cannot be subtracted from the the longer method. Remember that, in remainder but 22 can to leave a both cases, you. can always convert Hexadecimal 2 A remainder of 5-4 = 1. 2° ( = 1) can now back to decimal in order to check your be subtracted . from the second results! Binary 0010 1010 remainder to leave zero. Another way of putting.this is that; Therefore hexadecimal 2A is equivalent to binary ·00101010. Note Problem L5 that the leading zeros are optional Convert the following binary numbers (00101010 is exactly the same number to decimal: as 101010). When dealing with num­ We can write this as a binary number (a) 1011 bers present on an 8-bit bus it is, by placing 1s and Os in columns, as fol­ (b) 100110 however, a good idea to get into the lows: (c) 11100111 habit of showing leading zeros in bi- E& TTMwch 1988 35 Introducing Microprocessors

0010 1100 -,.-. -- 2 c Therefore, the hexadecimal equivalent of 101200 is 2C. Problem 1.7 Convert the following decimal num­ bers to hexadecimal: (a) 27 (b) 511 Fig. 6 Answer to problem.1.4 (c)4100 (Hint: Refer to Table 3 for powers of 16) Problem 1.8 Decimal Binary Hexadecimal Convert the following hexadecimal numbers to decimal: 0 0000 0 (a) BE 1 0001 1 (b) lOB 2 0010 2 (c) COOO 3 0011 3 4 0100 4 Problem 1.9 5 0101 5 Convert the following binary numbers 6 0110 6 to hexadecimal: 7 0111 7 8 1000 8 (a) 1011 9 1001 9 (b) 10101111 10 1010 A (c) 1010101111001101 11 1011 B 12 1100 c Problem 1.10 13 1101 D Convert the following hexadecimal 14 1110 E numbers to binary: 15 1111 F (a) 3F (b) 23A nary numbers so that all 8-bits are So, 250 decimal is equivalent to FA (c) 812C clearly shown. hexadecimal. To convert from decimal (in the Converting from binary to Addition range 0 to 255) it is simply necessary to hexadecimal over the range 0 to 255 is Binary and hexadecimal addition fol­ divide the decimal number by 16 to ob­ extremely simple. All we need to do is lows the same general rules as tain the most significant digit and then to separate the binary number into two employed with decimal numbers. The take the remainder as the least sig­ groups of four bits (known as rule for addition of two numbers nificant digit. In both cases it will be "nibbles") and then convert each of (which MUST be expressed in the necessary to convert a digit answer these groups to its corresponding same base) is that digits in the cor­ greater than nine to its corresponding hexadecimal character. responding position in each number hexadecimal digit (i.e. A to F). Sup­ As an example suppose we need to are added, starting from the right most pose, for example, we had the task of convert the binary number 10001001 to (least significant) and a carry into the converting decimal 75 to hexadecimal: hexadecimal: next most significant position occurs if the sum of two digits equals or exceeds 16l..z2_ 1000 1001 the value of the base used. 4 Remainder 11 As an example, suppose we have to I =B--, 8 9 add the binary numbers 10010010 and • 48 01010000. Therefore, decimal 75 is equivalent The binary number 10001001 . is to 4B hexadecimal. equivalent to hexadecimal89. 1 0 0 1 0 0 1 0 Taking another example, suppose we Taking one further example, suppose + 0 1 0 1 0 0 0 0 had to convert 250 decimal to we have to find the hexadecimal Carry 0 0 1 0 0 0 0 0 hexadecimal: equivalent of the binary number 0 0 0 0 1~250 101100 (note that this number consists of six rather than eight bits): (Note that a carry is generated when 15 Remainder 10 101100 = 00101100 (inserting two the two ls are added and the carry is = F =A-, leading zeros to form an eight bit bi­ added into the next more significant FA nary number) column.) 36 E& TTMarch1988 Introducing Microprocessors

To make the process dear it is worth much more complicated than it really Problem 1.12 taking another example in which we is so we shall again use several ex­ Subtract; shall add the binary numbers 10001101 amples to illustrate the techniques. (a) the binary number 01001101 from and 01001111: Consider the problems of subtracting the binary number 110000101 the binary number 0100 from the bi­ (b) the hexadecimal number 3C from 1 0 0 1 0 nary number 1101: + 0 1 1 0 1 1 the hexadecimal number FO Carry 1 1 1 1 1 0 1 0 1 (minuend) 0 0 0 0 0 0 Negative Numbers - 0 1 0 0 (subtrahend) Thus far we have confined ourselves to Borrow 0 0 0 0 Addition of hexadecimal numbers positive numbers and many of you will follows the same pattern. Suppose we 0 0 be wondering how we go about repre­ have to find the sum of the senting negative numbers within a hexadecimal numbers 14 and 23. (In this simple example we have not computer. One rather obvious method needed to borrow) is . that of using the first (most sig­ nificant) bit of a number solely to indi­ 1 4 Now consider the slightly more dif­ + 2 3 ficult problem of subtracting the binary cate its sign (i.e. whether it is positive Carry 0 0 .number 0110 from 1101. or negative). The convention used is that a 0 in the most significant bit 3 7 (MSB) position indicates that the num­ 1 1 0 1 (minuend) 0/1/1 0 (subtrahend) ber is positive. An MSB of 1, on the Therefore, the sum of hexadecimal Borrow 1 1 0 0 other hand, indicates that the number numbers 14 and 23 is (not surprising­ is negative. The magnitude of the num­ ly!) equal to 37. 0 1 1 1 ber is then given by the remaining bits. Now let's try something a little more. We refer to such a number as being difficult by finding the sum of 1F and (Note that, if you are unsure of an "signed". 2C: answer, it is always permissible to con­ As an example . the signed eight-bit vert the numbers to decimal in order to binary number 01111111 represents 1 F check the validity of a result. In the the decimal number 127 (it is positive + 2 c as the MSB is 0) whereas the signed bi­ Carry 1 0 foregoing example we have the equivalent decimal calculation; 13-6 nary number 11111111 represents the 4 B = 7) decimal number - 127 (the MSB is 1 Subtraction of hexadecimal numbers and therefore the number is negative). again follows . the same pattern. Sup­ (Note that adding F to C gives lB) pose we have to find the difference of Problem 1.13 Therefore, adding 2C to 1F gives 4B the hexadecimal numbers 2F and 1A: Convert the following signed binary hexadecimal. numbers to decimal: 2 F (a) 01000000 Problem 1.11 - 1 A (b) 11000000 Add: Borrow 0 0 (c) 10001001 (a) the binary number 01001111 to the binary number 10000101 5 Problem 1.14 (b) the hexadecimal number 5C to the Convert the following decimal num­ hexadecimal number 71. (Note that subtracting A from F leaves bers to signed 8-bit binary: 5) (a) +5 Subtraction So, the result of subtracting 1A (b)-99 Subtraction of binary and hexadecimal hexadecimal from 2F hexadecimal is 15 (c) +99 numbers also follows the same general hexadecimal. rules as employed with decimal num­ Now let's try something a little more bers. The rule of subtraction of two difficult by subtracting hexadecimal14 numbers (which again MUST be ex­ from hexadecimal 23: pressed in the same-base) is that digits of the number to be subtracted (the One's and Two's Complement The one's complement of a binary subtrahend) are subtracted from digits 2 3 in the corresponding position of the - 1/4 number is found by simply changing all minuend. If the difference obtained is Borrow 1 0 of the Os present to l s and changing all less than zero (i.e. negative) a value of the 1s present to Os. This process is equals to the base employed is BOR­ 0 F called "inversion". The one's comple­ ROWED FROM the next most sig­ ment of the binary number 1010 is thus nificant position. The value of the bor­ 0101. Note . that the result of adding a row (i.e. 1) must be ADDED TO the Therefore, the result of subtracting number to its one's complement will next most significant position of the the hexadecimal number 14 from the produce a succession of l s, as shown in subtrahend. Again all this sounds · hexadecimal number 23 is OF. the following example: E & TT March 1988 37 Introducing Microprocessors

Binary number 1 0 1 0 1 1 0 0 performing the foregoing example cally comprise 16 bits and therefore One's·complement 0 1 0 1 0 0 1 1 using conventional techniques! can range from 0 to 65535 Sum 1 1 1 1 1 1 1 1 Address bus Problem-1.16 A set of lines (usually 16) used to Use the two's complement to subtract transmit addresses, usually from the The two's complement of a binary the binary number 00011001 from the microprocessor to a memory or I/0 number is found by simply adding 1 to binary number 11010100. device. its one's complement. Therefore, the Address decoding two's complement of 1010 is 0110 (i.e. Representing Number Bases The process of selecting a specific ad­ 0101 + 0001). So far we have been quite explicit in dress or range of addresses to enable The result of adding a binary number stating (rather long-windedly) the unique support devices. to its two's complement is not a.succes­ number base which we have been Binary sion of 1s but a succession of Os with a working in. Methods commonly used A system of numbers using base 2. Bi­ leading 1 in the next more significant to indicate the base include: nary numbers thus use only two bit position. This is demonstrated by (a) using a suffix to indicate the base characters; 0 and 1. the following example: e.g. 10100% is a number having base 2 Bit Binary number 1 0 0 0 1 0 1 1 (i.e. binary) A contraction of binary digit A single One's·complement 0-1 1 1 0 1 0 0 12710 is .a number having base 10 (i.e. digit in a binary number. Two's complement 0 1 1 1 0 1 0 1 decimal) Bus / 7616 is a number having base 16 (i.e. A path of signals having some common added 1 Hexadecimal) function. Most microprocessor systems (b) adding a trailing H to indicate that have·three buses; an address bus, data Original number 1 0 0 .0 1 0 1 1 a number is hexadecimal bus and control bus. Two's complement +01110101 e.g. 9FH, C9H and FFH are all Byte Sum 1 00000000 hexadecimal A group of eight bits. (c) adding a leading $ to indicate that a Central Processing Unit Problem 1.15 number is hexadecimal The part of a computer that decodes Find the one's and two's complements e.g. $2A is the same as 2AH which is instructions and controls the other of each of the following: the same as 2A hardware elements of the system. The (a) 1001 CPU comprises a control unit, arith­ (b) 10110011 Problem 1.17 metic/logic unit and internal storage. (c) 10001110 Determine the decimal . equivalent of Chip Readers can be excused for wonder­ each of the following: The term commonly used to describe ing what all this is leading up to. It ac­ (a) 10 an integrated circuit. tually yields . a very neat method. for (b) 102 Complement 10 performing subtraction. We simply (c)$10 ~he process of changing a 1 to a 0 and form the two's complement of the v1ce versa. number to be subtracted (the sub­ Glossary for Part One Control Bus trahend) and ADD it to the first num­ Address The set of control signal lines in a com­ ber (the minuend). Any leading 1 A number which indicates the position puter system. The control bus provides generated is ignored. To show how this of a word in memory. Addresses typi- works consider the following example which subtracts the binary number 00110110 from the binary number 10010101: Subtrahend 00110110 ANSWERS TO PROBLEMS- 1.1 See Fig .-6. One's complement 1 0 0 1 0 0 1 1.2 (a) standard TTL (b) low-power Schottky (c) CMOS Fig. 6. Two'" comrlement 1 0 0 1 0 1 0 1.3 CMOS (reasons are wide .supply voltage range .and very low current requirements) 1 .4 See Fig . 7. Minuend 1 0 0 1 0 1 0 1 1.5 (a) 11 (b)38 Two's complement +11001010 (c) 231 1.6 (a) 100001 of subtrahend (b) 1100100 (c) 11010101 101011111 1.7 (a) 1B (b) 1FF (c) 1004 1.8 (a) 190 · (b)267 (c) 49152 Ignoring the leading 1 gives a result of 1.9 (a) 8 (b) AF (c) ABCD 01011111. . 1.10 (a) 111111 (b) 1000111010 (c) 1000000100101100 1.11 (a) 11010100 (b) CD .1.12 (a) J 111000 (b) B4 It is usually much easier to use two's 1.13(a) +64 (b) - .64 (c) -9 complements to perform subt1"action 1.14 (a) 10000.101 (b) 11100011 (c) 01100011 than .to use conventional subtraction 1.15 (a) 0110and 0111 (b) 01001100 and 01001101 (c) 01110001 and 01110010 (using borrow). Readers can easily 1.1610111011 check the validity of the. statement by 1.17(a)2 (b) 10 (c) 16 38 Ell TTMBI'ch 1988 Introducing Microprocessors the synchronization and control infor­ tains an arithmetic logic unit (ALU), Visual display unit (VDU) mation to operate the system. control block and registers. A VDU is an output device (usually CMOS One's complement based on a cathode ray tube) on which Complementary metal oxide semicon­ The inverse of a binary number which text and/or graphics can be displayed. ductor. A family of integrated circuit is formed by changing all Os to 1s and A VDU is normally used in conjunc­ devices based on unipolar field effect vice versa. tion with an integral keyboard when it devices. Output port is sometimes referred to as a console. Data A circuit that allows a microprocessor Word General term used to describe num­ system to output signals to other A set of characters that occupies one bers, letters and symbols present devices. storage location in memory and is within a computer during processing. Peripheral treated by the computer as a unit. Data Bus Any device that is connected to a com­ Program instructions and program The set of electrical conductors which puter whose activity is under the con­ data both have the same word length carries data between the different ele­ trol of the central processing unit. (equal to 8-bits or 1-byte in the case of ments of a computer system. Program 8-bit microprocessors) Digital A procedure of solving a problem Write A system which only allows discrete coded into a form suitable for use by a The process of transferring informa­ states. Most digital logic uses only two computer and frequently described as tion from a register within the central states (on/off, low/high or 0/1). software. processor to memory or I/0. Firmware RAM (random access memory) A program (software) stored in read­ Usually used to mean semiconductor Sources For Microprocessor only memory. read/write memory. Strictly speaking, Training Materials. Hardware ROM devices are also random access! The physical components of a com­ Random access Active, Division of Future puter system. An access method in which each word Electronics Hexadecimal can be retrieved in the same amount of Carries the full Edukit line including the "Digital Designer" in teacher's version or a A number system with base 16. The time (i.e. the storage locations can be home-study version, and the Motorola first six letters of the alphabet (A to F) accessed in any desired order). MC68000 kit. are used to represent the hexadecimal Read Locations across Canada or phone 1-800- equivalents of the decimal numbers 10 The process of transferring informa­ 361-5884 orl-800-361-9046 (Quebec and Ot­ to 16. tion from memory or l/0 into a register tawa Valley) Input/output in the central processor. Radio Shack Stocks a variety of laboratory-type kits deal­ Lines of devices used to transfer infor­ Register ingwith electronics and microprocessors. mation outside the computer system. A single word of memory. The CPU Radio Shack stores across Canada Input port contains a number of registers for tem­ ElectroSonic Inc. A circuit that connects signals from ex­ porary storage of data. They list a number of RCA and Motorola ternal devices as inputs to a microcom­ ROM (read-only memory) microprocessor evaluation kits in varying puter system. A permanently programmed memory. forms and prices. 1100 Gordon Baker Road, Willowdale, On­ Integrated circuit Mask-programmed ROMs are tario M2H 3B3 (416) 494-1555. programmed by the chip manufac­ An fabricated on a Tapto Corp. single wafer (chip) and packaged as a turer. PROMS (programmable ROM Stocks a variety of microprocessor-oriented single component. devices) can be programmed by the kits from Velleman of Belgium. user. EPROMs (erasable PROM P.O. Box 44247, Denver, CO 80202-4247. Memory devices) can be erased under (303) 296-5544 The part of a computer system into ultraviolet light before reprogram­ Labvolt which information can be placed and ming. Distributes the Labvolt series of comprehen­ held for future use. Storage and TIL (transistor transistor logic) sive microprocessor/logic training systems memory are interchangeable terms. starting at $885. Transistor transistor logic. A family of Ontario - Harold Burrows, 200 Consumers Digital memories accept and hold bi­ integrated circuit devices based on Rd., Suite 200, Willowdale, Ontario M2J nary numbers only. Common types of conventional bipolar . 4R4 Tel: (416) 491-8611 memory are magnetic disc, magnetic Two's complement numbers Quebec & Other - 4555 Metropolitain E., tape, and semiconductor (which in­ Suite 102, Montreal, Quebec H1R 1ZA (514) A number system used to represent 376-2120 cludes RAM and ROM) both positive and negative numbers. Heath Company Microcomputer The positive numbers in two's comple­ Carries a wide range of microprocessor A small computer based upon a ment representation are identical to trainers. Available from Heath/Zenith Com­ microprocessor CPU. Backing storage the positive numbers in standard bi­ puters and Electronic Centres across Canada. Mail order from 1020 Islington is usually provided by magnetic disc or nary, however the two's complement Ave., Toronto, Ontario M8Z 5Z3. representation of a negative number is tape; input is provided by means of a Mastertech Laboratories keyboard and output by a VDU. the complement of the absolute binary Microlab 1 Digital Trainer system. Contact Microprocessor value plus 1. Note that the most sig­ Mastertech at: 302 Royal Trust Building, 612 A central processing unit fabricated on nificant bit (usually the eight) indicates View Street, Victoria, B.C. V8W 1T5 (604) one or two chips. The processor con- the sign; 0 = positive, 1 = negative). 388-6631. E & TT Mwch 1988 •39

I I