Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
611 views
Instruction Classification Unit 2
Uploaded by
shivangi sharma
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Instruction classification unit 2 For Later
Download
Save
Save Instruction classification unit 2 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
611 views
Instruction Classification Unit 2
Uploaded by
shivangi sharma
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Instruction classification unit 2 For Later
Carousel Previous
Carousel Next
Save
Save Instruction classification unit 2 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 24
Search
Fullscreen
INSTRUCTION CLASSIFICATION An instruction is a binary pattern designed inside a microprocessor to perform a specific function. The entire group of instructions, called the instruction set, determines what / functions the microprocessor can perform. The 8085 microprocessor includes the instruc- tion set of its predecessor, the 8080A, plus two additional instructions. 5.21 The 8085 Instruction Set The 80835 instructions can be classified into the following five functional categories: data transfer (copy) operations, arithmetic operations, logical operations, branching opera- tions, and machine-control operations. Scanned with CamScannerDATA TRANSFER (COPY) OPERATIONS ae This group of instructions copies data from a location called a source to another locati on called ination, without 'ying the contents of the source. In technical manuals, the term data transfer is used for this copying function. However, the term transfer is \\ Disteading it creates the impression that the contents of a source are destroyed when, in fact, the contents are retained without any modification. The various types of data trans- fer (copy) are listed below together with examples of each type: . Types Examples O Between registers Copy the contents of register B into register D. O Specific data byte to a Teg- Load register B with the data byte 32H. ister or a memory location O Between a memory loéation From the memory location 2000H to register B. and a register O Between an I/O device and From an input keyboard to the accumulator. the accumulator ARITHMETIC OPERATIONS These instructions perform arithmetic operations such as addition, subtraction, increment, and decrement. 5 Addition ZAny 8-bit number, or the contents of a register, or the contents of a mem- ory location can be added to the contents of the accumulator and the sum is stored in the accumulator) No two other 8-bit registers can be added directly (e.g., the contents of register B Cannot be added directly to the contents of register C). The instruction DAD is an exception; it adds 16-bit data directly in register pairs, a Subtraction (Any 8-bit number, or the contents of a register, or the contents of a memory location can be subtracted from the contents of the accumulator and the re. sults stored in the accumulator) The subtraction is the results, if negative, are expressed in 2’s com subtracted directly. 5 Increment/Decrement—The 8-bit contents of a register or a memory location can be incremented or decremented by 1. Similarly, the’16-bit contents of a tegister pair (such as BC) can be incremented or decremented by 1. These i ement and decrement op- rations differ from addition and subtraction in an important way rey formed in-any one of the regi ters or in a memory location, Performed in 2's complement, and plement. No two other Tegisters can be .e., they can be per- ~” LOGICAL OPERATIONS. These instructions -perform various logical operations with the contents of the accumu lator.” G-AND, OR, Exclusive-OR—Any 8-bit number, or memory location‘c; the contents of a regi _ Of the accumulator, . be logically ANDed, ORed, or Exclusive-O) ‘The results are stored in the accumulator. a or of a with the contents Scanned with CamScanner}O- er left or right to the next p ifted eith 4 Rotate—Each bit in the accumulator can be shifted ister, ith the content a memory Jocation can 2 ts of the accumu- it number, or the contents of a reg} ~Any 8- i ty, greater than, or less than, Wi be compared for equa lator, nite ator. ompleme! & Complement—rhe contents of the accumulator can be comp! placed by Is and all 1s are replaced by 0s. d; all Os are re- BRANCHING OPERATIONS ion either conditionally This group of instructions alters the sequence of program execution or unconditionally, & Jump—Conditional jumps are an important aspect of the decision-making process ip Programming, These instructions test for a certain condition (e.g., Zero or Carry flag and alter the program sequence when the condition is met. In addition, the instruction Set includes an instruction called unconditional jump. . O Call, Return, and Restart—These instructions change the sequence of a program ei- ther by calling a subroutine or returning from a subroutine. The conditional Call and Return instructions also can test condition flags. “ MACHINE CONTROL OPERATIONS ‘These instructions control machine functions such as Halt, Interrupt, or do nothing. 5.22 Review of the 8085 Operations The microprocessor operations related to data manipulation can be summarized in four functions: 1. copying data 2. performing arithmetic operations 3. performing logical operations 4. testing for a given condition and altering the program sequence Some important aspects of the instruction set are noted below: 1, In data transfer, the contents of the source are not destroyed; only the contents of destination are changed. The data copy instructions do not affect the fla, sents of the 2. Arithmetic and logical operations are performed with the contents of the, and the results are stored in the accumulator (with some exceptions). The £1 fected according to the results, 3. Any.register including memory can be used for increment and decrement, 4. A program sequence can be changed either conditional . condition. ahs lly or by testing for a given data Scanned with CamScanner~~ MUN 1U U8 ASSEMBLY LANGUAGE PROGKAMINNS Mnemonics A ” & fetteny fe Sugyet me op” & synod ~ INSTRUCTION AND DATA FORMAT INSTRUCTION AND OO An instruction is a command to the microprocessor to perform a given task on specified data. Each instruction has two parts: one is the task to be performed, called the operation code (opcode), and the second is the data to be operated on, called the operand. The operand (or data) can be specified in various ways. It may include 8-bit (or 16-bit) data, an internal register, a memory location, or an 8-bit (or 16-bit) address. In some instruc- tions, the operand is implicit. 5.31 Instruction Word Size The 8085 instruction set is classified into the following three groups according to word size: 1. One-word or 1-byte instructions 2. Two-word or 2-byte instructions 3. Three-word or 3-byte instructions In the 8085, “byte” and “word” are synonymous because it is an 8-bit micro- processor. However, instructions are commonly referred to in terms of bytes rather than words. ONE-BYTE INSTRUCTIONS ‘A L-byte instruction includes the opcode and the operand in the same byte. For example: Task Opcode Operand* Binary Code Hex Code Copy the contents of MOV CA 0100 1111 4FH the accumulator in = register C. Add the contents of ADD B 1000 0000 80H | register B to the i contents of the ac- cumulator. Invert (complement) CMA 0010 Hh oFH each bit in the ac- ah cumulator. : These instructions are 1-byte instructions performing three different tasks. In the first instruction, both operand registers~are specified. In the second instruction, the operand B is specified and the accumulator is assumed. Similarly, in the ; third instruction, *In the operand, the destination register C is shown first, followed by the source register A. egister Scanned with CamScannerPROGRAMMING THE 2086 it operand, ‘These instructions are stored in B- it operand. Thes the accumulator is assumed to be the implici ry location. bit binary format in memory; cach requires one memo! TWO-BYTE INSTRUCTIONS In a 2-byte instruction, the first byte specifies the 0) specifies the operand, For example: peration code and the second byte Hex Task Opcode Operand —_Binary Code Code Load an 8-bit MVI A,Data 0011 1110 3E First es : data byte DATA Data Second Byte in the ac- i) cumulator. Assume the data byte is 32H. The assembly language instruction is written as Mnemonics Hex Code MVIA,32H 3E 32H This instruction would require two memory locations to store in memory. THREE-BYTE INSTRUCTIONS In a 3-byte instruction, the first byte specifies the opcode, and the following two bytes specify the 16-bit address. Note that the second byte is the low-order address and the third byte is the high-order address. For example: 5 Hex Task Opcode Operand —Binary Code _—Code Transfer the JMP 2085H 1100 0011 C3* First Byte program 1100 0011 85 Second Byte sequence (0010-0000 20 Third Byte to the . memory location 2085H. This instruction would require three memory locations to store in memory. These commands are in many ways similar to our everyday conversation, For ex- ample, while eating in a restaurant, we may make the following requests and orders 1, Pass (the) butter. Pass (the) bowl. Scanned with CamScannerHOW TO WRITE, ASSEMBLE, AND EXECUTE A SIMPLE PROGRAM i rm a specific A program is a sequence of instructions written to tell a computer to perfo: pet function. The instructions are selected from the instruction set of the ee een ~ write a program, divide a given problem in small steps in terms of the oper: can perform, then translate these steps into instructions. adding two numbers in the 8085 language is illustrated below. 5.41 Illustrative Program: Adding Two Hexadecimal Numbers Writing a simple program of PROBLEM STATEMENT : : Write instructions to load the two hexadecimal numbers 32H and 48H in registers A and B, respectively. Add the numbers, and display the sum af the LED output port PORT1. PROBLEM ANALYSIS Even though this is a simple problem, it is necessary to divide the problem into small Steps to examine the process of writing programs. The wording of the problem provides sufficient clues for the necessary steps. They are as follows: 1. Load the numbers in the registers. 2. Add the numbers: 3. Display the sum at the output port PORT1. FLOWCHART The steps listed in the problem analysis and the sequence‘can be Tepresented in a block diagram, called a flowchart. Figure 5.2 shows such a flowchart Tepresenting the above steps. This is a simple flowchart, and the steps are self-explanatory. We will discuss flow. charting in the next chapter. ” ASSEMBLY LANGUAGE PROGRAM To write an assembly language program, we need to translate flowchart into 8085 operations and then, subsequently, the blocks, we can classify them into three types of opel operations; Block 2 is an arithmetic operation; and Bl tion. To translate these steps into assembly and machi the instruction set. The translation of each block in shown as follows: soe a the blocks shown in the into mnemonics. By examining ations: Blocks 1 and 3 are copy lock 4 is a machine-control opera- ine languages, you should review to mnemonics with comments is Scanned with CamScannerINTRODUCT; ION 70 8088 ASSEMBLY LANGUAGE PROGRAMM ING FIGURE 5.2 Flowchart: Adding Two Numbers Block 1; Block 2: Block 3: Block 4: MVIA,32H MVIB,48H ADD B OUT O1H HALT Display | Sum Load register A with 32H Load register B with 48H ‘Add two bytes and save the sum in A Display accumulator contents at port 01H End FROM ASSEMBLY LANGUAGE TO HEX CODE To convert the mnemonics into Hex code, we need to look up the code in the 8085 in- struction set; this is called either manual or hand assembly. Mnemonics MVIA,32H MVI B,48H ADD B OUT 01H HLT Hex Code 3E 32. 06 48 80 D3 O1 16 2-byte instruction 2-byte instruction {-byte instruction 2-byte instruction I-byte instruction STORING IN MEMORY AND CONVERTING FROM HEX CODE TO BINARY CODE To store the program in RW output, we need to know the memory of a single-board microcomputer and display Ue memory addresses and the output port address, Let us a 151 Joes Scanned with CamScannersume that R/W memory ranges from 2000H to 20FFH, and the system has an LED out- put port with the address 01H. Now, to enter the program: 1. Reset the system by pushing the RESET key. 2. Enter the first memory address using Hex keys where the program should be stored. Let us assume it is 2000H 3. Enter each machine code by pushing Hex keys. For example, to enter the first machine code, push the 3, E, and STORE keys. (The STORE key may be labeled differently in different systems.) When you push the STORE key, the program will store the ma chine code in memory location 2000H and upgrade the memory address to 2001H. 4. Repeat Step 3 until the last machine code, 76H. 5. Reset the system. Now the question is: How docs the Hex code get converted into binary code? The answer lies with the Monitor program stored in Read-Only memory (or EPROM) of the microcomputer system. An important function of the Monitor program is to check the keys and convert Hex code into binary code, The entire process of manual assembly is shown in Figure 5.3. In this illustrative example, the program will be stored in memory as follows Memory Mnemonics Hex Code Memory Contents Address MVIA32H 3E ool 2000 32 oo 1) 2001 MVIB,48H 06 0000 2002 48 0100 2003 ADD B 80 1000 2004 OUT 01H D3 110 2005 Ol 0000 2006 HLT 16 [ort 2007 This program has eight machine codes and will require eight memory locations to store the program. The critical concept that needs to be emphasized here is that the mi croprocessor can understand and execute only the binary instructions (or data): everything else (mnemonics, Hex code, comments) is for the convenience of human beings EXECUTING THE PROGRAM To execute the program, we need to tell the microprocessor where the program beg entering the memory address 2000H. Now, we can push the Execute key (or the key with, a similar label) to begin the execution, As soon as the Execute function key is pushed, the microprocessor foads 2000H in the pro, ferred from the Monitor program to our program. ‘The microprocessor begins to rend one machine code ala time, and when it es the complete instruction, executes that instruction, Hor example, i will fetch the ma- ins by M counter, and the program control is tans Scanned with CamScanner~_DBTA TRANSFER (COPY) OPERATIONS One of the primary functions of the microprocessor is copying data, from a register (or V/O or memory) called the source, to another register (or I/O or memory) called the des. tination. In technical literature, the copying function is frequently labeled as the data transfer function, which is somewhat misleading. In fact, the contents of the source are not transferred, but are copied into the destination register without modifying the contents of the source. : Several instructions are used to copy data (as listed in Chapter 5). This section is concerned with the following operations. MOV : Move Copy a data byte. MVI : Move Immediate Load a data byte directly. OUT : Output to Port Send a data byte to an output device. IN _ : Input from Port Read a data byte from an input device. The term copy is equally valid for input/output functions because the contents of the source are not altered. However, the term data transfer is used so commonly to indicate the data copy function that, in this book, these terms are used interchangeably when the meaning is not ambiguous. In addition to data copy instructions, it is necessary to introduce two machine- control operations to execute programs. HLT: Halt Stop processing and wait, NOP: No Operation _Do not perform any operation. These operations (opcodes) are explained and illustrated below with examples. INSTRUCTIONS The data transfer instructions copy data from a source into a destination without modifying the contents of the source. The previous contents of the destination are re- placed by the contents of the source. Scanned with CamScannerINTRODUCTION TO 8085 INSTRUCTIONS Vv Important Note: In the 8085 processor, data transfer instructions do not affect the flags. Opcode MOV Operand RaRy R8-bit Brosh 8-bit port address 8-bit port address ‘The symbols Rd and Rs Description Move O This is a 1-byte instruction O Copies data from source register Rs to destina- tion register Rd Move Immediate, 0 This is a 2-byte instruction 1 Loads the 8 bits of the second byte into the register specified : Output to Port C This is a 2-byte instruction C Sends (copies) the contents of the accumulator (A) to the output port specified in the second byte Input from Port O This is a 2-byte instruction © Accepts (reads) data from the input port speci- fied in the second byte, and loads into the ac- cumulator Halt CO This is a 1-byte instruction 1 The processor stops executing and enters wait state OO The address bus and data bus are placed in high impedance state. No register contents are affected No Operation 1 This isa L-byte instruction 1 No operation is performed O Generally used-to increase processing time or substitute in place of an instruction. When an error occurs in a program and an instruction needs to be eliminated, it is more convenient to substitute NOP than to reassemble the whole program generic terms; they represent any of the 8085 registers: A, B, C, D, E, H, and l- 3 ee Scanned with CamScannerndicates hexadecimal num. [Load the accumulator A with the data byte 82H (the Tettet H ber), and save the data in register B. Instructions — MVIA, 82H, MOV B.A i ie di y The first instruction is a 2-byte instruction that loads the ae with | tn ao 82H, and the second instruction MOV B,A copies the contents of the acc 7 ister B without changing the contents of the accumulator. Scanned with CamScanneroutput ports with addresses trom UUH ! gic circuit (called interfacing) used to cofinect and identify a port by the system designer (see Chapter 4) s 6.11 Addressing Modes (): . ope \ The’ above instructions are commands to the microprocessor to copy 8-bit data from a Jaws into a destination. In these instructions, the source can be a register, an input port, or an 8-bit number (00H to FFH). Similarly, a destination can be a register or an output port. The sources and destination are, in fact, operands. The various formats of specify- ing the operands are called the addressing modes. The 8085 instruction set has the fol- lowing addressing modes. (Each mode is followed by an example and by the correspond- ing piece of restaurant conversation from the analogy discussed in Chapter 5.) 1. Immediate Addressing—MVI R,Data (Pass the butter) /2, Register Addressing—MOV Rd,Rs (Pass the bowl) 3. Direct Addressing—IN/OUT Port# (Combination number 17 on the menu) 4. Indirect Addressing—Illustrated in the next chapter (I will have what Susie has) “ (POU Ron LOG BY fF mUT mM wrt | AOD M aw 88 2 at poy EL geet OPT comp oneal cose otf Scanned with CamScanner6.12 Iustrative Program: Data Transfer—From Register to Output Port PROBLEM STATEMENT ‘Load the hexadecimal number 37H in register B, and display the number at the output port labeled PORT. PROBLEM ANALYSIS This problem is similar to the illustrative program discussed in Section 5.41. Even though this is a very simple problem it is necessary to break the problem into small steps and to outline the thinking process in terms of the tasks described in Section 6.1. STEPS Step 1: Load register B with a number. Step 2: Send the number to the output port. QUESTIONS TO BE ASKED O Is there an instruction to load the register B? YES—MVI B. O Is there an instruction to send the data from register B to the output port? NO. Review the instruction OUT. This instruction sends data from the accumulator to an output port. D The solution appears to be as follows: Copy the number from register B into accumu- lator A. ; i 7 Is there an instruction to copy data from one register to another register? YES—MOV RdRs. Scanned with CamScannerprogram in the next section. ASSEMBLY LANGUAGE PROGRAM Tasks 8085 Mnemonics a5) * 1. Load register B with 37H. oe 2. Copy the number from BA. ae 3. Send the number to the output—port O1H. iad 4. End of the program. TRANSLATION FROM ASSEMBLY LANGUAGE TO MACHINE LANGUAGE Now, to translate the assembly language program into machine language, : hexadecimal machine codes for each instruction in the 8085 instruction set and write each machine code in the sequence, as follows: “ look up the 8085 Mnemonics Hex Machine Code 1. MVI B,37H 06 37 2. MOV A,B 78 3. OUT PORT1 D3 01 4, HLT 76 This program has six machine codes and will require six bytes of memory to enter the program into your system. If your single-board microcomputer has R/W memory starting at the address 2000H, this program can be entered in the memory locations ae as The format generally used to write an assembly language program is / PROGRAM FORMAT / Memory — Machine / Address Code Instruction (Hex) (Hex) Opcode Operand Comm , ents sie s MVI B,37H :Load register B with data 37H *A number followed by the letter H represeqts a hexadecimal number. +Enter high-order address (page number) of your R/W memory in place of XX Scanned with CamScannerINTRODUCTION TO 8085 INSTRUCTIONS / J; xx02 8 MOV AB {Copy (8) inte (A) 7 Xx03 D3 OUT PORTI “Display accumulator CONTENTS xxo4 PORTI" < Q7H) at Port XX05 76 HLT “End of the program ‘This program has five columns: Memory Address, Machine Code, Opeode, fae and Comments. Each is described in the context of a single-board microconr Scanned with CamScannerINTRODUCTION TO 8085 INSTRUCTIONS 7 i | % AReTHMATIS INST: AN ADD: Add ‘Add the contents of a register." ADI : Add Immediate Add 8-bit data. | SUB : Subtract Subtract the contents of a register. SUI : Subtract Immediate Subtract 8-bit data. ; INR : Increment Increase the contents of a register by |. DCR : Decrement Decrease the contents of a register by |. are performed in relation to the contents of The arithmetic operations Add and Subtract n be performed the accumulator. However, the Increment or the Decrement operations cai in any register. The instructions for these operations are explained below. INSTRUCTIONS These arithmetic instructions (except INR and DCR) 1. assume implicitly that the accumulator is one of the operands. 2. modify all the flags according to the data conditions of the result. 3. place the result in the accumulator. 4. do not affect the contents of the operand register. The instructions INR and DCR 1. affect the contents of the specified register. 2. affect all flags except the CY flag. The descriptions of the instructions (including INR and DCR) are as follows: Opcode Operand Description XK ADD RT Add : 0 This is a 1-byte instruction O Adds the contents of register R to the contents of the ac- _ cumulator ADI _ Add Immediate GF This is a 2-byte instruction O Adds the second byte to the contents of the accumulator SUB Rt ee hy ° isa l-byte instruction acts the contents of register R from the contents of SUI 8-bit *Memory-related arithmetic operations are exclu ete; they are discussed in © Scanned with CamScannerPROGRAMMING THE 025 © Subtracts the second byte from the contents of the accu- me a malator Gi This is 2 1-byte instruction © Increases the contents of register R by 1 Caution: All flags except the CY are affected DcR R* Decrement Gi This is 2 1-byte instruction Decreases the contents of register R by 1 Caution: All flags except the CY are affected 6.21 Addition The 8085 perfornis addition with &-bit binary numbers and stores the sum in the accu- mutator. If the sum is larger than eight bits (FFH), it sets the Carry flag. Addition can be performed either by adding the contents of a source register (B, C, D, E, H, L, or mem- ory) to the contents of the accumulator (ADD) or by adding the second byte directly to the contents of the eccumulator (ADI). Scanned with CamScanner{dd the number 35H directly to the sum in the previous example when the CY flag is set. Instruction ADI 35H cy (A): 4AH= [1] 0100 1010 + (Data) : 35H (A): 7FH OOL 0 O11 1 “ 1 101 0] 1 11it Flag Status: S = 0,Z=0, CY =0 The addition of 4AH and 35H does not generate a carry and will reset the previous Carry flag. Therefore, in adding numbers, it is necessary to count how many times the CY flag is set by using some other programming techniques (see Section 7.32). {a Ex Assume the accumulator holds the data byte FFH. Illustrate the differences in the flags set by adding 01H and by incrementing the accumulator contents. Instruction ADI 01H cy (A): FFH= 11111111 + (ata) : OIH= 0000 0001 1111 1111 Cany DUO) (A) :Mo0H= [1 o000 0000 cy Flag Status: S=0,Z=1,CY=1 After adding 01H to FFH, the sum in the accumulator is 0 with a carry. Therefore, the CY and Z flags are set. The Sign flag is reset because D; is 0. Instruction INRA The accumulator contents will be OOH, the same as before, However, the instruction INR Will not affect the Carry flag; it will remain in its previous status. Flag Status: $= 0, Z=1,CY=NA Ex FLAG CONCEPTS AND CAUTIONS AS described in the previous chapter, the flags are flip-flops that are set or reset after the €xecution of arithmetic and logic operations, with some exceptions. In many ways, the flags are like signs on an interstate highway that help drivers find their destinations Scanned with CamScanner6.22 Illustrative Program: Arithmetic Operations—Addition At and Increment PROBLEM STATEMENT Write a program to perform the following functions, and verify the output. 1. Load the number 8BH in register D, 2, Load the number 6FH in register C. 3. Increment the contents of register C by one. 4, Add the contents of registers C and D and display the sum at the output PORT! PROGRAM The illustrative program for arithmetic operations using addition and increment is pr sented as Figure 6.5 to show the register contents during some of the steps. Scanned with CamScannerComments and \ 7 Register Contents Machine nd ine codes Maree) Code Opeode Oper™ The first four machine co* Joad the registers a A x00 16 mviD.8BH 4 ‘ a 8B H 03 oF Add O1 to (Cy: 6F + Ol = 70" 4 oc INR c 05 79 MOV .A.C 06 82 ADD DD 07 D3 OUT PORT! 08 PORT# — PORT! 0 6 HLT End of the program IGURE 6.5 lustrative Program for Arithmetic Operations—Using Addition and Increm . Instruction ADD D adds (1D) to (A), stores the sum in A, and sets the Sign flag shown below: 5h (A): 70H = OF ete 0:05010 + (D) 8BH = 1000 1011 (A): FBH= ©} 111d 101 1 (ce re 6.5) Gy, Flag Status: S = 1,Z=0, CY =0 >. The sum FBH is disnlaved hw tha rrr Scanned with CamScannerSe 6.24 Illustrative Program: Subtraction of Two Unsigned Numbers PROBLEM STATEMENT Write a program to do the following: 1. Load the number 30H in register B and 39H in register C. 2. Subtract 39H from 30H. 3. Display the answer at PORTI. PROGRAM The illustrative program for subtraction of two unsigned numbers is presented as Figure 6.6 to show the register contents during some of the steps. PROGRAM DESCRIPTION 1. Registers B and C are loaded with 30H and 39H, respectively. The instruction MOV A.B copies 30H into the accumulator (shown as register contents). This is an essential step because the contents of a register can be subtracted only from the contents of the accumulator and not from any other register. 2. To execute the instruction SUB C the microprocessor performs the following steps in- ternally: Step 1: 39H =0011 1001 l’s complement of 39H = 1100 0110 + Step 2: Add0l=0000 0001 2's complement of 39H = 1100 0111 + Step 3: Add 30H to 2’s complement of 39H = 0011 0000 cy [0 Pili oll Scanned with CamScannerINTRODUCTION TO 8085 INSTRUCTIONS Step 4: Complement carry T} tiii o1it Flag Status: $= 1, Z=0, Cy = 3, The number F'7H is a 2's complement of the magnitude (39H — 30H) = 09H. 4, The instruction OUT displays F7H at PORT on OP PROGRAM OUTPUT This program will display F7H as the Output. In this program, the unsigned numbers were used to perform the subtraction, Now, the question is: How do you recognize that the an- swer F7H is really a 2°s complement of 09H and not a straight binary F7H? The answer lies with the Carry flag, If the Carry flag (also known as the Borrow flag in subtraction) is set, the answer is in 2's complement. The Carry flag raises a second question: Why isn’t it a positive sum with a carry? The answer is implied by the instruc- tion SUB (it is a subtraction), There is no way to differentiate between a straight binary number and 2’s comple- ment by examining the answer at the output port. The flags are internal and not easily dis- Played. However, a programmer can test the Carry flag by using the instruction Jump On Carry (JC) and can find a way to indicate that the answer is in 2's complement. (This is discussed in Branch instructions.) Memory Machine Instruction Comments and Address (tt) Code Opcode —Operand Register Contents HI-LO weet Load the minuend in register B axbo 06; Myl ao Load the subtrahend in register C : oe ae, pe C208 The register contents: 03 39 4 8 MOV AB aad 91 SUB c — a 6 ‘63. OUT PORTI O2.. PORT# . 8 76. HLT FIGURE 6.6 ih ~ ‘Wustrative Program for Subtraction of Two Unsigned Number 8.25 Review of Important Concepts Scanned with CamScannerLOGIC OPERATIONS a Aiea ad Wie is basically a programmable logic chip. It can perform all the logic Aunctions of the hard-wired logic through its instruction set. The 8085 instruction set in- / cludes such logic functions as AND, OR, Ex OR, and NOT (complement). The opcodes, / of these operations are as follows:* ANA: AND Logically AND the contents of a register, AN AND Immediate Logically AND 8-bit data. OR. OR Logically OR the contents of a register. ORI : OR Immediate Logically OR 8-bit data. X-OR Exclusive-OR the contents of a register. X-OR Immediate Exclusive-OR 8-bit data. All logic operations are performed in relation to the contents of the accumulator. The in- structions of these logic operations are described below. INSTRUCTIONS The logic instructions 1. implicitly assume that the accumulator is one of the operands. 2. reset (clear) the CY flag. The instruction CMA is an exception; flags. 3. modify the Z, P, and S flags according to the data conditions of the result, 4. place the result in the accumulator, 5. do not affect the contents of the operand register, it does not affect ar Scanned with CamScannerINTRODUCTION TO 8085 INSTRUCTIONS Opcode ORA * ORI Operand 8-bit Description Logical AND with Accumulator = Qo This is a 1-byte instruction O Logically ANDs thé conteitts of the register R with the Contents of the accumulator Sts—CS 8085: CY is reset and AC is set AND Immediate with Accumulator O'This is a 2-byte instruction” O Logically ANDs the second byte with the contents of the accumulator— ae rae fe > 0 8085: CY is reset and AC is set Logically OR with Accumulator C1 This is a 1-byte‘insfrtction’ D Logically ORs the contents of the register R with the contents of the accumulator OR Immediate with Accumulator CO This is a 2-byte instruction Ci Logically ORs the second byte with the contents of the accumulator : Logically Exclusive-OR with Accumulator CO This is a 1-byte instruction OO Exclusive-ORs the contents of register R with the con- fents of the accumulator Exclusive-OR Immediate with Accumulator O This is a 2-byte instruction CO Exclusive-ORs the second byte with the contents of the accumulator Complement Accumulator DD This is a 1-byte instruction that complements the con- «tents of the accumulator LI No flags are affected Scanned with CamScanner
You might also like
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Mark Manson
4/5 (6129)
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
4/5 (627)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brene Brown
4/5 (1148)
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
Chris Voss
4.5/5 (935)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
4/5 (8215)
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Angela Duckworth
4/5 (631)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
4/5 (1253)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
4/5 (8365)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
4.5/5 (860)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
4/5 (877)
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Ben Horowitz
4.5/5 (361)
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Margot Lee Shetterly
4/5 (954)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
4/5 (2923)
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
Ashlee Vance
4.5/5 (484)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
4.5/5 (277)
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Fredrik Backman
4.5/5 (4972)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
4.5/5 (444)
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
Colm Toibin
3.5/5 (2061)
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
Garth Stein
4/5 (4281)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
4/5 (100)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Meik Wiking
3.5/5 (447)
Yes Please
From Everand
Yes Please
Amy Poehler
4/5 (1987)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
3.5/5 (2283)
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Gilbert King
4.5/5 (278)
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Roxane Gay
4/5 (1068)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
4/5 (1993)
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
Ruth Ware
3.5/5 (2641)
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
Betty Smith
4.5/5 (1936)
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Viet Thanh Nguyen
4.5/5 (125)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
3.5/5 (692)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
4.5/5 (1912)
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Hilary Mantel
4/5 (4074)
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Naomi Klein
4/5 (75)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
3.5/5 (830)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
3.5/5 (901)
SENSORS & INSTRUMENTATION Notes Unit-01 (Part-1)
PDF
No ratings yet
SENSORS & INSTRUMENTATION Notes Unit-01 (Part-1)
21 pages
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
3.5/5 (143)
John Adams
From Everand
John Adams
David McCullough
4.5/5 (2544)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M L Stedman
4.5/5 (790)
Sensors & Instrumentation Notes Unit-02
PDF
No ratings yet
Sensors & Instrumentation Notes Unit-02
47 pages
SI UNIT-4 Notes
PDF
No ratings yet
SI UNIT-4 Notes
21 pages
Sensors & Instrumentation Notes Unit-02
PDF
No ratings yet
Sensors & Instrumentation Notes Unit-02
47 pages
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
4/5 (45)
Little Women
From Everand
Little Women
Louisa May Alcott
4/5 (105)
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel
John le Carré
3.5/5 (109)