Sunteți pe pagina 1din 32

SIES GRADUATE SCHOOL OF TECHNOLOGY NERUL, NAVI MUMBAI DEPARTMENT OF COMPUTER ENGG.

BRANCH: CE YEAR/SEM:TE/V

MICROPROCESSOR

LIST OF EXPERIMENTS

1. ALP TO ADD AND SUBTRACT 2 8-BIT NUMBERS IN BCD 2. ALP TO MULTIPLY AND DIVIDE 2 8-BIT NUMBERS IN BCD 3. ALP TO ADD 16-BIT NUMBERS IN BCD 4. ALP TO GENERATE PACKED BCD FROM ASCII 5. ALP TO FIND FACTORIAL OF A NUMBER 6. ALP TO SORT ARRAY ELEMENTS 7. ALP TO FIND MAX IN ARRAY 8. ALP TO DISPLAY CHARACTERS A-Z 9. ALP TO CONCATENATE STRINGS 10. ALP TO CONVERT LOWERCASE TO UPPERCASE 11. ALP TO INTERFACE 8255 IN I/O MODE 12. ALP TO INTERFACE 8253 IN MODE-3 13. MIXED LANGUAGE PROGRAM TO EMULATE CALCULATOR 14. MIXED LANGUAGE PROGRAM TO FIND SUM OF ELEMENTS OF ARRAY
______________________________________________________________________________________

Department of Computer Engineering SIES GST 1

EXPERIMENT NO: 01(a)

BCD ADDITION

AIM: To perform two 8 bit BCD additions.

THEORY: Instructions used in program:

MOV: (Move) This data transfer instruction transfers data from one register/memory location to another register/memory location. The source may be nay one of the segment registers or other general or special purpose registers or a memory location and another register/memory location may act as destination. However, in case of immediate addressing mode, a segment register cannot be a destination register. In other words, direct loading of the segment registers with immediate data is not permitted. To load the segment registers with immediate data, one will have to load any general purpose register with the data and then it will have to be moved to that particular segment register.

The arithmetic instructions add data in registers or memory.

ADD: (Add) This instruction adds an immediate data or contents of a memory location specified in the instruction or a register (source) to the contents of another register (destination) or memory location. The result is in the destination operand. However, both the source and destination operands cannot be memory operands. Also contents of segment registers
______________________________________________________________________________________

Department of Computer Engineering SIES GST 2

cannot be added using this instruction. All the condition code flags are affected depending on the result.

STEPS:

Store the 8-bit numbers in registers or memory locations. Use add instruction to add two numbers. Use DAA to convert to BCD. Store the result in register or memory location.

CONCLUSION: Assembly coding is done to add two 8-bit numbers, numbers and result both are stored in registers. As the program is written using the basic operations of the processor, the program forms the basis of any efficient application that includes mathematical operations.

______________________________________________________________________________________

Department of Computer Engineering SIES GST 3

EXPERIMENT NO: 01(b)

BCD SUBTRACTION

AIM: To perform two 8 bit BCD subtractions.

THEORY: Instructions used in program:

MOV: (Move) This data transfer instruction transfers data from one register/memory location to another register/memory location. The source may be nay one of the segment registers or other general or special purpose registers or a memory location and another register/memory location may act as destination. However, in case of immediate addressing mode, a segment register cannot be a destination register. In other words, direct loading of the segment registers with immediate data is not permitted. To load the segment registers with immediate data, one will have to load any general purpose register with the data and then it will have to be moved to that particular segment register.

The arithmetic instructions add data in registers or memory.

SUB: The subtract instruction subtracts the source operand from the destination operand and the result is left in the destination operand. Source operand may be a register, memory location or immediate data and the destination operand may be a register or a memory location. But source and destination operands both must not be memory operands. Destination operand cannot be an immediate data. All the condition code flags are affected by the instruction.
______________________________________________________________________________________

Department of Computer Engineering SIES GST 4

DAS: Decimal Adjust after Subtraction This instruction converts the result of subtraction of two packed BCD numbers to a valid BCD number. The subtraction has to be in AL only. If the lower nibble of AL is greater than 9, this instruction will subtract 06 from lower nibble of Al. If the result of subtraction sets the carry flag or if upper nibble is greater than 9, it subtracts 60H from AL. This instruction modifies the AF,CF,SF,PF, and ZF flags. The OF is undefined after DAS instruction.

