Completely Solved C, C++ Programs Assignment.




Showing posts with label Microprocessor. Show all posts
Showing posts with label Microprocessor. Show all posts

The SBS-1 System-Operating Instructions

Filed Under:

Operating Instructions: 
What It Does
The things we can do with the basic SBS-1 kit are:
• Examine the contents of all memory and register locations.
• Deposit program steps or data in RAM or register locations.
 • Execute programs or subroutines upon command.
• Reset (start) the monitor upon command.
• Interrupt and start operation at a location we specify upon command.

  We may select either the keyboard and display on the board or a CRT terminal as the console device (optional interface) by operating a switch. Keyboard/display operation and CRT terminal operation are described separately in the following paragraphs. 
  Two of the keyboard buttons continue to function in CRT terminal mode as well as keyboard/display mode. These are the RESET and the VECT INTR keys. 

  The Buttons and Displays: 
 Keyboard/display operation is done by pressing keys on the keyboard. Responses are displayed either by echoing the key pressed or by prompting us with a message or prompt. When the RESET button is pressed the monitor is ready to accept commands. For numeric arguments the valid range is from 1 to 4 hexadecimal digits for address information and 1 to 2 hexadecimal digits for register and memory data information. Longer numbers may be entered bur in each case only the last four of the last two digits entered will be accepted. 

 Whenever the monitor expects a command the display shows the prompt “1” at the left edge of the address field (possibly along with an error message). When the monitor expects a parameter, a decimal point will be displayed at the right edge of the field into which the argument will be placed. A parameter will be either an address or a byte of data, which is used during the execution of a command. In the description of the command modes, upper case letters enclosed in () are the command keys. 

  RESET 
 The RESET key causes a hardware reset and starts the monitor again. The message “SBS1” will be displayed across the address and data field of the display if we are in the display-keyboard mode. If we are in CRT terminal mode the sign on message: SBS-8085 VER 1” will be displayed. The monitor is ready to accept a command after a reset and saves no information about the state of any user program before the reset. 

 Substitute Memory (SUBST MEM) 
 (SUBST MEM) address (NEXT) data (NEXT) data…(NEXT) data (EXEC). 
The substitute memory command allows us read the contents of ROM memory and to examine and modify the contents of ROM memory locations. 

The address argument denotes the contents of the memory address to be examined and may be from 1 to 4 hex digits. If we enter longer numbers only the last 4 digits entered are used. As soon as the number is terminated by a next key the content of the location is shown is the data field, along with a decimal point at the right edge of the field. Entering a new number will cause that number to be displayed in the data field. However the contents of the memory location will not be changed until an (EXEC) or (NEXT) key is pressed. 

Pressing (NEXT) will place the contents displayed in the data field into the displayed memory address. Then the address and contents of the next higher memory location will automatically be shown. Pressing (EXEC) will place the contents of the contents displayed in the data field into memory address displayed in the address field and will also terminate the command. Pressing (NEXT) while the address FFFF is being displayed will cause address 0000 to be displayed. 

Whenever the command changes the contents of a memory location, it also verifies whether the change has occurred correctly. If the contents of the location do not agree with the new value (i.e. if the memory location is in ROM or is non-existent) an error message is displayed. 

  Examine Registers (EXAM REG) 
 (EXAM REG) reg name (NEXT) data (NEXT) data…(EXEC). The examine command allows us to display and modify the contents of the 8085 CPU registers. Pressing the EXAM REG key blanks both the address and data fields, and displays decimal point at the right edge of the address field. At this point we must press a register key (register names are denoted by legends on the keyboard). Any other key will display an error message. If a register key is pressed the name of the register will appear in the address field and the contents of the register will be displayed in the data field along with a decimal point at the right hand edge. Entering a number will cause the number to be displayed in the data field, however the contents of the register will not be changed until an EXEC or NEXT key is pressed. 

Pressing NEXT will place the contents displayed in the data field into the register named in the address field, then will display the name and contents of the next register in sequence. Pressing EXEC will place the contents displayed in the data field in the register named in the address field, and will also terminate the command. Pressing NEXT while register PCL is being displayed has the same effect as pressing EXEC. The format of the 1 register in the lower 4 bits of the accumulator following execution of a RIM instruction. A “1” in an interrupt mask field denotes a masked condition. A “0” must be entered to use the interrupt. The format for the1 register is: 
                                  B7       B6       B5       B4          B3        B2        B1       B0
                                  0          0          0          0           1E        M7.5    M6.5    M5.5
           
            M         Interrupt Mask
            1E        Interrupt Enable Flag

  Register Display Sequence 

