This document provides information about assembly language programming using MASM/TASM assemblers on the Intel 8086/8088 microprocessors. It discusses the assembly, linking, and debugging processes. The assembler translates assembly code to machine code. The linker joins object files into an executable. A debugger allows loading, executing, and debugging programs. Common debugger commands are listed. The document also provides an introduction to the ESA 86/88E microcomputer trainer and its capabilities for assembly programming and interfacing.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online from Scribd
This document provides information about assembly language programming using MASM/TASM assemblers on the Intel 8086/8088 microprocessors. It discusses the assembly, linking, and debugging processes. The assembler translates assembly code to machine code. The linker joins object files into an executable. A debugger allows loading, executing, and debugging programs. Common debugger commands are listed. The document also provides an introduction to the ESA 86/88E microcomputer trainer and its capabilities for assembly programming and interfacing.
This document provides information about assembly language programming using MASM/TASM assemblers on the Intel 8086/8088 microprocessors. It discusses the assembly, linking, and debugging processes. The assembler translates assembly code to machine code. The linker joins object files into an executable. A debugger allows loading, executing, and debugging programs. Common debugger commands are listed. The document also provides an introduction to the ESA 86/88E microcomputer trainer and its capabilities for assembly programming and interfacing.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online from Scribd
This document provides information about assembly language programming using MASM/TASM assemblers on the Intel 8086/8088 microprocessors. It discusses the assembly, linking, and debugging processes. The assembler translates assembly code to machine code. The linker joins object files into an executable. A debugger allows loading, executing, and debugging programs. Common debugger commands are listed. The document also provides an introduction to the ESA 86/88E microcomputer trainer and its capabilities for assembly programming and interfacing.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online from Scribd
Download as docx, pdf, or txt
You are on page 1of 75
MICROPROCESSORS & INTERFACING LAB
VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 1
INTRODUCTION TO MASM/TASM
INTRODUCTION:
1. The first step in the development process is to write an assembly language program, can be written with an ordinary text editor. 2. Assembler translates a source file that was created using the editor, into machine language such as binary or object code 3. The Assembler generates two files on the floppy or hard disk during these two passes. 4. The first file is called as object file. This file contains the binary codes for the instructions and information about the addresses of the instructions. 5. The second file generated by the assembler is called assembler list file. This file contains the assembly language statements, The binary code for each instruction and the offset for each instruction.
C:\MASM\BIN\>MASM myprog.asm; Where myprog.asm is the name of the .asm file which is to be converted to .obj file
LINKING PROCESS:
A Linker is a program used to join together several object files into one large object file The command on command prompt for converting .obj file to .EXE file as given below:
C : \ MASM \ BIN \ > LINK myprog.obj
DEBUGGING PROCESS:
A debugger is a program, which allows us to load our object code program into system memory, execute the program, and debug it.
DEBUG COMMANDS:
Command Command Syntax and Description Assembler - A [address] A Command allows you to enter the mnemonic, or human readable, instructions directly GO - G [= address] [addresses] G Command executes the program in the memory. Quit - Q Q Command quits the debug. Register - R [register] R Command displays the register contents on the screen. Unassemble - U [range] U Command translates memory into assembly language mnemonics. INTRODUCTION TO ESA 86/88E
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 2
ESA 86/88E is an economical and powerful general-purpose microcomputer system that can be operated with 8086 or 8088 CPU that may be used as an instructional and learning aid and also as a development tool in R & D labs and industries.
8086 and 8088 are third generation CPUs from INTEL that differ primarily in their external data paths. 8088 uses an 8-bit wide data bus while 8086 uses a 16-bit wide data bus. ESA 86/88E can be operated with either CPU and the only is possible difference would be in the speed of execution (with 8088 CPU, a small speed degradation occurs because of the 8-bit wide data bus). In either case, the CPU is operated in maximum mode.
The basic system can be easily expanded through the system Bus connector. Powerful features like monitor resident Symbolic One-line assembler and Disassemble simplifies the programmer's task of entering Assembly language programs. On-board provision for 8087 Numeric Data Processor makes ESA 86/88E useful for number-crunching applications also. Onboard battery backup provision for RAM is made to retain the user programs in the event of a power failure or when the trainer is powered OFF. The trainer also features onboard Programmable Peripheral Interfaces, Programmable Interval Timers, USART (for serial communication), PC keyboard controller and parallel printer interface. Further, ESA 86/88E firmware also supports ESA EPROM Programmer interface.
ESA 86/88E can be operated on single +5 Volts power supply in stand-alone mode using LCD and optional PC/AT keyboard, or in serial mode with a host computer through its RS-232C interface. User-friendly Widows and DOS Driver packages supplied with ESA 86/88E provide for a powerful and versatile Assembly level programming/debugging environment.
SYSTEM CAPABILITIES: - Assemble 8086/8088 Instruction Mnemonics using ESA 86/88E Symbolic One-Line Assembler. - Disassemble HEZ bytes from memory into 8086/88 BPU instructions using monitor resident Disassembler. - Perform fast numerical computations using the optional 8087 Numeric Data Processor. - Execute the user program at full speed or debug the program through Single Step and Breakpoint facilities. - Examine/Modify the contents of memory locations in byte or word format. - Examine/Modify the content of CPU registers. - Write or read data to or from I/O ports (byte or word format). - Operations on blocks of memory such as filling a block of memory with a constant byte or word data, comparing a block of memory with another block, copying a block of data or program within the memory and displaying memory blocks in byte or word format. - Communicate with a Host PC serially through RS232C interface at a baud rate of up to 19200 and develop/debug applications using the user-friendly Windows or DOS driver packages. MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 3
- Supports for downloading user programs into ESA from a host computer system in Intel HEX as well as Intel Extended HEX format. - Support for uploading user programs to Host Computer system and saving them as HEX files on a system. - Read, Program, verify and Blank check of popular EPROM s Programmer interface module. - Use the monitor resident Centronics compatible Parallel printer driver software and obtain hard copies of Serial mode operations.
SPECIFICATIOS:
Central Processor: 8086 or 8088 CPU operating at 5 MHz in maximum mode. (Supplied with 8086 CPU)
Co-Processor: On-board 8087 Numeric Data processor.
Memory: ESA 86/88E provides a total of 128 Kbytes of onboard memory.
64K Bytes of ROM using two 27256 EPROMS.
64K Bytes of RAM using two 62256 Static RAM s.
ONBOARD PERIPHERALS AND INTERFACING OPTIONS:
8251A: Universal Synchronous/Asynchronous Receiver/Transmitter supporting standard baud rates from 110 to 19,200. Baud rate is selected through on-board DIPswitch setting. 8253-5:Programmable Interval Timer; Timer 0 is used for Baud clock generation. Timer 1 and Timer 2 are available to the user. 8255A: 3 Programmable Peripheral Interfaces provide up to 72 Programmable I/O lines. One 8255 is used for controlling LCD and reading DIP Switch. Two 8255s are for the user, of which one is populated by default and the other is optional. 8288 Bus Controller used for generating control signals in Maximum Mode operation. - 8042/8742 UPI (Universal Peripheral Interface) Interrupts
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 4
External: - NMI: 8086/8088 Type 2 Interrupt connected to KBINT key on the trainer. The vectoring information for this interrupt is fully user-defined. - INTR: Available to user on system expansion connector J6.
Internal: Interrupt Vectors 1 (Single step Interrupt) and 3 (Breakpoint Interrupt) reserved for monitor. External Interface Signals
CPU Bus: De-multiplexed and fully buffered, TTL compatible, Address, Data and Control signals are available on two 26-pin ribbon cable connectors.
Parallel I/O: 48 programmable parallel I/O lines (TTL Compatible) through two 26-pin ribbon cable connectors. Note that only one 8255 and its corresponding 26-Pin ribbon cable connector is available as default factory installation, which may additionally be used as a parallel printer interface. Further, ESA 86/88E firmware uses this 8255 for operations with ESA EPRON Programmer interface also.
Serial I/O: RS 232C through on-board 9 pin D-type female connector.
PC Keyboard: PS/2 connector is provided for interfacing PC Keyboard.
20 x 4 LCD: 15-Pin flow-strip for interfacing the 20x4 LCD.
Timer Signals: Timer 1 and Timer 2 signals are brought to a header.
Power Supply: + 5V @ 1A (approx.)
Battery backup: 3.6V Ni-Cd battery as power backup to RAM (optional).
ESA 86/88E MONITOR COMMANDS
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 5
N Single Step: Executes single instruction of the user program N<CR>[<start address>,],[,/<new address>]*<CR> COMMAND FUNCTION FORMAT/SYNTAX S Substitute Memory bytes: Displays/Modifies memory bytes S [<address>]<CR>[,/[<new data>],]*<CR> SW Substitute Memory Words: Displays/modifies memory words.
SW [<address>]<CR>[, /[<new data>],]*<CR>
D Display Memory bytes: Displays block of memory in word format D<start address>[,<end address>] <CR>
DW Display Memory words: Displays block of memory in word format DW<start address>[,<end address>] <CR> X Examine/modify registers: Displays modifies 8086/8088CPU registers
X [<reg><CR>[<new data>/,]]<CR>
M Move Memory: Copies a block of memory from one location to the other M<start address>,<end address>,<destination address><CR> F Fill Memory (Byte): Fills a block of Memory with constant byte data F<start address>,<end address>,<byte value><CR>
FW Fill Memory (Words): Fill a block of Memory with constant Word data FW<start address>,<end address>,<byte value><CR>
I Input byte: Accepts and displays the data byte at the input port I<port address><CR>[,]*<CR>
IW Input Word: Accepts and displays the data word at the input port IW<port address><CR>[,]*<CR> O Output byte: Outputs a data byte to the output port O<port address><CR>[<data>/,]*<CR> OW Output byte: Outputs a data word to the output port OW<port address><CR>[<data>/,]*<CR> C Compare Memory: Compares a block of memory with another block C<start address1>,<end address1>,<start address2><CR> MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 6
H Help Command: Lists Monitor commands with their valid syntax. H [<Command mnemonic>]<CR>
P* Invoke Programmer Software: Invokes the software for ESA EPROM Programmer Interface P<CR> A** Enter Assembler: Invokes EAS 86/88E Symbolic One-line Assembler A [address]<CR> LL** List Labels: Lists all labels defined in the symbol table
LL<CR> LC** Label Clear: Clears all previously defined label from the Symbol Table LC<CR> Z** Disassembly Command: Disassemble Hex code into 8086 mnemonics for a specific memory range Z [<start address>[, <end address>]]<CR>
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 7
MULTIBYTE ADDITION
A) AIM: To perform addition of 2 signed and unsigned words
ALGORITHM:
1. Get 1 st operand from memory that is pointed by source index [SI] register and store it in AX register. 2. Get 2 nd operand from memory and store it in BX register. 3. Add contents of AX and BX registers and the result will be in AX register. 4. Store the result in memory location pointed by DI.
PROGRAM:
PROGRAM STARTS AT 3000(ORIGIN) MEMORY LOCATION
LABEL MNEMONICS COMMENTS MOV AX,0000 ; Clearing accumulator MOV SI,2100 ; SI pointed to 2100 memory location MOV DI,2200 ; DI pointed to 2200 memory location MOV AX,[SI] ; get 1 st number in to accumulator INC SI ; increment SI by one INC SI ; increment SI by one to get next number MOV BX, [SI] ; move second number into BX register ADD AX, BX ; add two numbers and the result is in the AX register MOV [DI], AX ; store the result in memory location pointed by DI INT 03 ; it is a software interrupt which tells the processor to end the program.
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 8
G 3000 G 3000 Displays status of all registers. Displays status of all registers
AX = 2E01 BX = 1234 AX = 10F0 BX = DDAB CX = 0000 DX = 0000 CX = 0000 DX = 0000 SP = 0100 BP = 0000 SP = 0100 BP = 0000 SI = 2102 DI = 2200 SI = 2102 DI = 2200 DS = 0000 SS = 0000 DS = 0000 SS = 0000 ES = 0000 CS = 0000 ES = 0000 CS = 0000 IP = 3013 FL = F008 IP = 3013 FL = F008
OUTPUT: OUTPUT:
DW 2200 DW 2200
0000:2200 2E01 0000:2200 10F0
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 9
B) AIM: To perform addition operation of multibyte numbers for signed and unsigned nos.
ALGORITHM: 1. Make a register as a pointer to the memory location where the result is stored. 2. Make another two registers as pointers to the two operands stored in different locations. 3. Get the first 16-bits of the first operand from the memory store in register AX. 4. Get the higher 16-bit of the first operand from memory store in another register BX. 5. Get the first 16-bits of the second operand from the memory store in register CX 6. Get the higher 16-bits of the second operand from the memory store in register. DX. 7. Add BX to AX, result in AX. 8. Add with carry contents of DX to CX, result in CX, if carry occurs increment DL register. 9. Result stored in the memory location of DI
PROGRAM:
PROGRAM STARTS AT 5000(ORIGIN) MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV SI, 3000 ; Make SI as pointer to 3000 memory location MOV DI, 4000 ; Make DI as pointer to 4000 memory location CLC ; clear carry flag MOV AX, [SI] ; get contents from memory pointed by SI into AX register INC SI ; increments SI memory location INC SI ; increments SI memory location MOV CX, [SI] ; load higher 16 bit number of first number INC SI ; increments SI memory location INC SI ; increments SI memory location MOV BX, [SI] ; get lower 16 bit number of second number INC SI ; increments SI memory location INC SI ; increments SI memory location MOV DX, [SI] ; get higher 16 bit number of second number ADD AX, BX ; adding the lower 16 bit contents of two numbers ADC CX, DX ; adding the higher 16 bit contents with carry of the two numbers MOV DL, 00 ; to represent the carry bit JNC NEXT ; if there is no carry jump to the specified label MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 10
INC DL ; increments DL register NEXT: MOV [DI], AX ; store the contents in the memory pointed by DI INC DI ; increments the memory location of DI INC DI ; increments the memory location of DI MOV [DI], CX ; store the contents in the memory location pointed by DI INC DI ; increments the memory location of DI MOV [DI], DL ; store carry in memory location of DI INT 03 ; it is a breakpoint interrupt which tells processor it is end of the program
AX = 2345 BX = 1111 CX = 6789 DX = 1100 SP = 0100 BP = 0000 SI = 3006 DI = 4004 DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 5028 FL = F806 PC = 05028
OUTPUT:
DW 4000,4004
2345 6789 00 MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 11
MULTIBYTE SUBTRACTION
A) AIM: To perform subtraction of 2 signed and unsigned numbers.
ALGORITHM:
1. Get 1 st operand from memory, which is pointed by source index [SI] register and store it in AX register. 2. Get 2 nd operand from memory and store it in BX register. 3. Subtract contents of AX and BX registers and the result will be in AX register. 4. Store the result in memory location pointed by DI.
PROGRAM: PROGRAM STARTS AT 3000(ORIGIN) MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV AX,0000 ; Clearing accumulator MOV SI,2100 ; SI pointed to 2100 memory location MOV DI,2200 ; DI pointed to 2200 memory location MOV AX,[SI] ; get 1 st number in to accumulator INC SI ; increment SI by one INC SI ; increment SI by one to get next number MOV BX, [SI] ; move second number into BX register SUB AX, BX ; subtract two numbers and the result is in the AX register MOV [DI], AX ; store the result in memory location pointed by DI INT 03 ; it is a software interrupt which tells the processor to end the program.
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 12
G 3000 G 3000 Displays status of all registers. Displays status of all registers
AX = 1111 BX = 2234 AX = 5579 BX = DDCC CX = 0000 DX = 0000 CX = 0000 DX = 0000 SP = 0100 BP = 0000 SP = 0100 BP = 0000 SI = 2102 DI = 2200 SI = 2102 DI = 2200 DS = 0000 SS = 0000 DS = 0000 SS = 0000 ES = 0000 CS = 0000 ES = 0000 CS = 0000 IP = 3013 FL = F008 IP = 3013 FL = F008
OUTPUT: OUTPUT:
DW 2200 DW 2200
0000:2200 1111 0000:2200 5579 MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 13
B)AIM: To perform subtraction operation on two multibyte numbers
ALGORITHM: 1. Make a register as a pointer to the memory location where the result is stored. 2. Make another two registers as pointers to the two operands stored in different locations. 3. Get the first 16-bits of the first operand from the memory store in register AX. 4. Get the higher 16-bit of the first operand from memory store in another register BX. 5. Get the first 16-bits of the second operand from the memory store in register CX 6. Get the higher 16-bits of the second operand from the memory store in register. DX. 7. Subtract BX from AX, result in AX. 8. Subtract with borrow contents of DX from CX, result in CX 9. Result stored in the memory location of DI
PROGRAM: PROGRAM STARTS AT 5000(ORIGIN) MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV SI, 3000 ; Make SI as pointer to 3000 memory location MOV DI, 4000 ; Make DI as pointer to 4000 memory location CLC ; clear carry flag MOV AX, [SI] ; get contents from memory pointed by SI into AX register INC SI ; increments SI memory location INC SI ; increments SI memory location MOV CX, [SI] ; load higher 16 bit number of first number INC SI ; increments SI memory location INC SI ; increments SI memory location MOV BX, [SI] ; get lower 16 bit number of second number INC SI ; increments SI memory location INC SI ; increments SI memory location MOV DX, [SI] ; get higher 16 bit number of second number SUB AX, BX ; subtracting the lower 16 bit contents of two numbers SBB CX, DX ; subtracting the higher 16 bit contents with barrow of the two nos. MOV [DI], AX ; store the contents in the memory pointed by DI INC DI ; increments the memory location of DI INC DI ; increments the memory location of DI MOV [DI], CX ; store the contents in the memory location pointed by DI IN`T 03 ; it is a breakpoint interrupt which tells processor it is end of the program MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 14
AX = 0123 BX = 1111 CX = 4567 DX = 1111 SP = 0100 BP = 0000 SI = 3006 DI = 4002 DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 501F FL = F806 PC = 0501F
OUTPUT:
DW 4000,4002
0123 4567
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 15
MULTIBYTE MULTIPLICATION
MULTIPLICATION OF TWO 16-BIT NUMBERS
AIM: To perform multiplication of two words of signed and unsigned numbers and observe the result after executions.
ALGORITHM:
1. Get 1 st operand from memory that is pointed by source index [SI] register and store it in AX register. 2. Get 2 nd operand from memory and store it in BX register. 3. Multiply contents of AX and BX registers and the result will be in AX&DX registers. 4. Store the result in memory location pointed by DI.
PROGRAM: PROGRAM STARTS AT 3000(ORIGIN) MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV AX,0000 ; Clearing accumulator MOV DX,0000 ; Clearing DX register MOV SI,2100 ; SI pointed to 2100 memory location MOV DI,2200 ; DI memory pointed to 2200 location MOV AX,[SI] ; get 1 st number in to accumulator INC SI ; increment SI by one INC SI ; increment SI by one to get next number MOV BX, [SI] ; move second number into BX register MUL BX ; multiply two numbers and the result is in the AX & DX registers MOV [DI], AX ; store the result in memory location pointed by DI INC DI ; increments DI memory location
INC DI ; increments DI memory location to store DX contents MOV [DI], DX ; Store the result in memory location pointed by DI INT 03 ; it is a software interrupt which tells the processor to end the program.
INPUT: MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 16
For Unsigned Numbers For Signed Numbers (Use IMUL instruction instead of MUL)
G 3000 G 3000 Displays status of all registers. Displays status of all registers
AX = AE49 BX = 0035 AX = 6BFC BX = DDCC CX = 0000 DX = 0006 CX = 0000 DX = 2C6B SP = 0100 BP = 0000 SP = 0100 BP = 0000 SI = 2102 DI = 2202 SI = 2102 DI = 2202 DS = 0000 SS = 0000 DS = 0000 SS = 0000 ES = 0000 CS = 0000 ES = 0000 CS = 0000 IP = 301A FL = F008 IP = 301A FL = F008 PC = 0301A PC = 0301A OUTPUT: OUTPUT:
DW 2200 DW 2200
DW 2200,2202 DW 2200,2202
AE49 0006 2C6B 6BFC
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 17
MULTI BYTE DIVISION
A) DIVISION OF 16-BIT NUMBER BY 8-BIT NUMBER
AIM: To perform division of word with a byte.
ALGORITHM:
1. Get 1 st operand from memory, which is pointed by source index SI register and store it in AX register. 2. Get 2 nd operand from memory and store it in BL register. 3. Divide contents of AX with BL register and the results will be in AX register. 4. Store the result in memory location pointed by DI.
PROGRAM: PROGRAM STARTS AT 3000(ORIGIN) MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV AX,0000 ; Clearing accumulator MOV SI,2100 ; SI pointed to 2100 memory location MOV DI,2200 ; DI pointed to 2200 memory location MOV AX,[SI] ; get 1 st number in to accumulator INC SI ; Increment SI by one INC SI ; Increment SI by one MOV BL, [SI] ; move second number into BL register DIV BL ; divide the 16 bit number with an 8 bit number and the result is in the AX register MOV [DI], AX ; store the result in memory location pointed by DI INT 03 ; it is a software interrupt which tells the processor to end the program.
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 18
INPUT:
For Unsigned Numbers For Signed Numbers (Use IDIV Instruction instead of DIV)
SW 2100 SW 2100 0000:2100 0010, 0000:2100 2234,(8756) d
0000:2102 03 0000:2102 DE (-22) d
EXECUTION: EXECUTION:
G 3000 G 3000 Displays status of all registers. Displays status of all registers
AX = 0105 BX = 0003 AX = FE72 BX = 00DE CX = 0000 DX = 0000 CX = 0000 DX = 2C6B SP = 0100 BP = 0000 SP = 0100 BP = 0000 SI = 2102 DI = 2200 SI = 2102 DI = 2202 DS = 0000 SS = 0000 DS = 0000 SS = 0000 ES = 0000 CS = 0000 ES = 0000 CS = 0000 IP = 3013 FL = F008 IP = 301A FL = F008 PC = 03013 PC = 0301A OUTPUT: OUTPUT:
DW 2200 DW 2200
DW 2200 DW 2200
0105 FE72
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 19
B) DIVISION OF 32-BIT NUMBER BY 16-BIT NUMBER
AIM: To perform division of double word by a word and observe the result after executions.
ALGORITHM: 1. Get 32 bit number from memory that is pointed by source index SI register and store it in AX & DX registers. 2. Get dividend from memory and store it in BX register. 3. Divide contents of AX and DX registers with BX register and the result will be in AX&DX registers. 4. Store the result in memory location pointed by DI.
PROGRAM: PROGRAM STARTS AT 3000(ORIGIN) MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV AX,0000 ; Clearing accumulator MOV DX,0000 ; Clearing DX register MOV SI,2100 ; SI pointed to 2100 memory location MOV DI,2200 ; DI memory pointed to 2200 location MOV AX,[SI] ; get lower 16 bit number in to accumulator INC SI ; increment SI by one INC SI ; increment SI by one to get next number MOV DX, [SI] ; get higher 16 bit number into DX register INC SI ; increment SI by one INC SI ; increment SI by one to get next number MOV BX, [SI] ; get dividend in BX register DIV BX ; dividing 32 bit number which is in AX and DX registers with a 16 bit number which is in BX register. MOV [DI], AX ; store the result in memory location pointed by DI INC DI ; increments DI memory location INC DI ; increments DI memory location to store DX contents MOV [DI], DX ; Store the result in memory location pointed by DI INT 03 ; it is a software interrupt which tells the processor to end the program.
INPUT: MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 20
SW 2100
0000:2100 AE49, 0000:2102 0006, 0000:2004 0035
EXECUTION:
G 3000 Displays status of all registers.
AX = 2045 BX = 0035 CX = 0000 DX = 0000 SP = 0100 BP = 0000 SI = 2104 DI = 2202 DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 301E FL = F807 PC = 0301E
OUTPUT:
DW 2200,2202
2045 0000
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 21
ASCII ARITHMETIC OPERATIONS
A) ASCII ADDITION AIM: To perform ASCII arithmetic addition on 8086 kit.
ALGORITHM:
1. Initialize SI register with 2100 memory location. 2. Get 1 st operand into AL register and add with 2 nd operand that is in next memory location of SI. 3. Perform ASCII adjust for AL contents. 4. Add 30 to AL contents to obtain ASCII equivalent result. 5. Store the result in the memory location of SI.
PROGRAM: PROGRAM STARTS AT 3000(ORIGIN) MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV SI,2100 ; initialize SI with 2100 memory location MOV AL,[SI] ; get 1 st number into AL ADD AL,[SI]01 ; add 1 st number with 2 nd number which in the next memory location of SI AAA ; ASCII adjust after addition to AL contents OR AX,3030 ; add 30 to AL contents to obtain ASCII equivalent INC SI ; increments the memory location of SI INC SI ; increments the memory location of SI MOV [SI], AX ; store the result in the memory location of SI INT 03 ; it is a software interrupt which terminates the program
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 22
INPUT:
S 2100
0000:2100 34, 0000:2101 35
EXECUTION:
G 3000 Displays status of all registers.
AX = 0039 BX = 0000 CX = 0000 DX = 0000 SP = 0100 BP = 0000 SI = 2102 DI = 2200 DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 300F FL = F006 PC = 0300F
OUTPUT:
DW 2102
0000:2102 30 39
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 23
B) ASCII SUBTRACTION
AIM: To perform ASCII arithmetic subtraction on 8086 kit.
ALGORITHM:
1. Initialize SI register with 2100 memory location. 2. Get 1 st operand into AL register and subtract with 2 nd operand which is in next memory location of SI. 3. Perform ASCII adjusts for AL contents. 4. Add 30 to AL contents to obtain ASCII equivalent result. 5. Store the result in the memory location of SI.
PROGRAM: PROGRAM STARTS AT 3000(ORIGIN)MEMORY LOCATION LABEL MNEM Operand COMMENTS MOV SI,2100 ; initialize SI with 2100 memory location MOV AL,[SI] ; get 1 st number into AL SUB AL,[SI]01 ; subtract 1 st number with 2 nd number which in the next memory location of SI AAS ; ASCII adjust after subtraction to AL contents OR AX,3030 ; add 30 to AL contents to obtain ASCII equivalent INC SI ; increments the memory location of SI INC SI ; increments the memory location of SI MOV [SI], AX ; store the result in the memory location of SI INT 03 ; it is a software interrupt which terminates the program
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 24
INPUT:
S 2100
0000:2100 35, 0000:2101 34
EXECUTION:
G 3000 Displays status of all registers.
AX = 0031 BX = 0000 CX = 0000 DX = 0000 SP = 0100 BP = 0000 SI = 2102 DI = 2200 DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 300F FL = F006 PC = 0300F
OUTPUT:
DW 2102
0000:2102 30 31
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 25
C) ASCII MULTIPLICATION AIM: To perform ASCII arithmetic multiplication on 8086 kit.
ALGORITHM:
1. Initialize SI register with 2100 memory location. 2. Get 1 st operand into AL register and multiply with 2 nd operand which is in next memory location of SI. 3. Perform ASCII adjust for AL contents. 4. Add 3030 to AX contents to obtain ASCII equivalent result. 5. Store the result in the memory location of SI.
PROGRAM: PROGRAM STARTS AT 3000(ORIGIN)MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV SI,2100 ; Initialize SI with 2100 memory location MOV AL,[SI] ; Get 1 st number into AL SUB AL,30 ; Converting to unpacked BCD number INC SI ; Increment SI memory location MOV BL, [SI] ; Get 2 nd operand into BL register SUB BL,30 ; Converting to unpacked BCD number MUL BL ; Multiply 1 st number with 2 nd number which in the next memory location of SI AAM ; ASCII adjust to AXcontents OR AX,3030 ; Add 3030 to AX contents to obtain ASCII equivalent INC SI ; Increments the memory location of SI MOV [SI], AX ; Store the result in the memory location of SI INT 03 ; It is a software interrupt which terminates the program
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 26
INPUT:
S 2100
0000:2100 34, 0000:2101 35
EXECUTION:
G 3000 Displays status of all registers.
AX = 3230 BX = 0005 CX = 0000 DX = 0000 SP = 0100 BP = 0000 SI = 2102 DI = 2200 DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 3011 FL = F006 PC = 03011
OUTPUT:
DW 2102
0000:2102 32 30 MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 27
C) ASCII DIVISION AIM: To perform ASCII arithmetic division on 8086 kit.
ALGORITHM:
1. Initialize SI register with 2100 memory location. 2. Get 1 st operand into AL register and multiply with 2 nd operand which is in next memory location of SI. 3. Perform ASCII adjust for AX contents. 4. Add 3030 to AX contents to obtain ASCII equivalent result. 5. Store the result in the memory location of SI.
PROGRAM: PROGRAM STARTS AT 3000(ORIGIN)MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV SI,2100 ; Initialize SI with 2100 memory location MOV AX,[SI] ; Get 1 st number into AX SUB AX,3030 ; Converting to unpacked BCD number INC SI ; Increment SI memory location INC SI ; Increment SI memory location MOV BL, [SI] ; Get 2 nd operand into BL register SUB BL,30 ; Converting to unpacked BCD number AAD ; ASCII adjust to AX contents DIV BL ; Multiply 1 st number with 2 nd number which in the next memory location of SI OR AX,3030 ; Add 3030 to AX contents to obtain ASCII equivalent INC SI ; Increments the memory location of SI MOV [SI], AX ; Store the result in the memory location of SI INT 03 ; It is a software interrupt which terminates the program
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 28
INPUT:
S 2100
0000:2100 3230, 0000:2101 35
EXECUTION:
G 3000 Displays status of all registers.
AX = 3034 BX = 0035 CX = 0000 DX = 0000 SP = 0100 BP = 0000 SI = 2102 DI = 2200 DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 3013 FL = F006 PC = 03013
OUTPUT:
DW 2102
0000:2102 30 34
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 29
USING SHIFT AND ROTATE INSTRUCTIONS
A) NUMBER OF EVEN AND ODD NUMBERS IN A GIVEN SERIES
AIM: To find the no. of even and odd numbers from the given series of the numbers.
ALGORITHAM:
1. Make the SI as a pointer to the locations where the series of operands are stored. Store the number of bytes to be checked in CL 2. Get the number to be checked into AL. 3. Shift right the contents of AL and check for carry condition. 4. If carry is there that number is odd number otherwise it is a even number. 5. Number is even number increment one register for storing even number count. If the number is odd number increment another register, for storing odd number count. 6. Decrement the count and check for zero if not zero repeat from step 2.
PROGRAM: PROGRAM STARTS AT 5000(ORIGIN)MEMORY LOCATION. LABEL MNEMONICS COMMENTS
MOV SI, 4100 ; make SI as pointed to 4100 memory location
MOV DI, 4200 ; make DI as pointed to 4200 memory location
AX = 0036 BX = 0002 CX = 0000 DX = 0003 SP = 0100 BP = 0000 SI = 4106 DI = 4201 DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 5020 FL = F000 PC = 05020
OUTPUT:
D 4200,4201
02 03
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 31
B) NUMBER OF POSITIVE AND NEGATIVE NUMBERS IN A GIVEN SERIES
AIM: To find the no. of Positive and Negative numbers from the given series of the numbers. ALGORITHAM:
1. Make the SI as a pointer to the locations where the series of operands are stored. Store the number of bytes to be checked in CL 2. Get the number to be checked into AL. 3. Shift left the contents of AL and check for carry condition. 4. If carry is there that number is positive number otherwise it is a negative number. 5. Number is positives number increment one register for storing positive number count. If the number is negative number increment another register, for storing negative number count. 6. Decrement the count and check for zero if not zero repeat from step 2. PROGRAM: PROGRAM STARTS AT 5000(ORIGIN) MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV SI, 4100 ; make SI as pointed to 4100 memory location MOV DI, 4200 ; make DI as pointed to 4200 memory location MOV CL, [SI] ; get count from memory location MOV BL, 00 ; clear BL register to count negative numbers MOV DL,00 ; clear DL register to count positive numbers BACK: INC SI ; increments the memory location of SI MOV AL, [SI] ; get 1 st number from memory location into AL register SHL AL, 01 ; shift left contents of AL register JNC NEXT ; check for carry condition if there is no carry jump to the specified label, to increment DL register INC BL ; else increment BL which represents negative number JMP XX ; jump to the specified label. NEXT: INC DL ; increments DL register XX: LOOP BACK ; decrements count and check for zero condition MOV [DI], BL ; store the negative number count in the memory location of DI INC DI ; increments the memory location of DI MOV [DI], DL ; stores the positive number count in the memory location of DI INT 03 ; it is a software interrupt which tells end of the program
INPUT: MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 32
AX = 0036 BX = 0003 CX = 0000 DX = 0002 SP = 0100 BP = 0000 SI = 4106 DI = 4201 DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 5020 FL = F000 PC = 05020
OUTPUT:
D 4200,4201
03 02 MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 33
C) BCD TO HEXA DECIMAL CONVERSION
AIM: To convert BCD number in to Hexadecimal number.
ALGORITHM:
1. Initialize AX with zeros. 2. Make SI as a pointer to the location, where BCD number is stored. 3. Move the BCD number to AL and BL register. 4. Logical AND the contents of BL with 0F the result will be in BL register. 5. Logical AND the contents of AL with F0 and the result will be in AL register. 6. Rotate the contents of AL with CL times. 7. Load BH with 0A and multiply AL contents with BH contents. 8. Add contents AX and BX and result is in AX register. 9. Store the contents of AX in to memory.
PROGRAM: PROGRAM STARTS AT 5000(ORIGIN) MEMORY LOCATION LABEL MNEMONICS COMMENTS
MOV AX,0000 ; Clear AX register
MOV SI,2100 ; make SI as pointer to 2100 location
MOV AL,[SI] ; contents of memory location stored in AL register
MOV BL,AL ; copy the contents of AL to BL.
AND BL, 0F ; Logical AND the contents of BL with 0F and result is in BL register
AND AL, F0 ; Logical AND the contents of AL with F0 and result is in AL register
MOV CL, 04 ; load CL register with 04
ROR AL,CL ; rotate right AL contents with CL times
MOV BH,0A ; load BH with 0A
MUL BH ; multiply AL contents with BH contents
ADD AL, BL ; Add contents of AL and BL and result is in AL register
INC SI ; increment SI by one time
MOV [SI],AL ; store the result in to memory location pointed by SI
INT 03 ; break pointer interrupt which tells processor end of program
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 34
INPUT:
S 2100
0000:2100 45
EXECUTION:
G 3000 Displays status of all registers.
AX = 002D BX = 0A05 CX = 0004 DX = 0000 SP = 0100 BP = 0000 SI = 2101 DI = 8000 DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 501C FL = F000 PC = 0501C
OUTPUT:
D 2101
0000:2101 2D
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 35
D) CONVERTION OF HEXADECIMAL NUMBER TO DECIMAL NUMBER
AIM: To find the decimal number from the given hexadecimal numbers
ALGORITHM:
1. Initialize AX with zero. 2. Make SI as a pointer to the location, where hex number is stored. 3. Divide the hex number with 64H to find number of hundreds in the hex number. 4. Store the number of hundreds in the memory. 5. Store the remainder in AL. Divide it with 0A, to find number of 10s in the number. 6. Store the number of 10s in to next memory location. 7. Remainder obtained in the units place of the decimal number, store that in to next memory location.
PROGRAM: PROGRAM STARTS AT 5000(ORIGIN) MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV AX,0000 ; Clear AX register MOV SI, 2100 ; make SI as pointer to 2100 location MOV AL,[SI] ; contents of memory location stored in AL register MOV BL,64 ; load 64 to BL register DIV BL ; divides AX content with BL register INC SI ; increment SI MOV [SI],AL ; store the coefficient which is in AL into SI memory location MOV AL,AH ; contents of AH register will be moved into AL register MOV AH,00 ; clear AH register MOV BL,0A ; load 0A to BL register DIV BL ; divides AX content with BL register INC SI ; increment SI MOV [SI],AL ; store the coefficient which is in AL into SI memory location INC SI ; increment SI MOV [SI],AH ; store the reminder which is in AH into SI memory location INT 03 ; it is a software interrupt which tells end of a program
INPUT: MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 36
S 2100
0000:2100 FF
EXECUTION:
G 5000 Displays status of all registers.
AX = 0505 BX = 000A CX = 0000 DX = 0000 SP = 0100 BP = 0000 SI = 2103 DI = 8000 DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 501D FL = F000 PC = 0501D
OUTPUT:
D 2101,2103
02 05 05
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 37
CONVERSION OF PACKED BCDNUMBER TO UNPACKED BCDNUMBER
AIM: Program to convert packed BCD to unpacked BCD.
ALGORITHM:
1. Initialize SI as a pointer to the memory location where packed BCD number is stored. 2. Initialize DI as a pointer to memory location where unpacked BCD number is to be stored. 3. Get the packed BCD number in to AL and BL register. 4. Load CL register with 04 and rotate BL contents with CL times. 5. By logical AND the AL and BL contents 0F the packed BCD is converted into unpacked BCD.
PROGRAM: PROGRAM STARTS AT 5000(ORIGIN) MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV SI,2100 ; make SI as pointer to 2100 location MOV DI,2200 ; make DI as pointer to 2200 location MOV CL,04 ; load CL with 04 MOV AL,[SI] ; get BCD number to accumulator MOV BL, AL ; copy the contents of AL to BL register ROL BL, CL ; rotate BL contents with CL times AND AL, 0F ; logical AND of AL contents and 0F to unpack the BCD number AND BL, 0F ; logical AND of BL contents and 0F to unpack the BCD number MOV [DI], BL ; store the result to DI memory location INC DI ;increment DI by one location MOV [DI], AL ; store the result to DI memory location INT 03 ; It is a software interrupt which tells the processor end of the program MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 38
INPUT:
S 2100
0000:2100 35
EXECUTION:
G 3000 Displays status of all registers.
AX = 0005 BX = 0003 CX = 0004 DX = 0000 SP = 0100 BP = 0000 SI = 2100 DI = 2201 DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 5018 FL = F000 PC = 05018
OUTPUT:
D 2200,2201
03 05
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 39
BCD TO ASCII CONVERSION
AIM: To perform the BCD to ASCII conversion by assembly language program.
ALGORITHM:
1. Initialize SI with 2100, where BCD number is stored. 2. Initialize DI with 2200, where ASCII number is to be stored. 3. Store the number of times loop to be repeated in to CL. 4. Get the BCD number in to AL and AH.Unpack the BCD number in AL and AH. 5. To convert unpack BCD number to ASCII add 3030 to AX. 6. Move ASCII number in AX into memory.
PROGRAM: PROGRAM STARTS AT 5000(ORIGIN) MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV SI,2100 ; make SI as pointer to 2100 location MOV DI,2200 ; make DI as pointer to 2200 location MOV CL,04 ; load CL with 04 MOV AL,[SI] ; get BCD number to accumulator MOV AH, AL ; copy the contents of AL to AH register ROL AH, CL ; rotate AH contents with CL times AND AL, 0F ; logical AND of AL contents and 0F to unpack the BCD number AND AH, 0F ; logical AND of AH contents and 0F to unpack the BCD number OR AL, 30 ; OR AL contents to 30 to get ASCII equivalent OR AH, 30 ; OR AH contents to 30 to get ASCII equivalent MOV [DI], AH ; store the result to DI memory location INC DI ;increment DI by one location MOV [DI], AL ; store the result to DI memory location INT 03 ; It is a software interrupt which tells the processor end of the program
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 40
INPUT:
S 2100
0000:2100 35
EXECUTION:
G 5000 Displays status of all registers.
AX = 3335 BX = 0003 CX = 0004 DX = 0000 SP = 0100 BP = 0000 SI = 2100 DI = 2201 DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 501D FL = F000 PC = 0501D
OUTPUT:
D 2200,2201
33 35
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 41
MOVE BLOCK
AIM: To execute a program to move string of bytes from one location to the other location in the memory.
ALGORITHM:
1. Make SI as a pointer to the source block. 2. Make DI as a pointer to the destination block. 3. Store the number of bytes to transfer from one block to another block in CX. 4. Using MOVSB transfer byte from one location to another location. 5. Repeat step 4, count number of times in CX.
PROGRAM: PROGRAM STARTS AT 3000 (ORIGIN) MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV SI, 2100 ; make SI as pointed to memory location 2100 MOV DI, 2200 ; make DI as pointed to memory location 2200 MOV CX, 000A ; load CX register with the count CLD ; clear direction flag REP ; moves the strings from SI location to DI location and ; increments SI location and DI location and repeats ; this loop until CX becomes zero.
MOVSB
INT 03 ; it is a software interrupt which tells the processor it is ; end of the program
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 42
AX = 0001 BX = 0000 CX = 0000 DX = 0000 SP = 0100 BP = 0000 SI = 210A DI = 220A DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 3016 FL = F000 PC = 03016
OUTPUT:
D 2200,2209
01 02 03 04 05 06 07 08 09 10 MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 43
REVERSE STRING
AIM: To execute a program to obtain reverse of a given string
ALGORITHM:
1. Make SI as pointer to Data segment i.e., DS:SI and make DI as pointer to extra segment i.e., ES:DI . 2. Load CX register with the count. 3. Clear the direction flag, get data using SI to AL. 4. Set direction flag and store AL content into a location pointed out by DI. 5. Decrement the count and check for zero condition. If it is not zero go to step 3, else continue.
PROGRAM: PROGRAM STARTS AT 3000(ORIGIN) MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV CX, 000A ; load the counter with CX register MOV SI, 2100 ; initialize SI register to 2100 memory location MOV DI, 2209 ; initialize DI register to 220A memory location L1: CLD ; clear direction flag LODSB ; get the data from SI to AL STD ; set direction flag STOSB ; store the data from AL to DL LOOP L1 ; decrement count check for zero condition. If no zero jump to the specified label INT 03 ; it is a software interrupt which tells end of the program
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 44
AX = 0010 BX = 0000 CX = 0000 DX = 0000 SP = 0100 BP = 0000 SI = 210A DI = 2200 DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 300F FL = F000 PC = 0300F
OUTPUT:
D 2200,2209
10 09 08 07 06 05 04 03 02 01 MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 45
SORTING
A) ASCENDING ORDER
AIM: To perform the ascending order by the assembly language programming on 8086 kit.
ALGORITHM:
1. Load CX and BX registers with a length of array. 2. Get 1 st number from memory to AX register. 3. Compare AX register contents with the contents of next memory location. 4. Check for carry condition if there is no carry exchange the contents of AX register and [SI] 02 memory location. 5. If there is a carry increment SI by two times to get next number. 6. Decrement counter 7. If counter is not zero go to step 3, else continue. 8. Decrement the contents of CX, if CX is not zero go to step 2, else continue.
PROGRAM: PROGRAM STARTS AT 3000(ORIGIN) MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV CX, 0005 ; initialize CX register with number of elements L1: MOV SI, 2100 ; make SI as pointer with 2100 location MOV BX, CX ; initialize BX register with number of elements L2: MOV AX,[SI] ; get 1 st number into AX register DEC BX ;decrements counter by one CMP AX,[SI]02 ; compare AX with the contents of next memory location JB L3 ; check for carry condition if there is a carry jump to the specified label XCHG AX, [SI]02 ; exchange the contents of AX and [SI]02 XCHG AX,[SI] ; exchange the contents of AX and [SI] L3: INC SI ; increment SI INC SI ; increment SI DEC BX ; decrement the counter JNE L2 ; check for zero condition, if there is no zero jump to the specified label. LOOP L1 ; decrement CX register and check for zero condition, if there is no zero jump to the specified label. INT 03 ; it is a break point interrupt which tells the processor end of the program MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 46
AX = FFFF BX = 0000 CX = 0000 DX = 0000 SP = 0100 BP = 0000 SI = 210A DI = 8000 DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 301C FL = F800 PC = 0301C
OUTPUT:
DW 2100,2108
AAAA BBBB CCCC DDDD FFFF MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 47
B) DESCENDING ORDER
AIM: To perform the descending order by the assembly language programming on 8086 kit.
ALGORITHM:
1. Load CX and BX registers with a length of array. 2. Get 1 st number from memory to AX register. 3. Compare AX register contents with the contents of next memory location. 4. Check for no carry condition if there is carry exchange the contents of AX register and [SI] 02 memory location. 5. If there is a no carry increment SI by two times to get next number. 6. Decrement counter 7. If counter is not zero go to step 3, else continue. 8. Decrement the contents of CX, if CX is not zero go to step 2, else continue.
PROGRAM: PROGRAM STARTS AT 3000(ORIGIN) MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV CX,0005 ; initialize CX register with number of elements L1: MOV SI,2100 ; make SI as pointer with 2100 location MOV BX,0005 ; initialize BX register with number of elements L2: MOV AX,[SI] ; get 1 st number into AX register DEC BX ; decrements counter by one CMP AX,[SI]02 ; compare AX with the contents of next memory location JNB L3 ; check for no carry condition if there is no carry jump to the specified label XCHG AX,[SI]02 ; exchange the contents of AX and [SI]02 XCHG AX,[SI] ; exchange the contents of AX and [SI] L3: INC SI ; increment SI INC SI ; increment SI DEC BX ; decrement the counter JNE L2 ; check for zero condition, if there is no zero jump to the specified label. LOOP L1 ; decrement CX register and check for zero condition, if there is no zero jump to the specified label. INT 03 ; it is a break point interrupt which tells the processor end of the program MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 48
AX = AAAA BX = 0000 CX = 0000 DX = 0000 SP = 0100 BP = 0000 SI = 210A DI = 8000 DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 301C FL = F800 PC = 0301C
OUTPUT:
DW 2100,2108
FFFF DDDD CCCC BBBB AAAA MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 49
INSERTING A STRING BYTE
AIM: Program to insert a sub string in to main string.
ALGORITHM:
1. Make SI as pointer to data segment i.e., DS: SI. 2. Make DI as pointer to extra segment i.e., ES: DI. 3. Load CX with 0003 and clear the direction flag. 4. Repeat the loop until CX is not zero. 5. Move a byte from DS to ES and increment SI & DI memory locations 6. Make SI as pointer to data segment i.e., DS; SI and make DI as pointer to extra segment i.e., ES: DI 7. Load CX register with 0003 and clear direction flag. 8. Repeats the loop until CX is not zero. 9. Moves the substring from DS to ES.
PROGRAM: PROGRAM STARTS AT 5000 (ORIGIN) MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV SI, 3003 ; Make SI as pointer to 3003 MOV DI, 3006 ; make DI as pointer to 3006 MOV CX, 0003 ; load CX register with 0003 CLD ; Clear direction flag REPE ; repeat the loop if CX is not equal to zero
MOVSB ; moves a byte from DS to ES and increments SI and DI memory locations MOV SI,4000 ; Make SI as pointer to 4000 MOV DI,3003 ; Make DI as pointer to 3003 MOV CX,0003 ; load CX register with 0003 CLD ; Clear direction flag REPE ; repeat the loop if CX is not equal to zero
MOVSB ; moves a byte from DS to ES and increments SI and DI memory locations INT 03 ; it is a software interrupt which tells the processor end of the program.
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 50
AX = 0001 BX = 0003 CX = 0000 DX = FF00 SP = 0100 BP = 03B4 SI = 4003 DI = 3006 DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 5018 FL = F002 PC = 05018
OUTPUT:
D 3000,3008
01 02 03 AA BB CC 04 05 06 MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 51
DELETION OF A SUBSTRING FROM A MAIN STRING
AIM: Program to delete the sub string form main string and the result stored in particular location
ALGORITHM:
1. Make DI as a pointer to main string. 2. Make SI as a pointer to location. 3. Number of times the loop in repeated (or) number of bytes to be deleted is in CX. 4. Move the contents of 3004 and 3005 memory locations to 3002 and 3003,so the contents of these locations will be deleted PROGRAM: PROGRAM STARTS AT 5000(ORIGIN) MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV SI, 3004 ; Make SI as pointer to 3004 location MOV DI, 3002 ; Make DI as pointer to 3002 location MOV CX, 0002 ; Load CX register with 0002 CLD ; clear direction flag which increments SI & DI by one time REPE ; repeat until CX becomes zero MOVSB ; moves a byte from SI memory location to DI memory location INT 03 ; it is a software interrupt which tells end of a program
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 52
AX = 0006 BX = 0000 CX = 0000 DX = 0000 SP = 0100 BP = 0000 SI = 3005 DI = 3003 DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 500C FL = F002 PC = 0500C
OUTPUT:
D 3000,3003
01 02 05 06 MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 53
LENGTH OF THE STRING
AIM: To execute program for finding the length of the string.
ALGORITHM:
1. Load CX register with 0000 to represent the length of string. 2. Make SI as pointer to data segment. 3. Get content from memory location and compare with 00. 4. If they are not equal repeat step 3. 5. Increment CX contents and get next number again compare with 00. 6. Finally the length is in CX register.
PROGRAM: PROGRAM STARTS AT 3000 (ORIGIN) MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV CX,0000 ; clear CX register with 0000 MOV SI,2100 ;make SI as pointer to 2100 location MOV AX,0000 ; clear accumulator L1: LODSB ; get contents to AL register and increment SI memory location by one CMP AL,00 ; compare AL contents with 00 JE L2 ; Check for equal condition, if the contents are equal jump to specified label. INC CX ; increment CX register JMP L1 ; jumps to the specified label L2: MOV DI, 2200 ;make DI as pointer to 2200 location MOV [DI], CX ; store result in the memory location of DI INT 03 ; it is a software interrupt which tells processor end of the program
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 54
AX = B385 BX = 00FF CX = 0005 DX = 0000 SP = 0100 BP = 0000 SI = 2105 DI = 2200 DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 3016 FL = F046 PC = 03016
OUTPUT:
DW 2200
0000:2200 0005 MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 55
STRING COMPARISION
AIM: To execute a program to compare the string bytes given in two different memory Locations.
ALGORITHM:
1. Make SI as pointer to data segment and DI as pointer to extra segment. 2. Load CL with the count of string and clear direction flag. 3. Compare the two strings in SI and DI if both are equal store 00 in AL register, else store FF.
PROGRAM PROGRAM STARTS AT 3000(ORIGIN) MEMORY LOCATION LABEL MNEMONICS COMMENTS MOV SI,2100 ; initialize the source location MOV DI,2200 ; initialize the destination location MOV CX,0005 ; initializing the count CLD ; clear direction flag, increments SI and DI memory locations REP ; repeat until CX becomes zero CMPSB ; compare source contents with destination contents JCXZ NEXT ; checks CX = 0, if CX is zero jumps to the specified label MOV AL, FF ; move AL with FF to represent to unequal condition JMP XX ; jumps to the specified label NEXT: MOV AL, 00 ; move AL with 00 to represent to the equal condition XX: INT 03 ; it is a software interrupt which tells the processor it is the end of the program
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 56
AX = 00FF BX = 0000 CX = 0000 DX = 0000 SP = 0100 BP = 0000 SI = 2105 DI = 2205 DS = 0000 SS = 0000 ES = 0000 CS = 0000 IP = 3014 FL = F002 PC = 03014 MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 57
SEARCH STRING
AIM: To execute program for searching a byte string.
ALGORITHM:
1. Load CX register with 0005 to represent the length of string. 2. Make DI as pointer to extra segment. 3. Get content from memory location and compare with AL content. 4. If they are not equal repeat step 3. 5. Decrement CX contents and get next number again compare with AL. 6. Finally AL content will represents the presence of AL content in DI location.
PROGRAM: PROGRAM STARTS AT 3000(ORIGIN) MEMORY LOCATION. LABEL MNEMONICS COMMENTS MOV CX,0005 ; move CX register with the length of the string MOV DI,2100 ;make DI as pointer to 2100 location MOV AL,0F0 ; load accumulator with the byte, which is to be searched in the string L1: SCASB ; it searches the AL contents with the string pointed by DI LOOPNE L1 ; it decrements CX and checks for not equal condition JCXZ L2 ; Check for zero condition, if the contents are zero jump to specified label. MOV AL,00 ; Load AL with 00 to represent the presence of byte JMP L3 ; jumps to the specified label L2: MOV AL,0FF ; Load AL with 0FF i.e. the byte is not there in the string pointed by DI. MOV SI,5000 ; make SI as pointer to 5000 location L3: MOV [SI],AL ; store result in SI memory location INT 03 ; it is a software interrupt which tells processor end of the program
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 58
MOV AH, 02H Output character MOV DL, AL DL = character INT 21H Call DOS service CMP AL, # Compare input character with # JNE next character If not end, go for next character
MOV AH, 4CH MOV AL, 00H INT 21H
- Code ENDS End of segment End start end of program
INPUT:
From keyboard 'WELCOME'
OUTPUT:
'WELCOME' Initialize DS to the data segment Display string function call DOS service Read request without echo call DOS service returns character in AL Program terminate functions return code for error level setting call DOS services MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 61
8259-STUDY CARD
AIM: To Generate an interrupt using 8259 timer.
THEORY: The Intel 8259 is a programmable interrupt controller handles up to eight vectored priority interrupts for the CPU. It is cascadable for up to 64 vectored priority interrupt without additional circuitry. It is packaged in a 28 pin DIP, uses NMOS technology, and requires a single +5V supply. Circuitry is static, requiring no clock input. The interrupts at the IR input lines are handled by two registers in cascade, the Interrupt Request Register and the In-service Register (ISR). The IRR is used to store all the interrupt levels, which are requesting service and the ISR is used to store all the interrupt levels, which are being serviced. DESCRIPTION OF THE CIRCUIT: The 8259-study card allows the user to study the different modes of operation of 8259 by connecting it to different microprocessor/controller trainers. The interrupts to 8259 can be given from on-board provision or from external source through jumper selections. The on-board interrupt source uses a four-way dipswitch to select the eight different interrupts and the push button switch is to give the interrupt. For the on-board interrupt user has to place the jumpers JP1 to JP8 in the position 23.For external interrupt place the jumpers JP1 to JP8 at 12 positions, depends on the interrupt number. The study card has got two 26-pin (J3 & J4) and one 50-pin (P1) connectors for interfacing with different trainers. Default factory settings for on-board interrupts for ESA 86E trainer is as follows
JP1 = 23 JP6 = 23 JP2 = 23 JP7 = 23 JP3 = 23 JP8 = 23 JP4 = 23 JP9 = 23 JP5 = 23 JP10 = 12 JP11, JP12 & JP13 must be left open. 4-Way Dip Switch selection for different interrupts is as follows:
SWI 4 WAY 3 2 1 Interrupt No OFF OFF OFF OFF ON ON ON ON OFF OFF ON ON OFF OFF ON ON OFF ON OFF ON OFF ON OFF ON IR7 IR6 IR5 IR4 IR3 IR2 IR1 IR0
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 62
INTIALIZATION COMMAND WORDS (ICWs):
GENERAL
Whenever a command is issued with A0 = 0 and D4 = 1, this is interrupted as initialization command word (ICW1), ICW1 starts the initialization sequence during which the following automatically occur.
a. The edge sense circuit is reset, which means the following initialization; an interrupt request (IR) input must make a low- to-high transition to generate an interrupt. b. The Interrupt Mask Register is cleared. c. IR7 input is assigned priority 7. d. The slave mode address is set to 7. e. Special Mask mode is cleared and status read is set to IRR. f. If IC4 = 0, then all functions selected in ICW4 are set to zero. (Non Buffered mode*, no auto EOI, MCS 80,85 system).
Note: Master/Slave in ICW4 is only used in the buffered mode.
ICW2
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 63
0 X - NON BUFFERED MODE - BUFFERED MODE/SLAVE - BUFFERED MODE/MASTER 1 0 1 1
A15-A8 OF INTERUPT VECTOR ADDRESS (MCS80/85 MODE)T7-T3 OF INTERRUPT VECTOR ADDRESS (8086/8088 MODE) 1=SPECIAL FULLY NESTED MODE 0=NOT SPECIAL FULLY NESTED MODE MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 64
OPERATION COMMAND WORDS (OCWs): After the initialization command words (ICWs) are programmed into the 8259A, the chip is ready to accept interrupt requests at its input lines. However, during the 8259A operation, a selection of algorithms can command the 8259A to operate in various modes through the operation command words (OCWs). OCW1 A0
OCW1 sets and clears the mask bits in the interrupt Mask Register (IMR). M 7 M 0 represents the eight mask bits. M = 1 indicates the channel is masked (inhibited), M = 0 indicates the channel is enabled.
PROGRAM: PROGRAM STARTS AT 2000(ORGIN) MEMORY LOCATION. LABEL MNEMONICS COMMENTS MOV AX,0000
; INT0 VECTOR ADDRESS ;0120 IS THE BASE OF ; INT VECTOR TABLE
;ICW1 (IC4 NEEDED, SINGLE, ;INTERVAL 4, EDGE TRIG INT) ;ICW2 (MULTIPLE FOR INT VECTOR ;(ADDRESS TABLE) FOR MAKING ;120H AS BASE ADDRESS OF INT ;VECTOR TABLE ; ICW4(8086 MODE, AUTO EOI)
; OCW1 (ENABLE ALL INTERRUPTS)
; ENABLE INTR OF (8086)
MOV CS,AX MOV ES,AX MOV SS,AX MOV SP,3000 MOV SI,0120 MOV AX,2200 MOV [SI],AX ADD SI,02 MOV AX,0000 MOV [SI],AX MOV DX,0FFC8 MOV AL,17 OUT DX,AL MOV DX,0FFCA : MOV AL,48 OUT DX,AL MOV AL,03 OUT DX,AL MOV AL,00 OUT DX,AL STI HERE: JMP HERE
PROGRAM STARTS AT 2200(ORGIN) MEMORY LOCATION. LABEL MNEMONICS COMMENTS CLI ; INT0 ISR MOV DX, 2100 JMP 2300(DISP) INT 03
ORIGIN 2300H LABEL MNEMONICS COMMENTS MOV SI,DX ; COMMON DISPLAY ROUTINE ; FOR ALL ISRs
;CALL ROUTINE TO DISPLAY ;MESSAGE
; GET CHAR ROUTINE
; RETURN TO INTERRUPT MOV CX,0011 L1: MOV AL,[SI] CALLS 0FE00:0000 INC SI LOOP L1 CALLS 0FE00:00A9 STI IRET
EXECUTION:
G 2000
OUTPUT: INT0 OCCURRED (When PUSH button is pressed on Onboard 8259 study card the 'INTO OCCURD' message will be displayed on LCD display of 8086 Microprocessor kit).
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 66
8279-STUDY CARD
AIM: Program to display a string of characters.
THEORY: 8279 is a general purpose Programmable Keyboard and Display I/O Interface device designed for use with Intel microprocessors. The keyboard portion can provide a scanned interface to a 64- contact key matrix. The keyboard portion will also interface to an array of sensors or a strobed interface keyboard, such as Hall effect and ferrite variety. Key depressions can be 2-key lockout or N-key rollover. Keyboards entries are debounced and strobed in an 8- character FIFO. If more than 8 characters are entered, overrun status is set. Key entries set the interrupt output line to the CPU. The display portion provides a scanned display interface for LED, incandescent, and other popular display technologies. Both numeric and alphanumeric segment displays may be used as well as simple indicators. The 8279 has 16X8 display RAM, which can be organized into dual 16X4. The RAM can be loaded or interrogated by the CPU. Both right entry, calculator and left entry typewriter display formats are possible. Both read and write of the display RAM can be done with auto increment of the display RAM address.
DESCRIPTION OF THE CIRCUIT: The 8279-study card provides a keyboard as well as a display section. The display section features six 8 digit seven segment displays, while the keyboard section comprises a 4 X 4 matrix Hex Keypad and associated circuitry. The option for using shift and control keys during key scanning is also provided. The interface has 3 connectors. P1, J3 and J4. To interface the card with ESA 86/88E trainer, connect the 50 pin FRC connector P1 to J2 of ESA 86/88E study card adaptor.
For Encode method: place the jumpers as follows: JP1 = 1 2 JP2 = 2 3 JP3 = 2 3 JP4 = 1 2 JP5 = 2 3
For Decode method: place the jumpers as follows: JP1 = OPEN JP2 = 1 2 JP3 = 1 2 JP4 = 2 3 JP5 = 1 2
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 67
COMMAND WORDS OF 8279:
1 0 0 A I A A A A
The CPU seta up the 8279 for a write to display RAM by first writing this command. After writing the command with A 0 = 1, all subsequent writes with A 0 = 0 will be to the display RAM. The addressing and Auto increment functions are identical to those for the Read Display RAM.
; Eight 8-bit character ; display left entry ;decoded scan keybd
; Write to 8279 ; display RAM ;Routine to display ; a string of characters
MOV AL,00 MOV DX,0FFC2 OUT DX,AL MOV AL,90 OUT DX,AL RPT: MOV AL,00 MOV DX,0FFC0 OUT DX,AL LOOP RPT MOV DX,0FFC2 MOV AL,90 OUT DX,AL MOV SI,2100 MOV CX,0006 BC0: MOV AL,[SI] MOV DX,0FFC0 OUT DX,AL INC SI LOOP BC0 INT 03 ; Termination of the program
The segments of Seven Segment display are connected as shown in below
SEVEN SEGMENT DISPLAY
INPUT:
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 68
For letter I 0 1 1 0 0 0 0 0 = 60H For letter n 0 1 0 0 0 1 0 1 = 45H For letter d 1 1 1 0 0 1 0 1 = E5H For letter I 0 1 1 0 0 0 0 0 = 60H For letter A 0 1 1 1 0 1 1 1 = 77H For letter n 0 1 0 0 0 1 0 1 = 45H
I n d I A n
G 3000
OUTPUT:
Displays 'IndIan' on 8279 Keyboard display
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 69
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 70
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 71
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 72
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 73
DUAL DIGITAL TO ANALOG CONVERTOR
AIM: Programs to generate different waveforms (Sine, Square, Triangular and Saw tooth waveforms) using DAC interface.
THEORY:
The digital to analog converter (DAC) is a device widely used to convert digital pulses to analog signals. There are two methods of creating a DAC; one is Binary weighted method and other one is R/2R Ladder method. The vast majority of integrated circuit DACs, including the DAC0808 uses the R/2R method since it can achieve a much higher degree of precision. The first criterion for judging a DAC is its resolution, which is a function of the number of binary inputs. In the MC1408 (DAC0808), the digital inputs are converted to current (I out ), and by connecting a resistor to the I out pin, we convert the result to voltage. The total current provided by the Iout pin is a function of the binary numbers at the D0-D7 inputs of the DAC0808 and the reference current (I ref ), and is follows:
7 6 5 4 3 2 1 0 2 4 8 16 32 64 128 256 out ref D D D D D D D D I I | | = + + + + + + + | \ . Generally I ref = 2mA
DESCRIPTION OF THE CIRCUIT:
As can be seen in the circuit only 17 lines from the connectors are used totally. The port- A and port-B 8255 programmable. Peripheral interface are used as o/p ports. The digital inputs to the DAC are provided through port-A and port-B of 8255. The reference voltage for the DACs is derived from an on-board voltage regulator A 723. It generates the voltage of about 8V. The offset voltage balancing of op-amps is done by making use of the two 10K pots provided. The analog outputs of DACs connecting to inverting inputs of op-amps A 741 which act as current to voltage converter.
MICROPROCESSORS & INTERFACING LAB VISAKHA INSTITUTE OF TECHNOLOGY AND SCIENCE SONTYAM, VIZAG Page 74
CONTROL WORD:
D7 D6 D5 D4 D3 D2 D1 D0 Port C lower bit Group B 1-I/O modes 0-BSR mode Port B bit Mode of port B Mode of Port C upper bit GroupA Port A bit GroupA
B 6 B 5 MODE 0 0 mode 0 0 1 mode 1 1 0 mode 2 1 1 x
Download ebooks file Taping Wrapping and Bracing for Athletic Trainers Functional Methods for Application and Fabrication 1st Edition Andy Grubbs all chapters