STEPS:

Store the 8-bit numbers in registers or memory locations. Use sub instruction to subtract two numbers. Use DAS to covert to BCD. Store the result in register or memory location.

CONCLUSION: Assembly coding is done to subtract two 8-bit numbers, numbers and result both are stored in registers. As the program is written using the basic operations of the processor, the program forms the basis of any efficient application that includes mathematical operations.

______________________________________________________________________________________

Department of Computer Engineering SIES GST 5

EXPERIMENT NO: 02(a)

MULTIPLICATION

AIM: To perform BCD Multiplication.

THEORY: Instructions used in program:

MOV: (Move) This data transfer instruction transfers data from one register/memory location to another register/memory location. The source may be nay one of the segment registers or other general or special purpose registers or a memory location and another register/memory location may act as destination. However, in case of immediate addressing mode, a segment register cannot be a destination register. In other words, direct loading of the segment registers with immediate data is not permitted. To load the segment registers with immediate data, one will have to load any general purpose register with the data and then it will have to be moved to that particular segment register.

MUL: Unsigned Multiplication Byte or Word This instruction multiplies an unsigned byte or word by the contents of AL. The unsigned byte or word may be in any one of the general purpose registers or memory locations. The most significant word of the result is stored in AX. All the flags are modified depending upon the result. Immediate operand is not allowed in this instruction.

AAM: ASCII adjust after Multiplication This instruction, after execution, converts the product available in AL into unpacked BCD format. This instruction follows multiplication instruction that multiplies two
______________________________________________________________________________________

Department of Computer Engineering SIES GST 6

unpacked BCD operands, that is, higher nibbles of the multiplication operands should be 0. The multiplication of such operands is carried out using MUL instruction. The result of multiplication is available in AX.

STEPS:

Store the 8-bit numbers in registers or memory locations. Use mul instruction to multiply two numbers. Use AAM to covert to BCD. Store the result in register or memory location.

CONCLUSION: Assembly language code is written to multiply two 8-bit numbers; numbers and result both are stored in registers. As the program is written using the basic operations of the processor, the program forms the basis of any efficient application that includes mathematical operations.

______________________________________________________________________________________

Department of Computer Engineering SIES GST 7

EXPERIMENT NO: 02(b)

DIVISION

AIM: To perform 8 bit subtraction.

THEORY: Instructions used in program:

MOV: (Move) This data transfer instruction transfers data from one register/memory location to another register/memory location. The source may be nay one of the segment registers or other general or special purpose registers or a memory location and another register/memory location may act as destination. However, in case of immediate addressing mode, a segment register cannot be a destination register. In other words, direct loading of the segment registers with immediate data is not permitted. To load the segment registers with immediate data, one will have to load any general purpose register with the data and then it will have to be moved to that particular segment register.

AAD: ASCII Adjust before Division This instruction converts two unpacked BCD digits in AH and AL to the equivalent binary number in AL. This adjustment must be made before dividing the two unpacked BCD digits in AX by an unpacked BCD type. PF, SF, ZF are modified while AF, CF, OF are undefined, after the execution of the instruction AAD.

DIV: (unsigned Division) This instruction performs unsigned division. It divides an unsigned word or double word by a 16-bit or 8-bit operand. The dividend must be in AX for 16-bit operation and divisor
______________________________________________________________________________________

Department of Computer Engineering SIES GST 8

may be specified using any one of the addressing modes except immediate. The result will be in AL while AH will contain the remainder. If the result is too big to fit in AL, type 0 interrupt is generated. In case of a double word dividend (32-bit), the higher word should be in DX and lower word should be in AX. The divisor may be specified as explained earlier. The quotient and remainder will be in AX and DX respectively. The instruction does not affect any flag.

STEPS:

Store the 16-bit number and 8-bit number in registers or memory locations. Use div instruction to divide two numbers. Use AAD to covert to BCD. Store the result in register or memory location.

CONCLUSION: Assembly coding is done to divide 16-bit number by 8-bit number, numbers and result both are stored in registers. As the program is written using the basic operations of the processor, the program forms the basis of any efficient application that includes mathematical operations.

______________________________________________________________________________________

Department of Computer Engineering SIES GST 9

