Google

Feb 27, 2008

Assembly Language Source Codes

Here is the list of programs in assembly language with complete source code is provided

Assembler Source Code for emu8086 microprocessor emulator and compatible assemblers (16 bit) simply copy these codes and past them on your editor

http://www.emu8086.com/dr/asm2html/assembler_source_code/

it contains list of programs like
  • Input 8 bit binary number and print out its decimal equivalent.
  • This is a very basic example of a tiny OS. Your own Operating System that runs from floppy drive - easy!
  • This example shows how to add huge unpacked BCD numbers
  • Calculate the sum of elements in V1 array, store result in V2.
  • How CMP instruction sets the flags.
  • See how to operate with Octal, Binary and Decimal values.
  • Learn how to set and get file attributes, in other words how to make file Read Only or Hidden.
  • This is an example of AAS instruction, it is used to subtract huge BCD numbers.
  • This sample gets two numbers from the user, calculates the sum of these numbers, and prints it out.
  • This sample shows how to use CMPSW instruction to compare strings.
  • Make your own interrupts - Custom_Interrupt.asm
  • Encryption in Assembly Language
  • This sample gets the number from the user, and calculates factorial for it. Supported input from 0 to 8 inclusive!
  • Call a procedure from another segment or interrupt.
  • This program calculates linear equation: ax + b = 0 The result is printed with floating point.
  • This example prints out The easiest and the fastest way to print "Hello World!" using DOS INT 21h (still works under Windows XP in Dos prompt).
  • This example converts 2 digit Hex value into numeric value and decimal string representation (so that it can be easily printed if required).
  • Keyboard example - keybrd.asm
  • A very handy code that can be assembled into a very tiny utility to make floppy boot records and tiny operating systems.
  • This sample shows the use of input and output string functions of emu8086.inc
  • This sample shows how to use SCASW instruction to find a WORD (2 bytes).
You might be also interested in:
:: Temperature Control system using 8086
:: Traffic light control system using 8086
:: Assembly Language Program to serve NMI

Feb 19, 2008

Assembly Language Program to be executed when NMI is generated

Assembly Language Program to be executed when NMI is generated

AIM:To write Assembly Language Program to be executed when NMI is generated

APPARATUS:-
Microprocessor trainer kit & power supply.

NON MASKABLE INTERRUPT (NMI)

