Electronic Laboratory Manual Introduction to ...
Laboratory Exercise 1(a)
Objective:
Introducing the BGC- 8088 Microprocessor training system.
• Salient features.
• Hardware specifications.
• Software architecture.
Description:
The BGC Micro-engineer V3.4 is a 8088 microprocessor training system. It contains hardware and software to expand its functions and applications. It provides user an inexpensive and useful learning tool for the 8088 microprocessor.
Salient Features of BGC-8088 Micro-engineer V3.4 Trainer
(i) Hardware:
• 8088-2 CPU, 4.77 MHz clock, with 8 MHz option.8K SRAM and 16K EPROM with wired socket for additional 24K SRAM and 16K EPROM. 1MB RAM is optional.
• Keyboard: Large size, 56 alphanumeric and ASCII symbol keys. On-board LCD display. An external 80 x 24 monochrome monitor can be used with a Hercules card.
• Built in standard Centronics printer interface.
• RS-232 interface.
• Two IBM PC or compatible expansion slots.
• Status ports to display keyboard status as Caps Lock, Ins, and Ctrl-P. In addition, a speaker is built in for user application.
• Parallel control interfaces: Three 8-bit I/O ports(8255), three timers(8254), and five interrupt signals (8259A).
• An area on the main board is reserved for circuit designs and experiments.
• Switching power supply: +5V, +5V, +12V, +12V and GND.
(ii) Software:
• 8088 assembler and dis-assembler. Assembly language coding.
• Memory commands. D-display, M-move, C-Compare, E-edit and F-fill.
• Display and / or modify the contents of registers.
• Single step program execution and debug.
• Breakpoint debug, for setting up to 10 breakpoints for program debugging.
• Numerical systems conversions and calculations.
• Download / Upload from / to external system.
• RS-232 driver routine.
• Keyboard driver routine.
• Printer driver routine.
• Hercules card driver routine.
• LCD driver routine.
Hardware specifications of BGC-8088 Micro-engineer V3.4 Trainer
• CPU: 8088-2 CPU runs at 4.77 MHz. However, a clock rate of 8 MHz can be achieved
by using a 24 MHz crystal oscillator.
• RAM: The system provides 32K RAM, addresses from 00000H to 07FFFH, with
00000H to 00FFFH for system program and 0100H to 07FFFH for user applications.
• ROM: The system provides ROM, addresses from F8000H to FFFFFH, with
FC000H to FFFFFH for BIOS and F8000H to FBFFFH for user applications.
• Keyboard: It has 56 keys which include alphanumeric A-Z and 0-9 special ASCII
symbols.
• Display: An On-board 40x2 LCD module or a *)x24 monochrome monitor can be
used. The later requires a Hercules card.
• Printer interface: BGC-8088 provides a standard Centronics printer interface.
The connection cable is the same as those used in IBM PCs.
• RS-232 interface. The 8250 controls the RS-232 interface. It can be programmed for
baud rate, data bit, and stop bit.
• I/O expansion slot: The signals are compatible with the IBM PC expansion slot, but
no DMA function is provided.
• Status port: The status port is used to display keyboard statuses such as Caps Lock,
Ins, and Ctrl-P. A correspondent LED is lighted when the function is enabled. In addition, it provides the speaker interface to generate sound.
• Parallel control interface: Three IC’ s are used to provide parallel controls. They are
8255- three 8-bit I/O ports, 8254, - three timers, and 8259A – five interrupt signals.
• Power supply: +5V, -5V, +12V, -12V and GND are used in this system.
Software architecture of BGC-8088 Micro-engineer V3.4 Trainer
The BGC-8088 is designed to allow the user to access system programs and apply these programs to user’ s own applications. In addition, an I/O driver routine is available for each I/O device. These routines can be called by issuing an interrupt instructions in the user’ s application programs. The following diagram illustrates the software architecture.
System Program User Program
I/O Drivers
Hardware
System Commands:
The system commands provide
• Memory management
• Program control
• Numeric operation / conversion
• I/O control.
• Communication.
I/O Drivers:
The I/O drivers of BGC-8088 provide the software interface between the system and I/O devices.
• RS-232 driver.
• Keyboard driver
• Printer driver
• Hercules card driver
• LCD display driver
• Return to BIOS (system)
Assignment:
• Note down the IC part numbers used in the BGC-Trainer.
• Download the datasheets of each IC.
• Write summary of each IC.
Laboratory Exercise 1 (b)
Objective:
Introducing the syntax and use of the system commands of BGC trainer.
Description:
The system commands can be divided into the following groups according to their functions.
• Memory Management Commands.
• Assembler Commands.
• Numerical Operation Commands.
• Program Execution Commands.
Each command begins with a command letter followed by 1 to 3 operand parameters. The parameters of system commands are described below.
consists of two portions. Segment address: Offset address.
Segment registers, CS, DS, ES and SS are often used to hold a segment address. Segment address can be omitted, but the offset value must be indicated.
indicates an operation section of memory.
• The syntax for range must be one of th efollowing.
N
• is the starting address, and could contain both segment and offset addresses.
• is the ending address and contain only offset address.
• The addresses in must be in the same segment.
• The value of must be greater or equal to the offset address in
a 4 digit hexadecimal number.
a 2 digit hexadecimal number.
a set of characters included in single or double quotation marks.
a series of s, s, and /or s, separated by commas.
Memory Management Commands
C Compare the contents of two blocks of memory.
D Display the contents of memory.
E Edit (Write) data into memory.
F Fill the memory with a value.
M Move the contents of memory.
Command C: Compare the contents of two blocks of memory
Command syntax C,
• indicates the source area
• is the starting address of the target memory block.
• If any mismatch is found, the system displays both the source and target addressees and their contents.
Command D: Display the contents of memory
Command syntax D
• It will display the contents of a specified memory location.
• The ASCII codes for this value will also displayed.
• tells the D command what range of memory to display.
• If range is not specified, then the default starting address is set to the location following the last address used by a previous D command.
• It there is no previous D commands, then the default starting address is 0100:0000.
• The default length of display is 80H.
Command E: Edit (Write) data into memory Command syntax E
• It is used to write data into memory.
• When E command is used without a parameter; the system displays the and its contents, a byte of data.
• The user then types in a new byte of data, (two hexadecimal digits), to replace it.
• If is pressed, the next address can be edited.
• Memory can be edited until is pressed to exit the E command.
Command F: Fill the memory with a value
Command syntax F
• It is used to change the contents of a block of memory to a certain sequence of values.
• The memory locations specified in are filled with the values specified in .
Command M: Move the contents of memory
Command syntax M,
• It move the contents of a block of memory specified in from one place to another.
• The starting address of the destination is specified in .
• There are two different procedures for moving memory.
1. The first is used when the block occurs before the destination address.
2. The second is used when the destination start address is less than the source start address.
.
The destination occurs before the source
If the starting address of is greater than , data is moved from the starting address of to in ascending order.
The source occurs before the destination
If the starting address of the is smaller than , then the bytes of the are moved to the destination in descending order. This means that the last byte in the is moved to the last location in the destination first.
Assembler Commands
A Assemble a program.
U Disassemble a program
I Insert an instruction in a program.
[pic]
Command A: Assemble a program
Command syntax A []
• It is used to program with the 8088 assembly language.
• Since memory space on the BGC-8088 is restricted, the assembler is limited in comparison to a
PC macro assembler, these limitations are listed below.
➢ The assembler translate instructions into machine code and stores them in memory immediately after they are entered.
➢ There is no linking function.
➢ There is no macro function.
➢ Names and labels cannot be used to define the locations of the data segment or the code segment.
Command U: Disassemble a program
Command syntax U []
• It is used to disassemble assembly language instructions into machine code.
• is used to select a block of memory to disassemble.
• If is not specified, then the system will start immediately after the final address of the
last U command.
• If no U command have been executed, the default starting address is CS: IP, which is set to
0100:0000 after power-on.
• The default length is 20H.
Command I: Insert instruction into a program
Command syntax I []
• The I and A command can both be used to enter 8088 assembly language instructions.
• However, these two commands differ in how memory is handled.
• The A command overwrites the contents (machine codes) of the specified memory,
• While I command only pushes the contents back one location without erasing them.
• The INS key is used in toggle mode.i.e by pressing it will insert instructions into memory. As long as the INS LED is ON, the only way to leave insert mode is to press the INS key once again.
Numerical Operation Commands
B Decimal to binary conversion.
H Compute the sum and difference of 2 hexadecimal numbers.
J Decimal to hexadecimal conversion.
S Hexadecimal to decimal conversion.
V Binary to decimal conversion.
Command B: Converting decimal to binary
Command syntax B
• The range of decimal numbers on the BGC-8088 is 0 to 4294967295 (i.e. 65535 x 65535)
• Negative numbers are not considered.
• The binary representation for numbers in this range requires up to 32 bits.
• When the binary values is displayed, the leading zeroes are omitted, and B is appended to denote that the number is binary.
• If the decimal number is greater than 4294967295, it can not be converted into binary.
Command J: Converting decimal to hexadecimal
Command syntax J
• The range of decimal numbers is from 0 to 4294967295 , up to 8 digits are needed in the hexadecimal representation of a decimal number.
• As with the B command, the leading zeros or the result are not displayed and an H is suffixed to denote that the number is in hexadecimal.
Command S: Converting hexadecimal to decimal
Command syntax S
• The range of decimal numbers is from 0 to FFFFFFFF, and no negative numbers are considered.
• Therefore, the maximum decimal number is 4294967295.
• In the result, the leading zeros are not displayed and a D appended to denote decimal representation.
• If the input value is non-hexadecimal or greater than FFFFFFFF, no conversion is executed and an error message is issued.
Command V: Converting binary to decimal
Command syntax V
• The range of decimal numbers is from 0 to 11111111111111111111111111111111 (32 bits)
• Negative numbers are not considered.
• Therefore, the decimal result will not exceed 4294967295.
• In the result the leading zeros are not displays and a D is used to denote decimal representation.
Command H: Calculate the sum and difference
Command syntax H,
• If the sum is greater than FFFF the carry is discarded.
• Only 16 bits (4 hexadecimal digits) of the result are displayed.
• If is smaller than , a borrow is used to execute subtraction.
Program Control Commands
G Execute program
R Display or modify the contents of registers.
T Trace program execution.
Command G: Execute program
Command syntax G[=],[, ... ]
• The ‘ =’ sign in the above syntax indicates that a parameter will be given.
• If this symbol is not used , then the system assumes that any parameters are break points.
• specifies the beginning address of the program to be executed.
• Ιf it is not present, execution will start at the default value, which is the current CS: IP.
• tells the program results to determine whether the program runs as expected.
• Up to 10 break points are allowed.
• Multiple break points make debugging easier when the program contains flow control instructions, such as JNZ, JC, JNE etc.
• If no break point is set, control will not return to the user, until the program execution is completed.
Command R: Check / change the register contents
Command syntax R[=]
• The R command is used to check or change the contents of the 14 register in the BGC-8088 .
• It can be used to dump the register contents, or to display and modify the register contents.
• These functions can be described in the following ways.
R: Display the register contents
• If there is no specified, the R command is used to dump all the register contents to the screen.
• The registers are displayed in the following order:
AX, CX, DX, BX, SP, BP, SI, DI, ES, CS, SS, DS, IP and FG.
[pic]
R: : Display and modify the register contents.
• After executing this command, the name and contents of the specified register are displayed.
• The use can then modify the register contents, or press the key to display the next register in the order mentioned above.
• To exit this command Q or continuous to press until all the registers have been displayed.
RF: Display and modify the contents of the FG register
• The RF command displays the current status of each flag.
• The definition of the flag register is as follows.
Flag Register:
MSB LSB
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
XX XX XX XX OF DF IF TF SF ZF XX AF XX PF XX CY
Flags Name Bit = 1 Bit = 0
OF Overflow OV NV
DF Direction DN UP
IF Interrupt EI DI
TF Trap (Single step)
SF Sign N G PL
ZF Zero ZR NZ
AF Auxiliary Carry AC NA
PF Parity PE PO
CY Carry CY NC
Values of each flag Bits.
Command T: Trace program execution
Command syntax T[=], []
• The T command provides single step program execution.
• It executes one instruction at a time, and displays the register contents after each
instruction.
• is the beginning address for program execution.
• If it is not specified, the program starts at the current address of CS:IP.
• defines the number of instructions to be executed.
• The default value is 1.
• The P command is used, then Enter, at instruction LOOP to pass through the looping.
Assignment:
Write atleast first 8-bytes of each Memory Management Command.
Assemble the following code and fill the table.
|Logical Address |Opcode |Assembly code |comments |
| | |MOV AX, 0200H |; |
| | |MOV BX, 0400H |; |
| | |ADD AX, BX |; |
Give answer for the following questions regarding above results:
Why the values 0200H and 0400H are written as 0002 and 0004 respectively?
Write the number of bytes each instruction taken and also the value of IP register.
Laboratory Exercise 2 (a)
Objective:
Introducing DEBUG programming (at command prompt using PC).
Description:
DEBUG is a program included in the MS-DOS and PC-DOS operating systems that allows the programmer to monitor a program’s execution closely for debugging purposes. Specifically, it can be used to examine and alter the contents of memory, to enter and run programs, and to stop programs at certain points in order to check or even change data. Student will learn
• How to enter and exit DEBUG,
• How to code, run and debug programs
• How to look at machine code
• How to examine and alter the contents of registers and memory,
• How to examine and alter the FLAG register
Entering and Exiting DEBUG:
To enter and exit the DEBUG, simply type its name at the DOS level:
C:\> DEBUG
To quit the DEBUG, type Q at the DEBUG prompt and enter
Q
C:\>
Coding, Running and Debugging the programs:
To assemble a program, write the following at DEBUG prompt
A
Example: - A 100
Address Data/Code Mnemonics Comments
0100:0100 MOV BL, 05 ;Load data 05 in register BL
0100: MOV CL, 10 ;Load data 10 in register CL
0100: MOV AL, CL ; Position data
0100: MUL BL ;Multiplying
0100: MOV DX, AX ; Storing product in register DX
To run or execute the instructions, write the following at DEBUG prompt
G
“G stands for GO”
Assemble the above cod to multiply two numbers and run the instructions using G command.
Various forms of the Go Command
• -G
• -G = start address
• -G = start address ending address
• -G address
To debug a program, T (Trace) command is used which is a powerful debugging tool
T < = starting address > < number of instructions>
Also, Debug will inform any error by indicating “^Error” just under the faulty instruction.
Looking at the machine code , the Unassemble command:
The unassembled command displays the machine code in memory along with their equivalent Assembly language instructions. The command can be given in either format shown below.
U < starting address > < ending address >
U < starting address > < L number of bytes >
Get the above cod to multiply two numbers be unassembled using the U command at DEBUG prompt.
Examine and alter the contents of registers, FLAG registers and memory:
Using the following commands at the DEBUG prompt can examine and alter the contents of memory registers and FLAG registers,
F Fills a block of memory with data
F
F
D Dumps or Displays contents of memory on the screen
D
D E Enter command, examines/alters the memory contents
E
E
R check the contents of Registers
R
Rf ( for FLAG registers)
Laboratory Exercise 2 b
Objective:
To learn how to create and assemble an executable Assembly Language Programming using Assembler and Linker programs.
Description:
The three steps to be followed to create an executable assembly language program are listed as under
|Steps |Input |Program |Output |
|1. Edit the program |Keyboard |Editor |myfile.asm |
|2. Assemble the program |myfile.asm |TASM or MASM |myfile.obj |
|3. Link the program |myfile.obj |TLINK or LINK |myfile.exe |
Where, .asm, .obj, and .exe are the extension meaning assembler, object and executable file respectively.
Directives:
.model (memory models)
|Memory Models |Code segment size |Data segment size |
|Small |64kb |64kb |
|Medium |Can exceed 64kb |64kb |
|Compact |64kb |Can exceed 64kb |
|Large |Both can exceed 64kb (single data array can’t exceed 64kb) |
|Huge |Both can exceed 64kb (single data array can exceed 64kb) |
.stack 100h
Stack memory reserved 100 bytes
.data
Data segment starts
.code
Code segment starts
As it is obvious from the above description that a program is to be typed in by using an editor, like Notepad (in windows) or Edit (in DOS) with the extension “.asm”, it is then presented to an assembler program such as TASM (Turbo Assembler) or MASM (Microsoft’s Macro Assembler) in the following manner, (assuming that you are working on the COMMAND PROMPT)
C:\> MASM myfile.asm < return >
If no errors found in the program, MASM will generate an object file. This object file is to be presented to the TLINK (Turbo Linker) or LINK as
C:\> LINK myfile.obj < return >
If no errors occur, this will generate an executable file ready to be run stand-alone.
The executable file just created can be analyzed or debugged using DEBUG utility, the method will be
C:\> DEBUG myfile.exe < return >
The desired DEBUG commands can then be used.
ACTIVITY:
Write, Run and Analyze a program that adds 5 bytes of data and saves the result. The data should be the following numbers:
25, 12, 15, 1F, 2B
Laboratory Exercise 3
Objective:
To understand the basic assembly language instructions and performing basic arithmetic
operations.
To understand how the Half-Adder, Full Adder, Half-Subtractor, Full Subtractor, Multiplier and Divisor circuits are implemented as assembly instructions.
Theory:
Addition:
Half-Adder is implemented using the instruction ADD. No carry-in but carry-out may occur.
Full Adder is implemented using the instruction ADC. Both carry-in and carry-out may occur.
(a) Program to add two 32 bit numbers using ADC (add with carry) command.
Assembly Language Program:
Address Data/Code Mnemonics Comments
-------:0100 MOV AX,1111
-------: MOV BX,2000
-------: MOV CX,3000
-------: MOV DX,4000
-------: ADD AX,CX
-------: ADC BX,DX
Result :____________________________________________________________
Also write the flags affected.
Subtraction:
Half-Subtractor is implemented using the instruction SUB.
Full Subtractor is implemented using the instruction SBB.
Subtraction is implemented using 2’s complement method.
Steps involved in subtraction
1. Takes 2’s complement of subtrahend
2. Add it to the minuend.
3. Invert the carry.
If CY=0 then result is a positive number
Else if CY=1 then result is a negative number and stored in 2’s complement.
(b) Program to subtract two 32 bit numbers using SBB (Subtract With Borrow ) command.
Assembly Language Program:
Address Data/Code Mnemonics Comments
-------:0100 MOV AX,3000
-------: MOV BX,2000
-------: MOV CX,1000
-------: MOV DX,4000
-------: SUB AX,DX
-------: SBB BX,CX
Result :____________________________________________________________
Also write the flags affected.
Multiplication:
|Multiplication |Operand 1 |Operand 2 |Result |
|Byte x byte |AL |Register or memory |AX |
|Word x word |AX |Register or memory |DX AX |
|Word x byte |AL=byte, AH=0 |Register or memory |DX AX |
(c) Program to multiply two numbers store in registers BL and CL, and store the result in register DX.
Assembly Language Program:
Address Data/Code Mnemonics Comments
-------:0100 MOV BL, 05
-------: MOV CL, 10
-------: MOV AL, CL
-------: MUL BL
-------: MOV DX, AX
Result :____________________________________________________________
Also write the flags affecred.
Division:
|Division |Numerator |Denominator |Quotient |Remainder |
|Byte / byte |AL=byte, AH=0 |Register or memory |AL |AH |
|Word / word |AX=word,DX=0 |Register or memory |AX |DX |
|Word / byte |AX=word |Register or memory |AL |AH |
|DW / word |DXAX=DW |Register or memory |AX |DX |
(d) Program to divide two numbers store in registers BL and CL,
Assembly Language Program:
Address Data/Code Mnemonics Comments
-------:0100 MOV BL, 05
-------: MOV CL, 10
-------: MOV AH, 00
-------: MOV AL, CL
-------: DIV BL
Result :____________________________________________________________
Also write the flags affecred.
Laboratory Exercise 4(a)
Objective:
To learn how to implement loop in assembly language.
To learn how a software program affects the hardware signals and their connections.
Theory:
LOOP Command:
The Loop is implemented by using the command “LOOP” followed by the lable of the instruction where to jump to. The maximum number of iterations (repetitions) is defined in the register CX. The LOOP instruction first decrements the value of count defined in register CX and checks the value of CX register. If the CX register contains a non-zero value the loop continues otherwise the loop stops. For example, following code will add 1 in the value contained in register AL for 10 times.
| |MOV CX, 10 |;CX=max. count value i.e.; 10 |
| |MOV AL, 0 |;Initializing AL with zero |
|SUM: |ADD AL, 1 |;Add 1 to AL |
| |LOOP SUM |;DEC CX and JNZ SUM |
| | | |
| | | |
The alternate of the LOOP instruction can be a combination of two commands DEC and JNZ. To demonstrate this the above code can be written as:
| |MOV CX, 10 |;CX=max. count value i.e.; 10 |
| |MOV AL, 0 |;Initializing AL with zero |
|SUM: |ADD AL, 1 |;Add 1 to AL |
| |DEC CX |;CX=CX-1 |
| |JNZ SUM |;If zero flag is not set i.e.; CX != 0 then jump to SUM |
It is also to be noted that the count initialization for the CX value is done outside the loop.
Loops can also be used to insert delays in a Program. In this lab exercise we will require to turn on/off sequentially the LEDs interfaced on the BGC-trainer. To make the sequence visible we need to put a delay in between.
Communicating with the hardware through software:
To communicate with the hardware (Input/Output devices), 8088 microprocessor is provided with the IN and OUT commands. Each I/O device while interfacing to the microprocessor is assigned a port address through which it can access the processor and can be accessed by the processor.
Requirement for IN command:
DX=Port address, AL=value from the port
IN command sequence:
MOV DX, portAddress
IN AL, DX
Requirement for OUT command:
DX=Port address, AL=value to the port
OUT command sequence:
MOV DX, portAddress
MOV AL, value
OUT DX, AL
Description:
• The program controls the input signals SD0, SD1 and SD2.
• When one of these signals is low (L) or logic “0” the corresponding LED is turn ON.
• By adjusting the level of the input signals, the program can turn each LED OFF or ON at any time.
• In this program, the LEDs are turned ON and OFF in sequence to make them blink.
• The frequency of blinking cycle is determined by the contents of the CX register.
• Changing the value in the CX register changes the blinking frequency.
Assembly Language Program:
Address Data/Code Mnemonics Comments
-U0,1b
0100:0000 BA70FF MOV DX,FF70
0100:0003 BOFE MOV AL,FE
0100:0005 EE OUT DX,AL
0100:0006 B9401F MOV CX,1F40
0100:0009 E2FE LOOP 0009
0100:000B B0FD MOV AL,FD
0100:000D EE OUT DX,AL
0100:000E B9401F MOV CX,1F40
0100:0011 E2FE LOOP 0011
0100:0013 B0FB MOV AL,FB
01000015 EE OUT DX,AL
0100:0016 B9401F MOV CX,1F40
0100:0019 E2FE LOOP 0019
0100:001B EBE3 JMP 0000
-g
Laboratory Exercise 4(b)
Objective:
To write a program to turn Speaker ON and OFF and understand how a software program affects the hardware signals and their connections.
Description:
• The program controls the input signal SD3.
• When one of these signals is low (L) or logic “0” the corresponding LED is turn ON.
• By adjusting the level of the input signals, the program can turn Speaker OFF or ON at any
time.
• In this program, the Speaker is turned ON and OFF in sequence to make a sound.
• The frequency of sound is determined by the contents of the CX register.
• Changing the value in the CX register changes the sound frequency.
Assembly Language Program:
Address Data/Code Lables Mnemonics Comments
0100:0000 MOV DX,FF70
0100: Begin: MOV AL,0
0100: OUT DX,AL
0100: MOV CX,1234
0100: Address: LOOP Address
0100: MOV AL,08
0100: OUT DX,AL
0100: OUT DX,AL
0100: JMP Begin
Laboratory Exercise 5 (a)
Objective:
Using MASM/TASM learn how to use different BIOS and DOS Interrupt Services.
Description:
There are some extremely useful subroutines within BIOS and DOS that are available to the user through the INT (Interrupt) instructions. The INT instruction is somewhat like a FAR CALL. When it is invoked, it saves the value of CS:IP for the next instruction to be executed and flags on the stack and load the value of the CS:IP of the ISR (Interrupt Service Routine), associated with the interrupt, from the IVT (Interrupt Vector Table). The INT instruction has the following format
INT xx ;the interrupt number xx can be 00 to FFh
This makes 256 interrupts in 80x86 microprocessors. Of these 256 interrupts, two are widely used namely, INT 21H (DOS) and INT 10H (BIOS). Each of them can perform number of functions. Various functions of INT 21H and INT 10H are selected by the value put in the AH register,
• To display character → function 2 with int 21h
• To display string → function 9 with int 21h
• To clear the screen → function 6 with int 10h
• To set the cursor → function 2 with int 10h
Download the documents regarding int 10h and int 21h from the course website. .
Activity 1:
Write and run an Assembly language program to display “Hello World!”
Activity 2:
Write and run an Assembly language program to clear the screen and then set the cursor at desired location on the screen and display “Hello World!”
Activity 3:
Write and run an Assembly language program to clear the screen and then set the cursor at desired location on the screen and display the table of any number from 2 to 10.
Laboratory Exercise 5 (b)
Objective:
To perform some computation by using Assembly Language Programming.
• To generate Fibonacci series
• To generate BCD count
Description:
• The Fibonacci Series is a sequence of numbers first created by Leonardo Fibonacci (fi-bo-
na-chee) in 1202. It is a deceptively simple series, but its ramifications and applications are nearly limitless. It has fascinated and perplexed mathematicians for over 700 years, and nearly everyone who has worked with it has added a new piece to the Fibonacci puzzle, a new tidbit of information about the series and how it works. Fibonacci mathematics is a constantly expanding branch of number theory, with more and more people being drawn into the complex subtleties of Fibonacci's legacy. (do visit )
The series is like
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393,
• In computing and electronic systems, binary-coded decimal (BCD) is an encoding for
decimal numbers in which each digit is represented by its own binary sequence. Its main virtue is that it allows easy conversion to decimal digits for printing or display and faster decimal calculations. Its drawbacks are the increased complexity of circuits needed to implement mathematical operations and a relatively inefficient encoding – it occupies more space than a pure binary representation. In BCD, a digit is usually represented by four bits which, in general, represent the values/digits/characters 0-9.
Activity 1:
Write and run an Assembly language program to generate the Fibonacci series upto 233.
Activity 2:
Write and run an Assembly language program to generate two digit BCD up/down counts
(00 – 999).
Laboratory Exercise 6 (a)
Objectives:
➢ To examine and use an 8051 assembler.
➢ To examine and use an 8051 simulator.
➢ To examine the flag bits of the PSW.
➢ To examine the stack.
Reference:
➢ Mazidi and McKinlay, “The 8051 Microcontroller and Embedded Systems,” Chapter 2.
Materials:
➢ 8051 assembler and simulator from Franklin Software Inc., Keil Corporation, or the assembler of your choice.
Web Sites:
for Keil Corporation
Activity 1
Write and assemble a program to move value 99H to register A. Then from register A move it to all registers R0 - R7. Use the simulator to single-step the program and examine the registers.
Activity 2
Write and assemble a program to add all the single digits of your ID number and save the result in R2. Pick 7 random numbers (all single digit) if you do not want to use your ID number. Then use the simulator to single-step the program and examine the registers.
Activity 3
Write and assemble a program that Sequentially and repeatedly turn on/off the 8 LEDs from the leftmost LED to the rightmost LED.
Activity 4
Write and assemble a program to add the following data and then use the simulator to examine the CY flag. 92H, 23H, 66H, 87H, F5H
Activity 5
Write and assemble a program to load values into each of registers R0 - R4 and then push each of these registers onto the stack. Single-step the program, and examine the stack and the SP register after the execution of each instruction.
Activity 6
Write and assemble a program to:
(a) Set SP = 0D,
(b) Put a different value in each of RAM locations 0D, 0C, 0B, 0A, 09, and 08,
(c) POP each stack location into registers R0 - R4.
Use the simulator to single-step and examine the registers, the stack, and the stack pointer.
Laboratory Exercise 6(a)
Worksheet
1. Indicate the size (8- or 16-bit) of each of the following registers.
PC = A= B=
R0= R1= R2= R7=
2. For Question 1, indicate the largest value (in decimal) that each register can contain.
PC = A= B=
R0= R1= R2= R7=
3. For Question 1, indicate the largest value (in hex) that each register can contain.
PC = A= B=
R0= R1= R2= R7=
4. Who generates each of the following files and what is the use of each.
.asm
.lst
.obj
.abs
.hex
5. Find the value of the CY flag after the execution of the following code.
(a) MOV A,#85H
ADD A,#92H
(b) MOV A,#15H
ADD A,#72H
(c) MOV A,#0F5H
ADD A,#52H
(d) MOV A,#0FF
INC A
6. Upon reset, what is the value in the SP register?
7. Upon pushing data onto the stack, the SP register is _____________ (decremented,
incremented).
8. Upon popping data from the stack, the SP register is ___________ (decremented,
incremented).
9. Can you change the value of the SP register? If yes, explain why you would want
to do that.
10. The stack uses the same area of RAM as bank ______.
Laboratory Exercise 6 (b)
Objectives:
➢ Introduction to MTS-51 Microcontroller Trainer.
➢ This experiment demonstrates that I/O port 2 controls LED pack D5 on the MTS-51 Trainer. When P2 bit is 1, the corresponding LED is turned ON. When P2 bit is 0, the corresponding LED is turned OFF. Place the SW2-4 in ON position.
Materials:
➢ 8051 assembler and simulator.
➢ MTS-51 Trainer
Activity 1
Sequentially and repeatedly turn on/off the 8 LEDs from the leftmost LED to the rightmost LED. The on time of each LED is 0.1 seconds.
Activity 2
Sequentially and repeatedly turn on/off the 8 LEDs from the leftmost LED to the rightmost LED. When the rightmost LED is reached, the sequence is inverted. The on time of each LED is 0.1 seconds.
Activity 3
Sequentially turn on/off two LEDs from the two ends towards the middle. When the middle reached, the sequence is inverted. The ON time of each LED is 1 second.
Activity 4
Turn on LEDs according to the following cases and repeat each case 8 times.
Case 1: Turn on LEDs from left to right.
Case 2: Turn on LEDs from right to left.
Case 3: Blink two sets (left and right sides) of LEDs alternately.
Case 4: Blink all of 8 LEDs.
Laboratory Exercise 7 (a)
Objectives:
➢ This experiment uses the two-digit 7-segment display (DS3-DS4) of MTS-51 Trainer to show decimal numbers.
Materials:
➢ 8051 assembler and simulator.
➢ MTS-51 Trainer
Activity 1 (Two-Digit Up Counter)
Sequentially and repeatedly show the numbers 00 through 99 on DS3 and DS4. Each number stays on 0.5 seconds.
Activity 2 (Two-Digit Down Counter)
Sequentially and repeatedly show the numbers 99 through 00 on DS3 and DS4. Each number stays on 0.5 seconds.
Activity 3
Sequentially show the numbers from 00 to 99 and then from 99 to 00 on DS3 and DS4, and repeat the sequence. Each number stays on 0.7 seconds.
Activity 4
Sequentially show the numbers from 00 to 99 on DS3 (ten digit) and DS4 (Units digit) using table look up. Each number stays on 0.3 seconds.
Laboratory Exercise 7 (b)
Objectives:
➢ To demonstrate the on-board Speaker control with the microcontroller on the MTS-51 Trainer.
Materials:
➢ 8051 assembler and simulator.
➢ MTS-51 Trainer
Hardware Description:
➢ The signal to the speaker driver input comes from P3.7 pin. When a HIGH is fed to it the speaker turns ON. When a LOW is fed the speaker is turned OFF.
Activity 1 (Speaker control)
Generate a 1-KHz tone for the Speaker interface on the MTS-51 trainer.
Activity 2
Speaker sounds a 1 KHz tone for 0.5 seconds and then keeps silence 0.5 seconds.
Laboratory Exercise 8
OBJECTIVES:
➢ This experiment uses 8x8 dot matrix LED (D3) to display decimal numbers.
HARDWARE DESCRIPTION:
➢ The D3 is a common cathode matrix LED. The row scan signal is emitted from P2 and the column scan signal is emitted from P0. Both row and column scan signal are active-high signals, that is, all LEDs are turned on when the row and column signals are all 1s. The 2803 Darlington pairs are used to sink column currents.
MATERIALS:
➢ 8051 assembler and simulator.
➢ MTS-51 Trainer
ACTIVITY 1 (Basic Matrix LED Control)
Sequentially turn on the column LEDs from column 1 to column 8 eight times, and then turn on the row LEDs from row 1 to row 8 eight times.
ACTIVITY 2 (Static Character Display-1)
Show a 5x7 letter “A” on dot matrix LED.
ACTIVITY 3 (Static Character Display-1)
Sequentially show 5x7-dot characters A through Z and numbers 0 through 9.
ACTIVITY 4 (Dynamic Character Display)
Sequentially show 5x7-dot characters A through Z and numbers 0 through 9, and move it from the left to right.
Laboratory Exercise 9
OBJECTIVES:
➢ To learn Step Motor interfacing and to control the on-board 4-phase step motor M1 on MTS-51 Trainer.
Hardware Description:
➢ The motor coils A, B, A’, B’ are energized by the signals on P2.3, P2.2, P2.1, P2.0, respectively. Place switch SW2_8 in ON position. There are three switching schemes: 1-phase-on, 2-phase-on and 1-2-phase-on switching.
MATERIALS:
➢ 8051 assembler and simulator.
➢ MTS-51 Trainer
ACTIVITY 1 (Direction Control)
Drive the Step-motor to rotate in Clock-Wise (CW) direction using 2-phase-on switching.
ACTIVITY 2 (Revolution Control)
Drive the Step-motor to rotate one revolution CW and then rotate one revolution CCW, continuously.
ACTIVITY 3 (Speed Control)
Drive the Step-motor to rotate one revolution CCW and then rotate two revolutions CW but with double the CW revolution speed, continuously.
Laboratory Exercise 10
OBJECTIVES:
➢ This experiment demonstrates the matrix keyboard control.
➢ Using the matrix keyboard control to the 4-phase step motor M1 on MTS-51 Trainer.
Hardware Description:
➢ The matrix keyboard KB1 and ecoder 74C922 builds the keyboard circuit. If a key is pressed , the corresponding binary value will present on the outputs DOD-DOA (P1.3 – P1.0) of the encoder, as well as Data Available (DA) signal on the DA output. The DA signal is inverted by an inverter and then connected to P3.2 (INT0) pin.
MATERIALS:
➢ 8051 assembler and simulator.
➢ MTS-51 Trainer
ACTIVITY 1 (Keyboard Controls 7-Segment)
1. Show the key number on the 7-segment display DS4 when a key is pressed.
2. Place SW2-3 in ON position.
ACTIVITY 2 (Keyboard Controls LED)
Using the following keys on matrix keyboard, control the state of LEDs:
a) Key “0” pressed, all the 8 LEDs light up simultaneously.
b) Key “1” pressed, all the 8 LEDs blink.
c) Key “2” pressed, two sets (left and right sides) of LEDs blink alternately.
ACTIVITY 3 (Step Motor Direction Control)
1. Key “1” pressed, the step motor rotates one step CW.
2. Key “2” pressed, the step motor rotates two step CCW.
ACTIVITY 4 (Step Motor Revolution Control)
The step motor rotates CW the same number of revolutions as the key pressed (0-9)
Laboratory Exercise 11
OBJECTIVES:
➢ This experiment demonstrates the application of LCD module (LCM). LCMs are widely used to display alphanumeric characters. The LCM on MTS-51 Trainer is a 20 characters x 2 lines back-light LCM.
Hardware Description:
➢ SW2-5 should be placed in ON position. P0 lines are connected to the data bus DB0-DB7 of LCM. P1.5, P1.6, and P1.7 are connected to RS, R/W, and E pins, respectively.
MATERIALS:
➢ 8051 assembler and simulator.
➢ MTS-51 Trainer
ACTIVITY 1 (LCM Character Display-1)
Show the character string “Hello ! Welcome” in the middle of the first line of LCM.
ACTIVITY 2 (LCM Character Display-2)
Show the character string “Sir Syed University” in the middle of the first line of LCM and blink it every 0.5 second interval.
ACTIVITY 3 (LCM Character Display-3)
Show the character string “Hello ! Welcome” on the right side of the first line of LCM and slowly move to the middle position, and blink it.
ACTIVITY 4 (LCM Character Display-4)
Show the key value on the LCM screen and blink the cursor.
ACTIVITY 5 (LCM Character Display-5)
Design a 4-digit counter which automatically increments its value every second, and shows the result in the middle of the first line of LCM screen.
ACTIVITY 6 (6-Digit Electronic Stopwatch)
Design a stopwatch in the middle of LCM screen in 00:00:00 (minutes:seconds:1/60 seconds) format. The stopwatch has a resolution of 0.01 seconds. When the key “1” is pressed, the watch starts or resumes counting. When the key “2” is pressed, pause counting. When the key “2” is pressed, the watch is reset.
Laboratory Exercise 12
OBJECTIVES:
➢ This experiment demonstrates the application of Pulse Counter.
Hardware Description:
➢ This experiment demonstrates the design of a basic pulse counter which counts the input from either photo-interrupter output or pulse generator. The result is displayed on the 7-Segment display. The output of the 555 oscillator is connected to the T0 (P3.4) pin. The frequency is changed by adjusting the SVR1. However while using the Photo-interrupter PH1, output is detected on T1(P3.5).
MATERIALS:
➢ 8051 assembler and simulator.
➢ MTS-51 Trainer
ACTIVITY
Program for the following sequence:
1. Count the number of pulses from the 555 oscillator output and show the result on 7-Segment display DS3 and DS4.
[Connect pins 2 and 3 of JP4 together using a jumper cap]
2. Count the number of pulses from the Photo-interrupter PH1 output and show the result on 7-Segment display DS3 and DS4.
[Connect pins 1(T1) and 2(PH1) of JP3 using a jumper cap]
3. Increment the Count value every Photo-interrupter PH2 output pulse and decrement the Count value every Photo-interrupter PH1 output pulse, and show the result on 7-Segment display DS3 and DS4.
[Connect pins 3(INT1) and 2(PH1) of JP3, and connect pins 1(PH2) and 2(T0) of JP4 using jumper caps]
Laboratory Exercise 13
OBJECTIVES:
➢ To learn on-chip Timer/ counter control and their operation in Modes 0 and 1.
Hardware Description:
➢ Mode 0: 13-bit timer
➢ Mode 1: 16-bit timer/ counter
➢ SW2-4 should be placed in ON position.
MATERIALS:
➢ 8051 assembler and simulator.
➢ MTS-51 Trainer
ACTIVITY 1 (Timer/counter Mode-0)
Program timer/counter 0 operating in mode 0 and blink LEDs (D5) alternately. The ON/OFF time is 1 second.
ACTIVITY 2 (Timer/counter Mode-1)
Program timer/counter 0 operating in mode 1 and sequentially turn on/off LEDs from leftmost to the rightmost. The ON/OFF time is 0.5 seconds each.
Laboratory Exercise 14
OBJECTIVES:
➢ This experiment demonstrates the Serial Communication using on-chip serial port Mode 1.
Hardware Description:
➢ If two MTS-51 trainers are used, the JP2s on MTS-trainers should be interconnected such that TXD of one is connected to the RXD of other, with a common Ground for both.
➢
MATERIALS:
➢ 8051 assembler and simulator.
➢ MTS-51 Trainer
ACTIVITY (UART in Mode-1)
When a key is pressed on one MTS-51 trainer, the key is displayed on the 7-segment of the other MTS-51 trainer.
-----------------------
Note:
• Hexadecimal numerical system is used throughout the experiments (unless otherwise specified).
• The suffix ‘H’ can be omitted.
NOTE: and may be overlapped.
However, overlapping will destroy the original memory contents
NOTE:
• DEBUG is 鰻鰼鱇鱈鳊鳋鳖鳗鷄鷅鷐鷑鷲鸄鹓麇麈黦黧黨黩黪黫黬黭èÞÕÕ픀ÕÐ퀀Ð퀀Ð퀀Õ픀Õ픀Õ픀Õ픀Ѐ摧⯉[pic] ̤̀愁̤摧⯉[pic]Ѐ摧⯉[pic]Ѐ摧⯉[pic]ᘀ␃༃炄not case-sensitive.
• It is assumed in the above instruction that DEBUG program is on the drive C
• After enter key pressed, the DEBUG prompt “-“ will appear on the following line.
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
Related searches
- introduction to financial management pdf
- introduction to finance
- introduction to philosophy textbook
- introduction to philosophy pdf download
- introduction to philosophy ebook
- introduction to marketing student notes
- introduction to marketing notes
- introduction to information systems pdf
- introduction to business finance pdf
- introduction to finance 15th edition
- introduction to finance books
- introduction to finance online course