EXPERIMENT NO: 03

BCD ADDITION

AIM: To perform 16 bit BCD addition.

THEORY: Instructions used in program:

MOV: (Move) This data transfer instruction transfers data from one register/memory location to another register/memory location. The source may be nay one of the segment registers or other general or special purpose registers or a memory location and another register/memory location may act as destination. However, in case of immediate addressing mode, a segment register cannot be a destination register. In other words, direct loading of the segment registers with immediate data is not permitted. To load the segment registers with immediate data, one will have to load any general purpose register with the data and then it will have to be moved to that particular segment register.

The arithmetic instructions add data in registers or memory.

ADD: (Add) This instruction adds an immediate data or contents of a memory location specified in the instruction or a register (source) to the contents of another register (destination) or memory location. The result is in the destination operand. However, both the source and destination operands cannot be memory operands. Also contents of segment registers cannot be added using this instruction. All the condition code flags are affected depending on the result.
______________________________________________________________________________________

Department of Computer Engineering SIES GST 10

ADC: Add with Carry This instruction adds the carry flag bit to the result. All the condition code flags are affected by this instruction.

DAA: DAA instruction (Decimal Adjust Accumulator) allows conversion of the 8-bit accumulator value to Binary Coded Decimal (BCD). If the low-order 4 bits of the accumulator are greater than 9, or the auxilliary carry flag is set, 6 is added to the loworder 4 bits of accumulator, then if the high-order 4 bits of the accumulator are greater than 9, or the carry flag is set, 6 is added to the high-order 4 bits of the accumulator.

STEPS:

Store the 16-bit numbers in registers or memory locations. Use ADD instruction to ADD lower bytes. Use DAA to covert to BCD. Use ADD instruction to ADD higher bytes. Use DAA to covert to BCD. Store the result in register or memory location.

CONCLUSION: Assembly coding done to perform 16-bit addition and result converted to BCD using DAA instruction.

______________________________________________________________________________________

Department of Computer Engineering SIES GST 11

EXPERIMENT NO: 04

BCD FROM ASCII

AIM: To produce a packed BCD from two ASCII encoded digits.

THEORY: Instructions used in program:

MOV: (Move) This data transfer instruction transfers data from one register/memory location to another register/memory location. The source may be nay one of the segment registers or other general or special purpose registers or a memory location and another register/memory location may act as destination. However, in case of immediate addressing mode, a segment register cannot be a destination register. In other words, direct loading of the segment registers with immediate data is not permitted. To load the segment registers with immediate data, one will have to load any general purpose register with the data and then it will have to be moved to that particular segment register.

AND: (Logical AND) This instruction bit by bit ANDs the source operand that may be an immediate, a register or a memory location to the destination operand that may be a register or a memory location. The result is stored in the destination operand. At least one of the operand should be a register or a memory operand. Both the operands cannot be memory locations or immediate operands. An immediate operand cannot be a destination operand.

______________________________________________________________________________________

Department of Computer Engineering SIES GST 12

ROL: (Rotate Left without Carry) This instruction rotates the content of the destination operand to the left by the specified count excluding carry. The most significant bit is pushed into the carry flag as well as the least significant bit position at each operation. The remaining bits are shifted left subsequently by the specified count positions. The PF, SF, ZF flags are left unchanged in this rotate operation. The operand may be a register or a memory location.

STEPS:

Store the 8-bit numbers in registers or memory locations. Mask the lower nibbles with 0f H Rotate left the nibble in one register Add the nibbles to get packed BCD.. Store the result in register or memory location.

CONCLUSION: Assembly coding done to generate packed BCD from two ASCII codes results stored in register.

______________________________________________________________________________________

Department of Computer Engineering SIES GST 13

EXPERIMENT NO: 05

FACTORIAL

AIM: Program to find factorial

THEORY: Instructions used in program:

MOV: (Move) This data transfer instruction transfers data from one register/memory location to another register/memory location. The source may be nay one of the segment registers or other general or special purpose registers or a memory location and another register/memory location may act as destination. However, in case of immediate addressing mode, a segment register cannot be a destination register. In other words, direct loading of the segment registers with immediate data is not permitted. To load the segment registers with immediate data, one will have to load any general purpose register with the data and then it will have to be moved to that particular segment register.