NMI is an edge triggered input pin which causes Type-2 interrupt. The NMI is not mask able internally by software. A transition from low to high initiates the interrupt response at the end of the current instruction. This input is internally synchronized.
When an external device interrupts the CPU at the interrupt pin NMI and the CPU is executing an instruction of a program. The CPU first completes the execution of current instruction. The IP is then incremented by one to point next instruction. The CPU then acknowledges the requesting device on its INTA pin immediately for NMI. After an interrupt is acknowledged, the CPU computes the vector address from the type of the interrupt that may be passed to interrupt structure of the CPU internally or externally (for NMI vector address is 00008 H). The contents of PSW, CS & IP are next pushed on stack. The contents of IP & CS now points to the address of the next instruction in main program from which the execution is to be continued after executing the ISR. The control is then transferred to Interrupt Service Routine for serving the interrupting device. The new address is found out from the interrupt vector table (for NMI [00009:00008] = ISR IP & [0000B:0000A] = ISR CS. The execution of ISR starts. At the end of ISR the last instruction should be IRET. When CPU executes IRET instruction the IP, CS & PSW is popped back from the stack and the execution continued from address received by IP & CS.

WRITE THIS PROGRAM AT 0000:4000 H MEMORY LOCATION AND EXECUTE IT
0000:4000 MOV AX,0FFFFH 
0000:4003 MOV BX,0FFFFH 
0000:4006 ADD AX,BX 
0000:4008 HLT 
0000:4009 
WRITE THIS PROGRAM AT 0000:4100 H MEMORY LOCATION AND EXECUTE IT

0000:4100 MOV AX,0000H 
0000:4103 MOV DS,AX 
0000:4105 MOV AL,00H 
0000:4107 MOV [0008],AL 
0000:410A MOV AL,40H 
0000:410C MOV [0009],AL 
0000:410F MOV AL,00H 
0000:4111 MOV [000A],AL 
0000:4114 MOV AL,00H 
0000:4116 MOV [000B],AL 
0000:4119 HLT 
0000:411A  

NOW PRESS NMI BUTTON ON 8086 MICROPROCESSOR KIT

You might be also interested in:

:: MASM 611 SOFTWARE
:: bit reversal and sorting programs
:: Find Square Root of a hexadecimal number in assembly language
:: common intreview questions on 8086

Feb 9, 2008

Traffic light control system using 8086

AIM:-
To develop Traffic light Control system using 8086

APPARATUS:-
Microprocessor trainer kit, Traffic light controller kit, power supply, data cable etc

THEORY:-
Traffic light controller interface module is designed to simulate the function of four way traffic light controller. Combinations of red, amber and green LED’s are provided to indicate Halt, Wait and Go signals for vehicles. Combination of red and green LED’s are provided for pedestrian crossing. 36 LED’s are arranged in the form of an intersection. A typical junction is represented on the PCB with comprehensive legend printing.
At the left corner of each road, a group of five LED’s (red, amber and 3 green) are arranged in the form of a T-section to control the traffic of that road. Each road is named North (N), South(S), East (E) and West (W). LED’s L1, L10, L19 & L28 (Red) are for the stop signal for the vehicles on the road N, S, W, & E respectively. L2, L11, L20 & L29 (Amber) indicates wait state for vehicles on the road N, S, W, & E respectively. L3, L4 & L5 (Green) are for left, strait and right turn for the vehicles on road S. similarly L12-L13-L14, L23-L22-L21 & L32-L31-L30 simulates same function for the roads E, N, W respectively. A total of 16 LED’s (2 Red & 2 Green at each road) are provided for pedestrian crossing. L7-L9.L16-L18, L25-L27 & L34-L36 (Green) when on allows pedestrians to cross and L6-L8, L15-L17, L24-L26 & L33-L35 (Red) when on alarms the pedestrians to wait.
To minimize the hardware pedestrian’s indicator LED’s (both red and green are connected to same port lines (PC4 to PC7) with red inverted. Red LED’s L10 & L28 are connected to port lines PC2 & PC3 while L1 & L19 are connected to lines PC0 & PC1 after inversion. All other LED’s (amber and green) are connected to port A & B.

WORKING:-
8255 is interfaced with 8086 in I/O mapped I/O and all ports are output ports. The basic operation of the interface is explained with the help of the enclosed program. The enclosed program assumes no entry of vehicles from North to West, from road East to South. At the beginning of the program all red LED’s are switch ON, and all other LED‘s are switched OFF. Amber LED is switched ON before switching over to proceed state from Halt state.
The sequence of traffic followed in the program is given below.
a) From road north to East
From road east to north
From road south to west
From road west to south
From road west to north
b) From road north to East
From road south to west
From road south to north
From road south to east
c) From road north to south
From road south to north
Pedestrian crossing at roads west & east
d) From road east to west
From road west to east
Pedestrian crossing at roads north & south

microprocessor traffic light control



ASSEMBLY LANGUAGE PROGRAMS:-
MODEL SMALL
.STACK 100
.DATA
CWR EQU 0FFC6 H
PORTA EQU 0FFC0 H
PORTB EQU 0FFC2 H
PORTC EQU 0FFC4 H
.CODE
START:
MOV AX,@DATA
MOV DS,AX
MOV AL,80H
MOV DX,CWR
OUT DX,AL
MOV AL,F3H
MOV DX,PORTC
OUT DX,AL
MOV AL,FFH
MOV DX,PORTA
OUT DX,AL
MOV AL,FFH
MOV DX,PORTB
OUT DX,AL
MOV CL,03H
CALL DELAY
TOP:
MOV AL,EEH
MOV DX,PORTA
OUT DX,AL
MOV AL,EEH
MOV DX,PORTB
OUT DX,AL
MOV CL,02H
CALL DELAY