Key/Display Code      Register
I                                   Interrupt mask
H                                 CPU register H
L                                  CPU register L
SPH                             Most significant byte of stack pointer
SPL                             Least significant byte of stack pointer
PCH                            Most significant byte of program counter
PCL                             Least significant byte of stack pointer

The format for flag byte is:

            B7       B6       B5       B4       B3       B2       B1       B0
            S          Z          X         AC      X         P          X         C
S-Sign
Z-Zero
AC-Aux. Carry
P-Parity
C-Carry
X-Undefined
GO:
            (GO) Address (EXEC)

 Pressing the GO key causes the content of the program counter (PCH and PCL) to be displayed in the address field, along with a decimal point at the right edge of the field. The program counter is available for change and any number entered (a number is optional) becomes the new contents of the program counter. 

 Pressing the EXEC key transfers control of the CPU to the address in the address field (contents of the program counter). Before the transfer of control, the address and data display fields are cleared, and an ‘E’ is displayed at the left edge of the address field. Pressing any other key but EXEC generates an error message. The monitor again regains control of the CPU only after a RESET or after execution of an RST0, RST2 or JMP 0000 instruction. 

VECT INTR (Vector Interrupt) 
 1. The VECT INTR key is similar to the GO key in the respect that it takes control away from the monitor and gives it to another program. The interrupt key causes immediate recognition of RST 7.5 interrupt and control passes to location 003CH in the monitor. This location contains an unconditional branch to instruction location 20CEH in user RAM. We may place an instruction we wish in location 20CE thru 20D) (e.g. branch to a keyboard interrupt routine). The monitor does not regain control without specific action (a RESET, or a RST), RST1, or JMP 0 program instruction). In branching back to the monitor, unless the RST1 instruction is executed, the monitor loses all past information of user program. Since an interrupt is recognized by the hardware, the monitor cannot clear the display; thus the display may remain unchanged after interrupt. 

 Two conditions must be satisfied for the Vector Interrupt feature to be enabled. 
1. Interrupts must be enabled (by executing an E1 instruction) 
2. RST 7.5 must be unmasked (mask reset by the SIM instruction or by modifying the I-register). 

BRP (Break Point) 
 This key (BREAK POINT) is used for program debugging. Using this key, we can execute our program part by part and examine the register contents and memory location in between. As soon as we press BRP key, SA (starting address) will be displayed on the data field. We enter the staring address of our program and press EXEC key. Now EA (End Address) will be displayed in the data field. We enter the address up to which we want to execute our program and press EXEC key. The execution will be done up to the end address and now we can examine the register contents and memory locations. If there be any bug in our program the CPU will be in an infinite loop and to come out of the loop we will have to press VECT INTR button. (If we do not want to use BRP key, we can break our program by placing RST1 instructions at selected RAM locations where we want to examine the CPU status.) 

Error Conditions: Illegal Key 
 If a key is pressed which is illegal in its contest (e.g. a command key is pressed when monitor is expecting the number) the command is aborted and an error is displayed. The monitor is then again ready to accept a new command. The error message “Err” is cleared when a new command key pressed, thus we can cancel a command before we press NEXT or EXEC by pressing any illegal key. 

  Memory Substitution Key
 If the substitute memory commands determine that the contents of a memory location were not changed correctly (i.e. location is in ROM or non-existent) the command is aborted and an error message is displayed. The monitor is again ready to accept another command.


Back to main directory:  Microprocessor    Hardware Practical



The SBS-1 System-The Software

Filed Under:

The Software: 
 The SBS-1 monitor program provides utility functions employing the kit’s onboard keyboard as console. The program resides in 2K bytes of the ROM memory, between location 000H and 07FFH. The 8085 makes use of a 16bit internal register called the stack pointer to point to an area of memory called the stack. The 8085’s stack is used for saving many things, such as memory addresses for returns from subroutines. It is important always to define the stack pointer at the beginning of one’s program to avoid storing data in the wrong place. Locations 20C0H through 20D0H in RAM are reserved by the monitor for jump instructions when all interrupts are used. Thus, one should set the stack pointer initially at 20C2H by the use of the program instruction LXI SP, 20C2H, in order to keep his own stack clear of data and programs he wants to protect. If less than the full complement of interrupts is utilized some or all of the unused space above 20C2H can be allocated to stack as described above. The stack must still occupy an unbroken string of contiguous memory locations. There is provision for on board 4K bytes of static RAM from 2000H to 37FFH. The user can use this RAM space except the locations from 20C0H to 20FFH which is kept for monitor use. One may borrow several of the SBS-1 monitor routines to simplify his programming task. Following discussion provides descriptions and calling addresses for some of the available routines. 

 Monitor Subroutines that can be used by the user: Update Address (Calling address 0363H) This routine updates address field of the display. The contents of the D-E register pair are displayed in the address field of the display. The contents of all the CPU registers and flags are affected. 

 Update Data (Calling Address 036EH) This routine updates data field of the display. The contents of the A register are displayed in Hex notation in the data field of the display. The contents of all the CPU registers and flags are affected. 

 Time Delay (Calling address 05F1H) This routine takes the 16-bit content of D-E register pair and counts down to zero, then returns to the calling program. The contents of A, D and E registers and flags are affected. 

 Output Characters to Display (Calling Address 02B7H) 
This routine sends characters to the display with the parameters set up by registers A, B, H and L.

Register A                   0  use address field
                                     1  use data field
Register B                   0  decimal point off
                                     1  decimal point at right edge of field
Register H & L       starting address of character to be sent.

The following table shows the characters that can be displayed and their corresponding hexadecimal codes.

Character Displayed
Hexadecimal memory content pointed to by H-L register pair
0
00
1
01
2
02
3
03
4
04
5
05
6
06
7
07
8
08
9
09
A
0A
B
0B
C
0C
D
0D
E
0E
F
0F
H
10
L
11
P
12
I
13
R
14
S
05
Blank
15



Back to main directory:  Microprocessor    Hardware Practical



The SBS-1 System-Peripheral Interfaces

Filed Under:

Peripheral Interfaces: 

Programmable Peripheral Interfaces (8255) 
It is a general-purpose programmable I/O device with 24 pins. There are two 8255 on the board, so we can have 48 I/O parallel lines. These I/O lines are extended to two 40-pin connectors. 



Programmable Interval Timer (8253) 
It is a programmable counter/timer integrated circuit with 3 independent 16-bit counters, each separately can be programmed in any of five different modes. 



Programmable Communication Interface (8251) 
It is designed for programmable serial synchronous/asynchronous data communication. It accepts dada characters from the CPU in parallel format and then converts them into a continuous serial data stream for transmission. Simultaneously it can receive serial data stream and convert them into parallel data character for the CPU. The asynchronous baud rate required for this may be programmed in 8253 and the clock output from 8253 may be connected to TxC & RxC of 8251. System clock may also be used. 



Programmable Interrupt Controller (8259)
It handles up to eight vectored priority interrupts for CPU. It has several programmable modes permitting optimization for a variety of system requirements. The priority modes can be changed or reconfigured dynamically at any time during the main program. Each of the eight-interrupt requests is connected to the outputs of two TTL inverters (7400) and the corresponding inverter inputs are connected with eight PTH terminals. 



Programmable Keyboard/Display Interface (8279) 
It is a keyboard and display controller integrated circuit that handles the interface between 8085 and the keypad and LED display on the board. The 8279 refreshes the display from an internal memory while scanning the keyboard to detect any key pressing. The interrupt request output is connected to RST 5.5 of 8085. 



Eight Channel Analog to Digital Converter (ADC0809) 
It is 8-bit monolithic A/D converter and the conversion is done using successive approximation technique. It has eight channels for connecting eight different analog signals and they can be sampled regularly in time-multiplexed fashion. Its maximum frequency is 800 KHz. 

 Serial Data Interface Through SID/SOD of 8085
SID and SOD pins are available for computing VDU or TTY. Extra interface for 20mA current loop or RS232C is required.


Back to main directory:  Microprocessor    Hardware Practical



The SBS-1 System-Hardware

Filed Under:

System Overview
The Hardware:
CPU and Bus Structure The system is based on Intel 8085 microprocessor as its CPU. The lower byte of address is separated out from multiplexed data/address bus (AD0-AD7) by latching the lower byte of address in 8212 using the ALE signal from 8085. The upper byte of address is buffered by 74367. The output from 8212 and 74367 together constitutes the local address bus. The data from AD0-AD7 is buffered by two bi-directional bus drivers 8216. The output from two 8216 constitutes the local data bus the direction of the data bus is controlled by using the signals RD and INTA from the microprocessor when either of the signals is present, the local data bus will be pointing in i.e. towards the microprocessor is said to be in input mode.

  Reset On the board itself there is provision for power on auto reset. Reset button is also provided for manual reset. The RESET OUT signal from the microprocessor is buffered by 74367 and fed to various other integrated circuits on the board.

  Decoder The chip select signals for the ROM, RAM and other peripheral integrated circuits are derived by decoding the address bits A15 through A11 using 4 to 16 line decoder 74154. When address bit A15 is low the decoder 74154 is enabled and depending on the bit configuration of address bits A11, A12, A13 and A14 different devices are selected as follows…

A14
A13
A12
A11
Device Selected
0
0
0
0
EPROM1 (0000H-07FFH)
0
0
0
1
EPROM2 (0800H-0FFFH)
0
0
1
0
EPROM3 (1000H-17FFH)
0
0
1
1
Keyboard/Display controller (8279)
0
1
0
0
RAM1 (2000H-27FFH)
0
1
0
1
RAM2 (2800H-2FFFH)
0
1
1
0
RAM3 (3000H-37FFH)
0
1
1
1
Floating (may be used for any expansion)
1
0
0
0
Floating (may be used for any expansion)
1
0
0
1
Floating (may be used for any expansion)
1
0
1
0
Analog to digital converter (ADC0809)
1
0
1
1
Programmable interval timer (8253)
1
1
0
0
Programmable interrupt controller (8259)
1
1
0
1
UART (8251)
1
1
1
0
Programmable peripheral interface (right 8255)
1
1
1
1
Programmable peripheral interface (left 8255)


The processor board can support 6K bytes of Ram starting from location 2000H to 37FFH. Location starting from 20C0H to 20FFH is used by monitor programs. So the user should not use these RAM locations for their programs.


Restart Interrupts
  • RST 5.5 Dedicated to Keyboard/Display Interface (8279). 
  • RST 6.5 Available user interrupt. It is connected to the output pin 6 of TTL inverter 7400 (beside keypad). The user may apply interrupt request at the input of the inverter. The user should put JMP instructions and starting address of ISR routine from RAM location 20C8H. 
  • RST 7.5‘VECT INTR’ keyboard button interrupt. The user should put JMP instruction and starting address of RST 7.5 ISR routine from RAM location 20CEH. 
  • TRAPAvailable user interrupt. It is connected to the output pin 12 of TTL inverter 7400 (beside keyboard). The user may apply interrupt request at the input of the inverter. The user should put JMP instruction and starting address of TRAP routine from RAM location 20C0H. 
  • INTRConnected to the Programmable Interrupt Controller 8279



Back to main directory:  Microprocessor    Hardware Practical



The SBS-1 System Description

Filed Under:

The SBS-1 System Description: 
The SBS-1 is single board microcomputer to provide economical, self-contained computer-based solution for different applications like microcomputer-based experiments, computations and real-time process control. The central processing unit, system clock, read/write memory, parallel input/output port, universal serial asynchronous transmitter receiver, priority interrupt logic, programmable timers and multi-channel analog to digital converter all reside on a single board.

 Features: 
• High performance 8085 CPU with 6.144 MHz Crystal. 
• 2K powerful firmware in 2716. 
• 6K bytes of read/write memory using 6116. 
• 6K bytes of read only memory using 2716. 
• 48 programmable parallel input/output lines using 8255. 
• Programmable synchronous/asynchronous serial interface with software selectable baud rate using 8251 (for RS232C, TTY-20mA current loop, cassette interface etc.) 
• Serial communication with SID/SOD ports of 8085. 
• Three programmable 16-bit BCD/Binary timers or event counters using 8253. 
• 12 levels of programmable interrupt control using 8259 and hardware vectored interrupt pins of 8085. 
• 8-channel 8-bit analog to digital converter using ADC0809. 
• Fully buffered STD bus for easy expansion. 
• Highly reliable 24 keys and 6-digit 7-segment LED display. 
• Monitor has basic software to aid the user to load, verify, execute and debug his program. 

 Operational Supports: 
 • TTY interface using 0-20mA current loop. 