MUL: Unsigned Multiplication Byte or Word This instruction multiplies an unsigned byte or word by the contents of AL. The unsigned byte or word may be in any one of the general purpose registers or memory locations. The most significant word of the result is stored in AX. All the flags are modified depending upon the result. Immediate operand is not allowed in this instruction.

______________________________________________________________________________________

Department of Computer Engineering SIES GST 14

LOOP: Loop Unconditionally This instruction executes the part of the program from the label or address specified in the instruction up to the loop instruction, CX number of times. In other words, this instruction implements DECREMENT COUNTER and JUMP IF NOT ZERO structure.

STEPS:

Store the 8-bit number in registers or memory location. Use mul instruction to multiply. Loop to continue multiplying up to 1. Store the result in register or memory location.

CONCLUSION: Assembly code written to find the factorial of a number which finds applications in combinotrics.

______________________________________________________________________________________

Department of Computer Engineering SIES GST 15

EXPERIMENT NO: 06

SORTING AN ARRAY

AIM: To sort the numbers in ascending order. . THEORY: Instructions used in program:

MOV: (Move) This data transfer instruction transfers data from one register/memory location to another register/memory location. The source may be nay one of the segment registers or other general or special purpose registers or a memory location and another register/memory location may act as destination. However, in case of immediate addressing mode, a segment register cannot be a destination register. In other words, direct loading of the segment registers with immediate data is not permitted. To load the segment registers with immediate data, one will have to load any general purpose register with the data and then it will have to be moved to that particular segment register.

ADD: (Add) This instruction adds an immediate data or contents of a memory location specified in the instruction or a register (source) to the contents of another register (destination) or memory location. The result is in the destination operand. However, both the source and destination operands cannot be memory operands. Also contents of segment registers cannot be added using this instruction. All the condition code flags are affected depending on the result.

______________________________________________________________________________________

Department of Computer Engineering SIES GST 16

INC: (Increment) This instruction increases the contents of the specified register or memory location by 1. All the condition code flags except the carry flags are affected. This instruction adds 1 to the contents of the operand. Immediate data cannot be operand of this instruction.

DEC: (Decrement) This instruction decreases the contents of the specified register or memory location by 1. All the condition code flags except the carry flags are affected. This instruction subtracts 1 from the contents of the operand. Immediate data cannot be operand of this instruction.

CMP: (Compare) This instruction source operand which may be a register, memory location or an immediate data with a destination operand which may be a register or a memory location. For comparison, it subtracts the source operand from the destination operand but does not store the result anywhere. The flags are affected depending upon the result of the subtraction. If both of the operand is equal, zero flag is set. If source operand is greater than the destination operand carry flag is set or else, carry flag is reset.

JNZ: (Jump if Not Zero) Transfers execution control to the specified address or label if ZF = 0

STEPS:

Store the 8-bit numbers in a array. Use simple comparison technique to sort the elements of the array. Display the results on the screen.

______________________________________________________________________________________

Department of Computer Engineering SIES GST 17

CONCLUSION: Assembly language code implemented to sort a set of numbers stored in an array using insertion sort, TASM/MASM assembler used to run the program. Sorting finds application in database search.

______________________________________________________________________________________

Department of Computer Engineering SIES GST 18

EXPERIMENT NO: 07

FINDING MAXIMUM NUMBER

AIM: To find maximum number in the array.

THEORY: Instructions used in program:

MOV: (Move) This data transfer instruction transfers data from one register/memory location to another register/memory location. The source may be nay one of the segment registers or other general or special purpose registers or a memory location and another register/memory location may act as destination. However, in case of immediate addressing mode, a segment register cannot be a destination register. In other words, direct loading of the segment registers with immediate data is not permitted. To load the segment registers with immediate data, one will have to load any general purpose register with the data and then it will have to be moved to that particular segment register.

LEA: (Load Effective Address) The load effective address instruction loads the effective address formed by destination operand into the source register. This instruction is more useful for assembly language rather than for machine language.

CMP: (Compare) This instruction source operand which may be a register, memory location or an immediate data with a destination operand which may be a register or a memory location.
______________________________________________________________________________________

Department of Computer Engineering SIES GST 19