MOV AL,FCH
MOV DX,PORTC
OUT DX,AL
MOV AL,7DH
MOV DX,PORTA
OUT DX,AL
MOV AL,57H
MOV DX,PORTB
OUT DX,AL
MOV CL,15H
CALL DELAY

MOV AL,E7H
MOV DX,PORTB
OUT DX,AL
MOV AL,FDH
MOV DX,PORTA
OUT DX,AL
MOV AL,EDH
MOV DX,PORTA
OUT DX,AL
MOV CL,02H
CALL DELAY

MOV AL,F7H
MOV DX,PORTB
OUT DX,AL
MOV AL,F0H
MOV DX,PORTC
OUT DX,AL
MOV AL,F1H
MOV DX,PORTA
OUT DX,AL
MOV CL,15H
CALL DELAY

MOV AL,FBH
MOV DX,PORTA
OUT DX,AL
MOV AL,FBH
MOV DX,PORTB
OUT DX,AL
MOV AL,50H
MOV DX,PORTC
OUT DX,AL
MOV CL,15H
CALL DELAY

MOV AL,FEH
MOV DX,PORTA
OUT DX,AL
MOV AL,FEH
MOV DX,PORTB
OUT DX,AL
MOV CL,03H
CALL DELAY

MOV AL,FFH
MOV DX,PORTA
OUT DX,AL
MOV AL,AFH
MOV DX,PORTC
OUT DX,AL
MOV AL,EEH
MOV DX,PORTA
OUT DX,AL
MOV AL,EEH
MOV DX,PORTB
OUT DX,AL
MOV CL,02H
CALL DELAY

MOV AL,BFH
MOV DX,PORTA
OUT DX,AL
MOV AL,BFH
MOV DX,PORTB
OUT DX,AL
MOV CL,15H
CALL DELAY
JMP TOP

DELAY:
MOV BX,10H
D1:
MOV CX,0FFFFH
D2:
LOOP D2
DEC BX
JNZ D1
INT 03H
END START


PROCEDURE:-
1. Connect power supply 5V & GND to both microprocessor trainer kit & Traffic light controller interfacing kit.
2. Connect data bus between microprocessor trainer kit & Traffic light controller interfacing kit.
3. Enter the program to control Traffic light.
4. Execute the program by typing GO E000:0B80 ENTER.
5. Observe the LED’s on traffic light controller PCB.

You might be also interested in:

:: MASM 611 SOFTWARE
:: bit reversal and sorting programs
:: Find Square Root of a hexadecimal number in assembly language
:: common intreview questions on 8086



Jan 28, 2008

Temperature Control system using 8086

AIM:-

To develop Temperature Control system using 8086

APPARATUS:-

Microprocessor trainer kit, Temperature controller kit, power supply, data cable etc

THEORY:-

Temperature control system involved interfacing successive approximation ADC and typical method of measuring and controlling the temperature using microprocessor. ADC is among the most widely used devices for data acquisition. A digital computer uses binary values, but in physical world everything is analog, temperature, pressure, humidity, and velocity are few examples of physical quantities that we seal with every day.

Temperature measurement is of great importance in industry as most of the processes are temperature dependent. A number of devices and schemes have been used over the years, for the measurement of temperature. Typical sensors include devices like thermocouples, thermostats, RTD’s and semiconductor sensor.

This system uses semiconductor sensor AD590 to monitor the temperature of water bath. The AD590 is basically a PTAT (proportional to absolute temperature) current regulator. It generates a current O/P of 1µA/K above absolute zero temperature that is -2730C. Thus at 00C the current O/P will be 273µA and 250 if will be 298µA and 373mV at 1000. This O/p is buffered through an OPAMP having a gain of 10. To enable easy equivalence between the transducers O/P in volts and the measured temperature a calibration procedure needs to be done.

