Thursday , 21 November 2024

CS401 Assignments # 3 Solution Spring 2012

Question:

DC motor (fig 1) is operated through two terminals, whenever the potential difference is created (through batteries, cells etc) across these terminals the motor starts its motion.

Suppose we have connected a DC motor to our system’s parallel port through a secure circuitry (fig 3).

We wish to operate the DC motor through our parallel port (fig 2) using some input through our keyboard. Like “F” key for running motor in “Forward Direction”, “R” for “Reverse Direction”, “S” for “Stop” and “E” for “Exit from code”.


We have suggested that we will use parallel port’s Pin 2 and Pin 3 (the last 2 pins of parallel port’s data check fig 2 and table 1).

Pin 2 Pin 3 Outcome
0 0 Stop
0 1 Forward
1 0 Reverse
1 1 No Operation

Table 1

You have to write a code in assembly language that take an input character from keyboard (S, F, R and E) and on the basis of these characters transmit the code (with respect to the truth table) to the parallel port to operate that connected DC motor.

NOTE: your code only use ASCII code for Capital letters F, R, S and E as an input from the keyboard and will transmit the specific data to the parallel port. Through this program, we are interested in communicating with a DC motor through parallel port.

SOLUTION:

ORG 0100H

XOR AX, AX                                    ; clearing AX

XOR DX, DX                                    ; clearing DX

MAIN:

MOV AH, 1H                         ; keyboard input

INT 21H                                 ; read character intoAL

CMP AL, 53H                                    ; compareALwith “S”

JE S                                         ; jump to “Stop routine”

CMP AL, 46H                                    ; compareALwith “F”

JE F                                         ; jump to “Forward routine”

CMP AL, 52H                                    ; compareALwith “R”

JE R                                        ; jump to “Reverse routine”

CMP AL, 45H                                    ; compareALwith “E”

JE END                                   ; jump to “Exit routine”

JMP MAIN                             ; jump to main program

S:                     MOV AL, 00H                       ; settingALto STOP mode

MOV DX, 0x378

OUTDX,AL                         ; writing data to Parallel port

JMPMAIN

F:                     MOV AL, 01H                       ; moving motor in forward direction

MOV DX, 0x378

OUTDX,AL                         ; writing data to Parallel port

JMPMAIN

R:                    MOV AL, 02H                       ; moving motor in reverse direction

MOV DX, 0x378

OUTDX,AL                         ; writing data to Parallel port

JMPMAIN

END:               MOV AX, 4C00H

INT 21H

/****************** Download Solution From here **********************\



Spring 2012_CS401_3_SOL

Check Also

CS401 Assignment no 03 Solution Spring 2013 has been uploaded

Please carefully read the following instructions before attempting assignment.   Rules for Marking It should be clear …

Leave a Reply

Your email address will not be published. Required fields are marked *

*