For comparison, it subtracts the source operand from the destination operand but does not store the result anywhere. The flags are affected depending upon the result of the subtraction. If both of the operand is equal, zero flag is set. If source operand is greater than the destination operand carry flag is set or else, carry flag is reset.

INC: (Increment) This instruction increases the contents of the specified register or memory location by 1. All the condition code flags except the carry flags are affected. This instruction adds 1 to the contents of the operand. Immediate data cannot be operand of this instruction.

DEC: (Decrement) This instruction decreases the contents of the specified register or memory location by 1. All the condition code flags except the carry flags are affected. This instruction subtracts 1 from the contents of the operand. Immediate data cannot be operand of this instruction.

JNZ: (Jump if Not Zero) Transfers execution control to the specified address or label if ZF = 0

JNC: (Jump if Not Carry) Transfers execution control to the specified address or label if CF = 0

STEPS:

Store the 8-bit numbers in a array. Use simple comparison technique to find MAX element of the array. Display the results on the screen.

______________________________________________________________________________________

Department of Computer Engineering SIES GST 20

CONCLUSION: Assembly language code implemented to find the max element in array, TASM/MASM assembler used for code execution.

______________________________________________________________________________________

Department of Computer Engineering SIES GST 21

EXPERIMENT NO: 08

DISPLAY CHARACTERS

AIM: To find maximum number in the array.

THEORY: Instructions used in program:

MOV: (Move) This data transfer instruction transfers data from one register/memory location to another register/memory location. The source may be nay one of the segment registers or other general or special purpose registers or a memory location and another register/memory location may act as destination. However, in case of immediate addressing mode, a segment register cannot be a destination register. In other words, direct loading of the segment registers with immediate data is not permitted. To load the segment registers with immediate data, one will have to load any general purpose register with the data and then it will have to be moved to that particular segment register.

INT N: (Interrupt Type N) In the interrupt structure of 8086, 256 interrupts are defined corresponding to the types from 00H to FFH. When an INT N instruction is executed, the TYPE byte N s multiplied by 4 and the contents of the IP and CS of the interrupt service routine will be taken from the hexadecimal multiplication as offset address and 0000 as segment address. In other word, the multiplication of type N by 4 (offset) points to a memory block in 0000
______________________________________________________________________________________

Department of Computer Engineering SIES GST 22

segment, which contains the IP and CS values of the interrupt service routine. For the execution of this instruction, the IF must be enabled.

INC: (Increment) This instruction increases the contents of the specified register or memory location by 1. All the condition code flags except the carry flags are affected. This instruction adds 1 to the contents of the operand. Immediate data cannot be operand of this instruction.

LOOP: (Loop Unconditionally) This instruction executes the part of the program from the label or address specified in the instruction up to the loop instruction, CX number of times. In other words, this instruction implements DECREMENT COUNTER and JUMP IF NOT ZERO structure.

CONCLUSION: Assembly program written to display characters A-Z on screen.

______________________________________________________________________________________

Department of Computer Engineering SIES GST 23

EXPERIMENT NO: 09

STRING CONCATENATION

AIM: To write a program for string concatenation.

THEORY: Instructions used in program:

MOV: (Move) This data transfer instruction transfers data from one register/memory location to another register/memory location. The source may be nay one of the segment registers or other general or special purpose registers or a memory location and another register/memory location may act as destination. However, in case of immediate addressing mode, a segment register cannot be a destination register. In other words, direct loading of the segment registers with immediate data is not permitted. To load the segment registers with immediate data, one will have to load any general purpose register with the data and then it will have to be moved to that particular segment register.

LEA: (Load Effective Address) The load effective address instruction loads the effective address formed by destination operand into the source register. This instruction is more useful for assembly language rather than for machine language.

INC: (Increment) This instruction increases the contents of the specified register or memory location by 1. All the condition code flags except the carry flags are affected. This instruction adds 1 to the contents of the operand. Immediate data cannot be operand of this instruction.
______________________________________________________________________________________

Department of Computer Engineering SIES GST 24

JMP: (JUMP) This instruction unconditionally transfers the control of execution to the specified address using an 8-bit it 16-bit displacement. No flags are affected by this instruction.

STEPS:

Input two strings. Copy character by character of the input strings to a third string. Display the results on the screen.

CONCLUSION: Assembly language instructions written to concatenate two strings and display results on screen.

______________________________________________________________________________________