WORKING:-

8255 is interfaced with 8086 in I/O mapped I/O. port A (PA0-PA7) as input port is connect to data lines of ADC, PB0, PB1, PB2 lines of port B for channel selection, PC2 connected to Start of conversion (SOC) and PC3 to O/P enable. Channel 1 of ADC is used to input analog signal, Channel 0 of ADC for temperature controller.

ADC will give binary equivalent of the I/P voltage. Input will vary from 0 to 5V (0 to 100 degree C) and the ADC O/P varies from 00-FFH. So 5V/100 i.e. 5000mvs/100 gives 50mvs/0C. And the counts for indication of temperature are taken as 2.5 (256/100) per degree C.

AC supply to the external heating element is controlled through the onboard Relay, based on the set value. When the temperature of the heating element (which is sensed by AD590, AD590 output is analog which is converted to digital by ADC) is less than the set value (reference value) heating element will be switched ON and when temperature crosses the set temperature AC supply is turned OFF.




MODEL SMALL
.STACK 100
.DATA
START:
PORTA EQU FFC0H ; PORTA address
PORTB EQU FFC2H ; PORTB address
PORTC EQU FFC4H ; PORTC address
CTL EQU FFC6H ; Control port address
CTL_BYTE EQU 98H ; 8255 control reg.
CLEAR_DISPLAY EQU F800:4BB1H
DWAD EQU F800:4BB1H
DBDTA EQU F800:4F1F
DEC_TEMP DB 0
SET_TEMP DB 0
ADC_VAL DB 0
COUNT DB 0
PRE_TEMP DB 0
.CODE
ADC TABLE:

DB 00H,03H,05H,08H,0aH,0dH,0fH,11H,14H,16H


DB 19H,1cH,1eH,21H,24H,27H,2aH,2cH,2eH,32H

DB 34H,36H,39H,3cH,3fH,42H,45H,48H,4aH,4cH

DB 4eH,50H,52H,54H,56H,58H,5bH,61H,64H,67H

DB 6aH,6dH,70H,72H,74H,77H,7aH,7dH,7fH,82H

DB a0H,a2H,a5H,a8H,aaH,aDH,afH,b0H,b3H,b6H

DB b9H,bcH,bfH,c1H,c4H,c6H,c9H,ccH,cfH,d0H

DB d2H,d5H,d7H,daH,dcH,dfH,e0H,e2H,e5H,e7H

DB e9H,ebH,eeH,f1H,f4H,f6H,f9H,fcH,ffH

START:
MOV AL,CTL_BYTE ; 8255
MOV DX,CTL ; PORTC (lower) as output
OUT DX,AL ; PORTA as input
MOV AL,DEC_TEMP
CALL DEC_HEX
MOV SET_TEMP,AL
MOV AL,DEC_TEMP
MOV AH,00
MOV SI,AX
CALL FAR DWAD
MOV DX,CTL
MOV AL,02
OUT DX,AL
MOV AL,00
OUT DX,AL
MOV CX,70
L0:
LOOP L0
BACK:
MOV COUNT,0
CALL ADC
CALL DISP_TEMP
CALL TEMP_CONTL
JMP BACK
DISP_TEMP:
MOV AL,ADC_VAL
MOV SI,OFFSET ADC_TABLE
AGAIN:
CMP AL,[SI]
JC FOUND
JE FOUND
INC SI
INC COUNT
JMP AGAIN
FOUND:
MOV AL,COUNT
CALL HEX_DEC
MOV AH,0
MOV SI,AX
CALL FAR DBDTA
RET
TEMP_CONTL:
MOV AL,COUNT
CMP AL,SET_TEMP
JC TURN_ON_RELAY
RELAY_OFF:
MOV DX,PORTB
MOV AL,0FFH
OUT DX,AL
MOV DL,20H
HERE1:
MOV CX,FFFFH
HERE:
LOOP HERE
DEC DL
JNZ HERE1
RET
TURN_ON_RELAY:
MOV DX,PORTB
MOV AL,00H
OUT DX,AL
CONTINUE:
MOV CX,FFFFH
L22:
LOOP L22
RET
ADC:
MOV DX,CTL
MOV AL,01
OUT DX,AL
MOV CX,70
L10:
LOOP L10
MOV AL,00
OUT DX,AL
L1:
MOV DX,PORTC
IN AL,DX
AND AL,80H
CMP AL,80H
JNZ L1
MOV DX,PORTA
IN AL,DX
MOV ADC_VAL,AL
RET
HEX_DEC:
MOV AH,00H
MOV CL,0AH
DIV CL
MOV CL,04H
ROL AL,CL
AND AL,F0H
OR AL,AH
RET
DEC_HEX:
MOV BL,AL
AND BL,0FH
AND AL,F0H
MOV CL,04
ROR AL,CL
MOV CL,0AH
MUL CL
ADD AL,BL
RET
END START