• Keyboard and CRT terminal interface using 1488 and 1489 (RS232C). 
• EPROM programmer for 2716, 2732 or any other ROM on order. 
• Special utility software on requirement. 

 Electrical Characteristics: DC regulated power supply +5Volt ±5% 2.0 Amp. 

 Environmental: Operating temperature 0º to 55 ºC.


Back to main directory:  Microprocessor    Hardware Practical



Microprocessor-registers

Filed Under:

  The 8085 has six general-purpose registers, namely, B,C,D,E,H, and L. They can be combined as register pairs- BC, DE, and HL – to perform some 16-bit operations.


  These registers are programmable, meaning that a programmer can use them to load or copy data from the registers by using instructions. For example, the instruction MOV B, C copies the data from register C to register B. Conceptually, the registers can be viewed as memory locations, except they are built inside the microprocessor and identified by specific letters for user convenience.

   ACCUMULATOR:  The accumulator is an 8-bit register that is part of the arithmetic/ logic unlit (ALU). This register is used to store 8-bit data and to perform arithmetic and logical operations. The result of an operation is stored in the accumulator. The accumulator is also identified as register A.

   FLAGS: The ALU includes five flip- flops that are set or reset according to the result of an operation. The microprocessor uses them o perform the third operation; namely, testing for data conditions.



 S-Sign Flag: After the execution of an arithmetic or logic operation, if bit D7 of the result (usually in the accumulator) is 1, the Sign Flag is set. The flag is used with sign numbers. In a given byte, D7 is 1, the number will be viewed as a negative number; if it is 0, the number will be considered positive. In arithmetic operations with signed numbers, bit D7 is reserved for indicating the sign, and the remaining seven bits are used to represent the magnitude of a number.
  Z-Zero Flag: The Zero flag is set if the ALU operation results in 0,and the flag is reset if the result is not 0. This flag is modified by the results in the accumulator as well as in the other registers.
 AC-Auxiliary Carry flag: In an arithmetic operation, when a carry is generated by digit D3 and passed on to digit D4, the AC flag is set. The flag is used only internally for BCD (binary-coded decimal) operations and is not available for the programmer to change the sequence of a program with a jump instruction.
 P-Parity Flag: After an arithmetic or logical operation, if the result has an even number of 1s, the flag is set. If it has odd number of 1s, the flag is reset.
  
 CY-Carry Flag: If an arithmetic operation results in a carry, the Carry flag is set; otherwise it is reset. The Carry flag also serves as a borrow flag for subtraction.
    The bit positions reserved for these flags in the flag register are as follows:-


   PROGRAM COUNTER (PC) 

  The 16-bit register deals with the fourth operation, sequencing the execution of instructions. This register is a memory pointer. Memory locations have 16-bit addresses, and that is why this is a 16-bit register.

  The microprocessor uses this register to sequence the execution of instructions. The function of the program counter is to point to the memory address from which the next byte is to be fetched. When a byte (machine code) is being fetched, the program counter is incremented by 1 point to the next memory location.

  STACK POINTER (SP)

   The stack pointer is also a 16-bit register used as a memory pointer, initially; it will be called a stack pointer register to emphasis that it is a register. It points to a memory location in R/W memory, called the stack. The beginning of the stack is defined by loading a 16-bit address in the stack pointer (register).

  The 8085 instruction set is a huge one and needs to be classified into the following groups:
  • Data transfer operations. 
  • Arithmetic operations. 
  • Logical operations. 
  • Branching operations and 
  • I/O and Machine-control operations. 
  Programs are written based on these instructions which the MPU interprets. Each instruction has a specific hexadecimal 8-bit code. Some instructions do not need operands. Some give immediate operands and on the other hand some instructions tell the MPU to fetch the operand from a specific memory location. Accordingly these instructions are classified into 1-byte, 2-byte and 3-byte instructions. Some of the instructions are:

1-byte instruction: 
  • MOV A, B
  • ADD C
  • CMA
2-byte instruction:
  • MVI A, 32H
3-byte instruction: 
  • LDA F01AH
  • JMP 5A4EH

Back to main directory:  Microprocessor    Hardware Practical