Department of Computer Engineering SIES GST 25

EXPERIMENT NO: 10

LOWERCASE TO UPPERCASE

AIM: To write a program to convert a lowercase character to uppercase.

THEORY: Instructions used in program:

MOV: (Move) This data transfer instruction transfers data from one register/memory location to another register/memory location. The source may be nay one of the segment registers or other general or special purpose registers or a memory location and another register/memory location may act as destination. However, in case of immediate addressing mode, a segment register cannot be a destination register. In other words, direct loading of the segment registers with immediate data is not permitted. To load the segment registers with immediate data, one will have to load any general purpose register with the data and then it will have to be moved to that particular segment register.

LEA: (Load Effective Address) The load effective address instruction loads the effective address formed by destination operand into the source register. This instruction is more useful for assembly language rather than for machine language.

AND: (Logical AND) This instruction bit by bit ANDs the source operand that may be an immediate, a register or a memory location to the destination operand that may be a register or a memory
______________________________________________________________________________________

Department of Computer Engineering SIES GST 26

location. The result is stored in the destination operand. At least one of the operand should be a register or a memory operand. Both the operands cannot be memory locations or immediate operands. An immediate operand cannot be a destination operand.

CONCLUSION: Assembly code executed to convert a character from lowercase to uppercase.

______________________________________________________________________________________

Department of Computer Engineering SIES GST 27

EXPERIMENT NO: 11

INTERFACING 8255

AIM: To configure 8255 in simple I/O mode . THEORY: To read at the output ports. 1. 80H is a control word for 8255. It is set in simple I/O mode and all the ports are in output mode 0. 2. The LEDs connected to the pin of port A glows according to the data transmitted on port A. 3. The LEDs connected to pin of port B glows according to data transmitted on port B. 4. The LEDs connected to pin of port C glows according to data transmitted on port C.

To read data at the input ports. 1. 9BH is a control word for 8255. It is set in simple I/O mode and all the ports are in input mode 0. 2. Connect pins of ports A, B,C to ground and Vcc according to the data to be given to ports A,B,C respectively. 3. Data from port A will be stores in register DL. The data in register DL should match data shown by glowing LEDs of port A.
______________________________________________________________________________________

Department of Computer Engineering SIES GST 28

4. Data from port B will be stores in register BL. The data in register BL should match data shown by glowing LEDs of port B. 5. Data from port C will be stores in register CL. The data in register CL should match data shown by glowing LEDs of port C.

CONCLUSION: Assembly language program implemented to configure 8255 PPI in simple I/O mode.

______________________________________________________________________________________

Department of Computer Engineering SIES GST 29

EXPERIMENT NO: 12

INTERFACING 8253

AIM: To configure 8253 in mode 3, that is, square wave generator. . THEORY: 1. 37H is a control word for 8253 with the counter in mode 3. BCD counter is selected. Load low order 8-bits and then high order 8-bits. 2. 06H is the low order 8-bit count, loaded in counter 0. 3. 00H is the high order 8-bit count, loaded in counter 0. 4. 87H is the control word for 8253 with the counter in mode 3. The count is latched and stored in register DX.

CONCLUSION: Assembly language program implemented to configure 8253 PIT in mode 3.

______________________________________________________________________________________

Department of Computer Engineering SIES GST 30

EXPERIMENT NO: 13

MIXED LANGUAGE

AIM: To Write a mixed language program in C and ASSEMBLY to: a) Emulation of a calculator b) To calculate sum of elements in an array

THEORY: C generates an object code that is extremely fast and compact but not as fast as the object code generated by a programmer using assembly language. The time needed to write a program in assembly language is much more than time taken by C. However, there are special cases where a function is coded in assembly language to reduce execution time. In addition certain instructions can be executed in C. Thus, inspite of C being very powerful routine must be written in ALP to : a) Increase the speed and efficiency of routine. b) Perform machine specific functions not available in C.

CONCLUSION: Mixed language program in C is implemented to emulate a simple calculator. Mixed mode programs increase the efficiency of the program as instructions directly command the processor, no translation is required as we are directly dealing with the hardware..

______________________________________________________________________________________

Department of Computer Engineering SIES GST 31

______________________________________________________________________________________

Department of Computer Engineering SIES GST 32

S-ar putea să vă placă și