PROCEDURE:-

1. Connect power supply 5V & GND to both microprocessor trainer kit & temperature controller interfacing kit.

2. Connect data bus between microprocessor trainer kit & temperature controller interfacing kit.

3. Enter the program to read temperature of the water bath from ADC at 0000:4000.

4. Execute the program by typing GO 0000:4000 enter.

5. Enter the reference temperature value, when temperature of water bath exceeds reference value then power supply to water bath is switched OFF.


You might be also interested in:

:: Traffic light control system using 8086
:: Assembly Language Program to serve NMI
:: Interfacing Stepper Motor to 8086 using 8255

Jan 23, 2008

common intreview questions on 8086

1) what is segmentation?
2) how many bit processor does 8086?
3) how many address lines in 8086
4) how many data lines in 8086?
5) multiplexed lines in 8086?
6) over flow flag, interrupt flag ,direction flag, trap flag?
7) role of pointers ?
8) how 16 bit processor generates 20 bit addresses
9) instructions set of 8086
10) timing diagram of 8086
11) min/max mode working of 8086?
12) pin difference in min/max mode
13) interrupt structure in 8086?
14) how an interrupt is acknowledged?
15) how the cs:ip is working during interrupt
16) new cs:ip during interrupt
17) how the even odd address are assigned through 8086?


the remaning questions can be found at : here
You might be also interested in:
:: Assembly Language Programs for Multiplication and Division
:: Assembly Language Programs on array of Hexadecimal numbers

Jan 22, 2008

Interfacing Stepper Motor to 8086 using 8255

To Interface Stepper Motor to 8086 using 8255 and write Assembly Language Program to rotate Stepper Motor in Clockwise & Anticlockwise direction.

APPARATUS:-
Microprocessor trainer kit, ADC kit, power supply, data cable etc

THEORY:-
Stepper motor is a device used to obtain an accurate position control of rotating shafts. A stepper motor employs rotation of its shaft in terms of steps, rather than continuous rotation as in case of AC or DC motor. To rotate the shaft of the stepper motor, a sequence of pulses is needed to be applied to the windings of the stepper motor, in proper sequence. The numbers of pulses required for complete rotation of the shaft of the stepper motor are equal to the number of internal teeth on its rotor. The stator teeth and the rotor teeth lock with each other to fix a position of the shaft. With a pulse applied to the winding input, the rotor rotates by one teeth position or an angle x. the angle x may be calculated as.
x = 3600 / no. of rotor teeth
After the rotation of the shaft through angle x, the rotor locks it self with the next tooth in the sequence on the internal surface of the stator. The typical schematic of a typical stepper motor with four windings is as shown below.


The stepper motors have been designed to work with digital circuits. Binary level pulses of 0-5V are required at its winding inputs to obtain the rotation of the shafts. The sequence of the pulses can be decided, depending upon the required motion of the shaft. By suitable sequence of the pulses the motor can be used in three modes of operation.


  • One phase ON (medium torque)
  • Two phase ON (high torque)
  • Half stepping (low torque)


