hemz mpmc rep1

Upload: rajgopalsm

Post on 06-Apr-2018

232 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 hemz mpmc rep1

    1/25

    DATE: 15TH September 2011

    MICROPROCESS

    ORS ANDMICRO

    CONTROLLERS

    LAB REPORTSUBMITTED BY

    RESHMA BABU &

    RAVURI ASWANI

    GROUP NO: 7

    BATCH: B

  • 8/3/2019 hemz mpmc rep1

    2/25

    SEMESTER: 5

    EXPERIMENT NO:14th August 2011

    FAMILIARISATION OF MICROPROCESSOR TRAINER

    KIT

    AIM

    To familiarize with 8086 microprocessor trainer kit having in-built assembler

    MATERIALS REQUIRED

    8086 microprocessor trainer kit, PC

    PROCEDURE

    Steps in setting up the kit and burning the code into it.

    On the keyboard of the kit

    Type BU and then press ENTER

    Wait for a ? to be displayed

    Type 5 and ENTER

    Then type SI 1000 and ENTER

    You will see the message serial input on it

    Now go to the PC

    Write the program on the notepad and save as asm file in bin directory.

    Open command prompt

    Type cd

    Type EDIT

    Type ml

    Type DEBUG then press ENTER

    Type -n

    Type -wcs:1000 to write the code segment

    Type -q to quit the debugging

    Then type DATACOM

    Set the default parameters in the window that appears

    Then transmit the filename.bin

    Wait till the data is send to the kit

  • 8/3/2019 hemz mpmc rep1

    3/25

    On the kit type GO 1000 to start executing, now we can see the outputs from

    the required ports

    RESULT :Hence we are familiarized with the microprocessors trainer kit.

    EXPERIMENT NO:24th August 2011

    ADDITION OF TWO 32-BIT NUMBERS

    AIM

    To write a program to add two 32-bit numbers in memory and store back the

    result

    MATERIALS REQUIRED: 8086 MP trainer kit, PC.

    PROGRAM:

    .MODEL SMALL

    .CODE

    .STARTUP

    ORG 1000H

    MOV SI, 5032H ; setting the initial memory location

    MOV AL, [SI] ;

    MOV AH, [SI+1] ; reading lower word of first number

    MOV BL, [SI+4]

    MOV BH, [SI+5] ; reading lower word of second number

    ADD AX, BX; adding the lower words

    MOV [SI+8], AL

    MOV [SI+9], AH ; store the result in memory

    ;carry holds the overflow

    MOV AL, [SI+2]

    MOV AH, [SI+3] ; reading higher word of first number

    MOV BL, [SI+6]

    MOV BH, [SI+7] ; reading higher word of second number

  • 8/3/2019 hemz mpmc rep1

    4/25

    ADC AX, BX ;adding the higher words with carry

    MOV [SI+10], AL

    MOV[SI+11] ,AH ;STORE THE RESULTS IN MEMORY

    MOV AX,0000H

    ADC AX,0000H

    MOV [SI+12],AL ;STORE OVERFLOW IN MEMORY

    .EXIT

    END

    PROCEDURE

    ENTER THE PROGRAM FROM LOCATON 1000H

    ENTER DATE IN MEMORY LOCATIONS 5032H TO 5039H

    EXECUTE program and verify results

    INPUT

    5032H-01

    5033H-04

    5034H-04

    5035H-03

    5036H-03

    5037H-02

    5038H-03

    5039H-05

    OUTPUT

    503AH-04

    503BH-06

    503CH-07

    503DH-08

  • 8/3/2019 hemz mpmc rep1

    5/25

    EXPERIMENT NO 3:4th August 2011

    GENERATION OF TRIANGULAR WAVEFORM USING

    DAC CARD

    AIM: To write a program to generate triangular waveform using DAC card

    and 8086

    MATERIALS REQUIRED: 8086 microprocessor trainer kit, CRO, PC, DAC

    card

    PROGRAM:

    .MODEL SMALL;program to generate triangular waveform on a DAC board

    .CODE

    .STARTUP

    ORG 1000H ;origin set at location 1000h

    MOV AL,00H ;set the initial value to 0

    INCR:OUT 0C8H,AL ;output the value in al to

    DAC2

    CALL DELAY ;provide necessary delay

    INC AL ;increment the value

    CMP AL,0FFH ;check if the value is

    maximum

    ;if maximum start

    decrementing

    JNZ INCR ;if value is not maximum

    continue incrementing

    DECR:OUT 0C8H,AL ;output the value in al to DAC2

  • 8/3/2019 hemz mpmc rep1

    6/25

    CALL DELAY ;provide necessary delay

    DEC AL ;decrement the value

    CMP AL,00H ;check if the value is minimum

    ;if minimum start increment

    JNZ DECR ;if value is not minimum

    continue decrementing

    JMP INCR ;if value is minimum start

    incrementing

    DELAY PROC NEAR ;delay program

    MOV CX,09H ;set the count value to 9 for

    small delay

    HERE:LOOP HERE ;loop for count number of times

    RET ;return to the main function

    DISPLAY ENDP ;end the delay program

    .EXIT

    END

    PROCEDURE:

    Enter the program in memory locations starting from 1000H

    Execute the program and verify the output from the CRO

    OBSERVATION:

  • 8/3/2019 hemz mpmc rep1

    7/25

    RESULT: Triangular waveform has been generated using 8086 and DAC card

    EXPERIMENT NO:44th August 2011

    ADDITION OF TWO 64 BIT NUMBERSAIM

    To write a program to add two 64 bit numbers in 8051 simulator

    REQUIREMENTS

    8051 trainer kit and Connecting probes

    THEORY

    8051 is an 8 bit microcontroller. It has 128 bits of RAM 4 bytes of on chip ROM, 2 timers one

    serial port and 4 ports all on a single chip. Both the timers are 16 bits wide and SETB & CLR

    instructions can be used to stop and start the timer.

    Steps to use 8051 trainer kit and simulator

  • 8/3/2019 hemz mpmc rep1

    8/25

    Go to Digitickx, a window will pop out

    Give project name, location and select debugger

    Go to file> new, select asm file and give file name and location.

    Type the code in the white space provided

    Go to Build>Build sample.hex

    Then go to project settings to select the way of display of out, either in the PC or

    8051 kit.

    If the result to be displayed in the kit, for downloading the code select Debug with

    Digitickx51-C Debugger.

    Debugging can be done by selecting Debug> Step over, result of each register,

    memory etc can be examined.

    PROGRAM

    ORG 0000H

    MAIN: MOV R0,#030H ;set the start location of first number

    MOV R1,#050H ;set the start location of second number

    MOV R2,#08H ;set the number of bytes

    MOV A,#55H ;highest byte of the first number

    MOV B,#66H ;highest byte of the second number

    ADD A,#00H ;clear the accumulator

    ;store the 64 bit numbers in memory

    AGN: MOV @R0,B ;higher byte of the first number is stored

    MOV @R1,A ;higher byte of the second number is stored

    INC R0 ;increment the location of first number

    INC R1 ;increment the location of second number

    DEC A ;decrement the first number byte

    DEC B ;decrement the second number byte

    DJNZ R2,AGN ;loop for 8 times to write2 64 nit numbers

    DEC R0 ;point to the LSB for first number

    DEC R1 ;point to the MSB for second number

    SETB PSW.3 ;select the 4th register number

    MOV R0,#77H ;set the memory location for answer

  • 8/3/2019 hemz mpmc rep1

    9/25

    CLR PSW.3 ;select the default register bank

    MOV R2,#08H ; set the number of bytes

    ; add the two 64 bit numbers

    RST: MOV A,@R1 ; read the byte of second number

    ADDC A,@R0 ; add with the corresponding byte of first number

    SETB PSW.3 ;select the fourth register bank

    MOV @R0,A ;store the byte result in corresponding location of result

    DEC R0 ;decrement the location for the result location

    CLR PSW.3 ;select the default register bank

    DEC R0 ;decrement the location for the first number byte

    DEC R1 ;decrement the location for the second number byte

    DJNZ R2,RST ;loop for 8 times

    END

    RESULT

    64 Bit addition has been performed and output has been verified

    EXPERIMENT NO:511th August 2011

    GENERATION OF SQUARE WAVE

    AIM

    To write a program to generate a square wave using timer and interrupts in 8051

    REQUIREMENTS

    8051 trainer kit

    THEORY

    8051 is an 8 bit microcontroller. It has 128 bits of RAM 4 bytes of on chip ROM, 2 timers one

    serial port and 4 ports all on a single chip. Both the timers are 16 bits wide and SETB & CLR

    instructions can be used to stop and start the timer.

  • 8/3/2019 hemz mpmc rep1

    10/25

    Out of the 6 interrupts, 2 external hardware interrupts are set aside for the timers. The

    count value is given to the timer registers and in the interrupt enable mode when the count

    reaches, the program will go automatically to the interrupt vector assigned for the timers.

    PROGRAM

    ORG 0000H ;set the origin to zero

    MAIN: LJMP START ;jump to the main routine

    ORG 001BH ;isr location for the timer interrupt

    LJMP ISR_T1 ;jump to subroutine to complement the output pin

    ORG 0030H ;location of main routine

    ;main routine starts here

    START:MOV TMOD,#10H ;set the timer 1

    MOV IE,#88H ;interrupt enable for timer1

    MOV TL1,#0FFH

    MOV TH1,#0FFH ;count values for the timer

    SETB TCON.6 ;start timer

    BACK: SJMP BACK ;loop here

    ;isr to stop timer, complement the pin and again setting the

    timer

    ISR_T1: CLR TCON.6 ;stop timer

    CPL P2.3 ;complement output

    MOV TL1,#0FFH

    MOV TH1,#0FFH ;provide count values for the timer

    SETB TCON.6 ;start the time

    RETI ;return from interrupt

    END

    OBSERVATION:

    Frequency: 15Hz

    RESULT:

  • 8/3/2019 hemz mpmc rep1

    11/25

    Square wave output has been generated and wave is as shown:-

    EXPERIMENT NO: 6DATE: 18TH AUGUST 2011

    SINGLE DIGIT CALCULATOR

    AIM: To design single digit calculator using 8279 interface board.

    MATERIALS REQUIRED: 8086 trainer kit, 8279 interface board

    PROGRAM

    FOR ADDITION

  • 8/3/2019 hemz mpmc rep1

    12/25

    ORG 1000H ;origin set at location 1000H

    MOV DI, 5000H

    MOV AL, 0CH ;storing seven segment code of 0 into AL

    MOV [DI], AL

    INC DI

    MOV AL, 9FH ; storing seven segment code of 1 into AL

    MOV [DI], AL

    INC DI

    MOV AL, 4AH ; storing seven segment code of 2 into AL

    MOV [DI], AL

    INC DI

    MOV AL, 0BH ; storing seven segment code of 3 into AL

    MOV [DI], AL

    INC DI

    MOV AL, 99H ; storing seven segment code of 4 into AL

    MOV [DI], AL

    INC DI

    MOV AL, 29H ; storing seven segment code of 5 into AL

    MOV [DI], AL

    INC DI

    MOV AL, 28H ; storing seven segment code of 6 into AL

    MOV [DI], AL

    INC DI

    MOV AL, 8FH ; storing seven segment code of 7 into AL

    MOV [DI], AL

  • 8/3/2019 hemz mpmc rep1

    13/25

    INC DI

    MOV AL, 08 ; storing seven segment code of 8 into AL

    MOV [DI], AL

    INC DI

    MOV AL, 09 ; storing seven segment code of 9 into AL

    MOV [DI], AL

    INC DI

    MOV AL, 88H ; storing seven segment code of A into AL

    MOV [DI], AL

    INC DI

    MOV AL, 38H ; storing seven segment code of B into AL

    MOV [DI], AL

    INC DI

    MOV AL, 6CH ; storing seven segment code of C into AL

    MOV [DI], AL;

    INC DI;

    MOV AL, 1AH ; storing seven segment code of D into AL

    MOV [DI], AL

    INC DI

    MOV AL, 68H ; storing seven segment code of E into AL

    MOV [DI], AL

    INC DI

    MOV AL, 0E8H ; storing seven segment code of F into AL

    MOV [DI], AL;

    MOV AL, 0 ; word for display ram, right entry

  • 8/3/2019 hemz mpmc rep1

    14/25

    OUT CNTR, AL ;send it control register

    MOV AL, 3EH ;word to divide clock freq by 30

    OUT CNTR, AL ;send to control register

    MOV AL, 0CCH ;word to clear display

    OUT CNTR, AL ;send to control register

    MOV AL, 90H ;word to write display ram

    OUT CNTR, AL ;send to control register

    MOV CX, 08 ;counter

    MOV AL, 0FFH ;data to blank out display

    AGN: OUT DATR, AL ;send to data register

    LOOP AGN ;repeat for 8 digits

    MOV DI, 7000H

    REPP:MOV SI, 5000H

    IN AL, CNTR

    TEST AL, 07

    JZ REPP

    MOV AL, 40H

    OUT CNTR, AL

    IN AL, DATR

    AND AL, 0FH

    MOV BL, AL

    MOV BH, 0

    MOV [DI], BX

    INC DI

    INC DI

  • 8/3/2019 hemz mpmc rep1

    15/25

    MOV DL, 0CH

    CMP BL, DL

    JZ RES

    DISP: MOV AX, SI

    ADD AX, BX

    MOV SI, AX

    MOV AL, [SI] ;take corresponding display code

    OUT DATR, AL ;send to data register

    JMP REPP

    RES: MOV CX, 08H ;counter

    MOV AL, 0FFH ;send max value into AL

    AGAIN:OUT DATR, AL ;send it to data register

    LOOP AGAIN;

    MOV AX, [7002H];

    MOV CX, 0AH

    CMP AX, CX

    JZ AD

    AD: MOV BX, 7000H

    MOV AX, 0

    ADD AX, [BX]

    MOV BX, 7004H

    ADD AX, [BX]

    MOV CX, SI

    MOV SI, 7006H

    MOV [SI], AX

  • 8/3/2019 hemz mpmc rep1

    16/25

    MOV SI, CX

    JMP CONV

    CONV: MOV BX, 7006H

    MOV AX, 0

    ADD AX, [BX]

    MOV DX, 0

    MOV CX, 10H

    REPEA: DIV CX

    PUSH DX

    MOV DX, 0

    INC COUNT

    CMP AX, 0

    JNE REPEA

    DISPL: MOV SI, 5000H

    POP DX

    MOV AX, SI

    ADD AX, DX

    MOV SI, AX

    MOV AL, [SI] ;take corresponding display code

    OUT DATR, AL ;send to data register

    DEC COUNT

    JNZ DISPL

    .EXIT

    END

    FOR SUBTRACTION

  • 8/3/2019 hemz mpmc rep1

    17/25

    .MODEL SMALL

    .DATA

    DATR EQU 0C0H ;address of data register

    CNTR EQU 0C2H; ;address of control register

    COUNT DB 0

    .CODE

    .STARTUP

    MOV AL, 0CH ;storing seven segment code of 0 into AL

    MOV [DI], AL

    INC DI

    MOV AL, 9FH ; storing seven segment code of 1 into AL

    MOV [DI], AL

    INC DI

    MOV AL, 4AH ; storing seven segment code of 2 into AL

    MOV [DI], AL

    INC DI

    MOV AL, 0BH ; storing seven segment code of 3 into AL

    MOV [DI], AL

    INC DI

    MOV AL, 99H ; storing seven segment code of 4 into AL

    MOV [DI], AL

    INC DI

    MOV AL, 29H ; storing seven segment code of 5 into AL

    MOV [DI], AL

    INC DI

  • 8/3/2019 hemz mpmc rep1

    18/25

    MOV AL, 28H ; storing seven segment code of 6 into AL

    MOV [DI], AL

    INC DI

    MOV AL, 8FH ; storing seven segment code of 7 into AL

    MOV [DI], AL

    INC DI

    MOV AL, 08 ; storing seven segment code of 8 into AL

    MOV [DI], AL

    INC DI

    MOV AL, 09 ; storing seven segment code of 9 into AL

    MOV [DI], AL

    INC DI

    MOV AL, 88H ; storing seven segment code of A into AL

    MOV [DI], AL

    INC DI

    MOV AL, 38H ; storing seven segment code of B into AL

    MOV [DI], AL

    INC DI

    MOV AL, 6CH ; storing seven segment code of C into AL

    MOV [DI], AL;

    INC DI;

    MOV AL, 1AH ; storing seven segment code of D into AL

    MOV [DI], AL

    INC DI

    MOV AL, 68H ; storing seven segment code of E into AL

  • 8/3/2019 hemz mpmc rep1

    19/25

    MOV [DI], AL

    INC DI

    MOV AL, 0E8H ; storing seven segment code of F into AL

    MOV [DI], AL

    MOV AL, 0 ;word for display ram, right entry

    OUT CNTR, AL ;send it control register

    MOV AL, 3EH ;word to divide clock frequency by 30

    OUT CNTR, AL ;send to control register

    MOV AL, 0CCH ;word to clear display

    OUT CNTR, AL ;send to control register

    MOV AL, 90H; word to write display ram

    OUT CNTR, AL ;send to control register

    MOV CX, 08 ;counter

    MOV AL, 0FFH ;data to blank out display

    AGN: OUT DATR, AL;send to data register

    LOOP AGN ;repeat for 8 digits

    MOV DI, 7000H;

    REPP:MOV SI, 5000H

    IN AL, CNTR

    TEST AL, 07

    JZ REPP

    MOV AL, 40H

    OUT CNTR, AL

    IN AL, DATR

    AND AL, 0FH

  • 8/3/2019 hemz mpmc rep1

    20/25

    MOV BL, AL

    MOV BH, 0

    MOV [DI], BX

    INC DI

    INC DI

    MOV DL, 0CH

    CMP BL, DL

    JZ RES

    DISP: MOV AX, SI

    ADD AX, BX

    MOV SI, AX

    MOV AL, [SI] ;take corresponding display code

    OUT DATR, AL ;send to data register

    JMP REPP

    RES: MOV CX, 08H

    MOV AL, 0FFH

    AGAIN: OUT DATR, AL

    LOOP AGAIN

    MOV AX, [7002H]

    MOV CX, 0BH

    CMP AX, CX

    JZ SU

    SU: MOV BX, 7000H

    MOV AX, 0

  • 8/3/2019 hemz mpmc rep1

    21/25

    ADD AX, [BX]

    MOV BX, 7004H

    SUB AX, [BX]

    MOV CX, SI

    MOV SI, 7006H

    MOV [SI], AX

    MOV SI, CX

    JMP CONV

    CONV: MOV BX, 7006H

    MOV AX, 0

    ADD AX, [BX]

    MOV DX, 0

    MOV CX, 10H

    REPEA: DIV CX

    PUSH DX

    MOV DX, 0

    INC COUNT

    CMP AX, 0

    JNE REPEA

    DISPL: MOV SI, 5000H

    POP DX

    MOV AX, SI

    ADD AX, DX

    MOV SI, AX

  • 8/3/2019 hemz mpmc rep1

    22/25

    MOV AL, [SI] ; take corresponding display code

    OUT DATR, AL ; send to data register

    DEC COUNT

    JNZ DISPL

    .EXIT

    END

    PROCEDURE:

    8279 interface board is used as a calculator. The user can input any of the

    digits from 0 to 9 as numbers. Key A is used for addition. B for subtraction

    and c to see the result. The result should be in decimals.

    INPUT OUTPUT

    3 A 5 C 8

    2 A 4 C 6

    7 B 3 C 4

    9 B 6 C 3

    EXPERIMENT NO: 7

    25TH August 2011

    DANCING LEDs

    AIM

    To generate waveforms of different frequencies using 8253 timer by which

    dancing LEDs are observed.

    MATERIALS REQUIRED

  • 8/3/2019 hemz mpmc rep1

    23/25

    8086 trainer kit, 8253 timer board with manual, Bread board, CRO and LEDs.

    PROGRAM:

    .MODEL SMALL

    .DATA

    CR EQU 0CEH ; address of control register

    CNT0 EQU 0C8H ; address of counter0

    CNT1 EQU 0CAH ; address of counter1

    CNT2 EQU 0CCH ; address of counter2

    .CODE

    .START UP

    MOV AL, 37H ; control word to use counter0

    OUT CR, AL ; send control word to control register

    MOV AX, 10H ; load count= 10H

    OUT CNT0, AL ; send low byte of count to counter0

    MOV AL, AH ; move high byte of count to AL

    OUT CNT0, AL ; send high byte of count to counter0

    MOV AL, 77H ; control word to use counter

    OUT CR, AL ; send control word to control register

    MOV AX, 100H ; load count= 100H

    OUT CNT1, AL ; send low byte of count to counter1

    MOV AL, AH ; move high byte of count to AL

    OUT CNT1, AL ; send high byte of count to counter 1

    MOV AL, 0B7H ; control word to use counter2

    OUT CR, AL ; send control word to control register

  • 8/3/2019 hemz mpmc rep1

    24/25

    MOV AX, 1000H ; load count= 1000 in AX

    OUT CNT2, AL ; send low byte of count to counter2

    MOV AL, AH ; move high byte of count to AL

    OUT CNT2, AL ; send high byte of count to counter2

    END

    EXPLANATION

    With this program, counter 0 divides input frequency by 10, counter 1

    by 100 and counter 2 by 1000. We have used the BCD of bit D0 (=1)of the

    control word, and so used the numbers 10H, 100H and 1000H as a count for

    the three cases. The control words of the three counters would be 37H,77H

    and 0B7H.

    PROCEDURE

    Establish connections with 8086 microprocessor and 8253 timer.

    Give the output of the 8253 timer to the LEDs.

    Enter the program in the memory location starting from 1000H.

    Execute the program and observe the square waveforms and the dancingLEDs.

  • 8/3/2019 hemz mpmc rep1

    25/25

    OBSERVATIONS: Square waveforms of different frequencies are observed

    on the CRO as shown below.

    RESULT:

    The waveforms of different frequencies are observed on the CRO and the

    resulting dancing format of LEDs is observed.