loading...

CS401 Computer Architecture and Assembly Language Assignment 3 Solution fall 2012

Question: 1

In this assignment, you have to deal with parallel ports as shown in Fig: 1.You have to read and write the parallel port’s data block using IN and OUT instructions.

We can control AC devices (switching them ON/OFF) by interfacing them with system’sParallelPortas shown in Fig: 2.We have to use some external Electrical switching circuitry which needs some expertise to design it that will switch those devices ON or OFF depending upon theParallelPort’s PIN status either Set (1) or Cleared (0).

 

Suppose we have interfaced 5 different AC devices with our system’s parallel port and want those to be controlled using five different keyboard keys.

You have to write an assembly code that will read the device status (read the parallel port) and on the basis of that status, it will turn the specific device ON or OFF depending upon your input provided through keyboard as shown in Table: 1.

Keyboard Key

Data pin linked

Device Controlled or Action Performed

F

Data Pin 0

FAN Controlled

L

Data Pin 1

Light Controlled

T

Data Pin 2

Television Controlled

D

Data Pin 3

DVD player Controlled

S

Data Pin 4

Sound System Controlled

Q

NIL

Program Exit/Quit/Terminate

Table: 1

In your code, you have to read an input character (ASCII code only) from keyboard and then have to send a specific HEX value to parallel port to turn ON or OFF the specific device (depends upon the current state).

Note: If a device is ON, by pressing the assigned key the device should be set to OFF or vice versa. For example, if you have pressed “F” to switch ON the FAN then by pressing the key “F” again will switch OFF the FAN as shown in Table: 2.

You have to write a code in assembly language using ASCII standard that take an input character from keyboard (Capital letters:F, L, T, D, S and Q) and on the basis of these characters, you have to control attached AC devices via the parallel port.

 

Key Pressed

D0

D1

D2

D3

D4

F

1

0

0

0

0

L

0

1

0

0

0

T

0

0

1

0

0

D

0

0

0

1

0

S

0

0

0

0

1

Q

0

0

0

0

0

Table: 2


Solution Idea:
ORG 0100H

XOR AX, AX ; clearing AX
XOR DX, DX ; clearing DX

MAIN:
MOV AH, 1H ; keyboard input
INT 21H ; read character into AL

CMP AL, 53H ; compare AL with “S”
JE S ; jump to “Stop routine”

CMP AL, 46H ; compare AL with “F”
JE F ; jump to “Forward routine”

CMP AL, 52H ; compare AL with “R”
JE R ; jump to “Reverse routine”

CMP AL, 45H ; compare AL with “E”
JE END ; jump to “Exit routine”

JMP MAIN ; jump to main program

S: MOV AL, 00H ; setting AL to STOP mode
MOV DX, 0x378
OUT DX, AL ; writing data to Parallel port
JMP MAIN

F: MOV AL, 01H ; moving motor in forward direction
MOV DX, 0x378
OUT DX, AL ; writing data to Parallel port
JMP MAIN

R: MOV AL, 02H ; moving motor in reverse direction
MOV DX, 0x378
OUT DX, AL ; writing data to Parallel port
JMP MAIN

END: MOV AX, 4C00H
INT 21H

DOWNLOAD SOLUTION HERE
loading...