WORKING:-
8255 is interfaced with 8086 in I/O mapped I/O. port C (PC0, PC1, PC2, PC3) is used to give pulse sequence to stepper motor. The 8255 provides very less current which will not be able to drive stepper motor coils so each of the winding of a stepper motor needs to be interfaced using high speed switching Darlington transistors with max 1A, 80V rating with heat sink, with the output port of 8255. Output the sequence in correct order to have the desired direction to rotate the motor.





Assembly Language Program to rotate Stepper Motor in Clockwise direction

MODEL SMALL
.STACK 100
.DATA
PORTA EQU FFC0H ; PORTA ADDRESS
PORTB EQU FFC2H ; PORTB ADDRESS
PORTC EQU FFC4H ; PORTC ADDRESS
CWR EQU FFC6H ; CONTROL PORT ADDRESS
PHASEC EQU 03H
PHASEB EQU 06H ; SEQUENCE IN SERIES TO ROTATE MOTOR
PHASED EQU 0CH ; IN CLOCKWISE DIRECTION
PHASEA EQU 09H
.CODE
START:
MOV AL,@DATA
MOV DX,CTL
OUT DX,AL
AGAIN:
MOV AL,PHASEC
MOV DX,PORTC
OUT DX,AL
MOV CX,0FFFFH
UP:
LOOP UP

MOV AL,PHASEB
MOV DX,PORTC
OUT DX,AL
MOV CX,0FFFFH
UP1:
LOOP UP1

MOV AL,PHASED
MOV DX,PORTC
OUT DX,AL
MOV CX,0FFFFH
UP2:
LOOP UP2

MOV AL,PHASEA
MOV DX,PORTC
OUT DX,AL
MOV CX,0FFFFH

UP3:
LOOP UP3
JMP AGAIN ; REPEATE OUTPUT SEQUENCE
INT 03H
END START




Assembly Language Program to rotate Stepper Motor in Anticlockwise direction
MODEL SMALL
.STACK 100
.DATA
PORTA EQU FFC0H ; PORTA ADDRESS
PORTB EQU FFC2H ; PORTB ADDRESS
PORTC EQU FFC4H ; PORTC ADDRESS
CWR EQU FFC6H ; CONTROL PORT ADDRESS
PHASEC EQU 03H
PHASEA EQU 09H ; SEQUENCE IN SERIES TO ROTATE MOTOR
PHASED EQU 0CH ; IN ANTICLOCKWISE DIRECTION
PHASEB EQU 06H

.CODE
START:
MOV AL,@DATA
MOV DX,CTL
OUT DX,AL
AGAIN:
MOV AL,PHASEC
MOV DX,PORTC
OUT DX,AL
MOV CX,0FFFFH
UP:
LOOP UP

MOV AL,PHASEA
MOV DX,PORTC
OUT DX,AL
MOV CX,0FFFFH
UP1:
LOOP UP1

MOV AL,PHASED
MOV DX,PORTC
OUT DX,AL
MOV CX,0FFFFH
UP2:
LOOP UP2

MOV AL,PHASEB
MOV DX,PORTC
OUT DX,AL
MOV CX,0FFFFH
UP3:
LOOP UP3
JMP AGAIN ; REPEATE OUTPUT SEQUENCE
INT 03H
END START


PROCEDURE:-
1. Connect power supply 5V & GND to both microprocessor trainer kit & Stepper motor interfacing kit.
2. Connect data bus between microprocessor trainer kit & Stepper motor interfacing kit.
3. Enter the program to rotate Stepper motor in clockwise & anticlockwise.
4. Execute the program by typing GO E000:00C0 ENTER for clockwise, GO E000:0030 ENTER for anticlockwise.
5. Observe the rotation of stepper motor.


You might be also interested in:
:: Temperature Control system using 8086
:: Traffic light control system using 8086
:: Assembly Language Program to serve NMI