ELEVATORASM - Notepad File Edit Format View Help ELEVATOR INTERFACE Assumes the
ID: 3701999 • Letter: E
Question
ELEVATORASM - Notepad File Edit Format View Help ELEVATOR INTERFACE Assumes the interface is connected over 18 of trainer : The elvator will work in both upward and Downward directions This program starts at 2000H location OUTPUT 2500AD 2000H DX, OFFE6H AL, 82H DX, AL AX, AX ; Configure 8255 ; PortA as o/p,Porte as i/p MOV Initial stage is ground floor ; AH is the floor position LOOP1: MOV AL,AH AL,OFOH DX, OFFEOH DX, AL MOVDX, OFFE2H LOOP2: IN : Get request AL, DX AL,OFH AL, OFH LOOP2 AND MOVSI,00H FINDF : ROE OUND AL,01H SHORT FINDF otherwise,continue search AL,AH : If requested floor found JMP FOUND: MOV AL, [SI]2100H Get requesting floor code ; Compare with current floor : If it need to go UP If it need to g DOWN CLEAR: MOVAL. [SI]2104H DX, OFFEOH DX, AL DELAY XCHG AL,AH MP SHORT LOOP1 GouP: CALL ; Elevator goes UP by one LED AL , OFOH DX, OFFEOH DX, AL AL OFH AH,AL AL,AH XCHG OMP GODN CALL DELAY DEC XCHG SHORT CLEAR : Elevator goes DOwN by one LED AH,AL AL,OFOH DX, OFFEOM DX,AL AL .OFH XCHG AL AH AL,AH GODN SHORT CLEAR ONZ CX, 0800H Delay between glow of successive LEDS HR2 DELAY: MOV LOOP RET 2100H OOH, 03H, 06H, 09H : Position codes for floors VAL UE1: 0B VALUE2: OBOEOH.003H,086H,79H : clear coderposition dode for all floorsExplanation / Answer
EXPLANATION:
ORG: is origin directive which sets the program/instructions origin by telling the assembler to load instruction and data at particular location.
MOV: Copies the data from source to destination,
MOV Destination Source
OUT: Outputs the value to hardware port
XOR: Performs an Exclusive-OR operation on the source/destination and stores the result in the destination register.
XOR Destination Source
OR: Performs a bitwise OR on the source and destination and stores the result in the destination.
OR Destination Source
IN: Inputs the value from hardware port
CMP: Compare the numerical value of the destination with the source and set flags appropriately. This comparison is carried out like value1 - value2. If output is zero means value1 is equal to value2. After a CMP instruction, OF, SF, ZF and CF are set appropriately
OF: overflow flag, SF: signed flag, ZF: Zero flag, CF: Carry Flag
JZ: (conditional jump) The program sequence is transferred to a particular level or a 16-bit address if Z=1 (or zero flag is 0)
ROR: Rotates the bits in the destination to the right "count" times with all data pushed out the right side re-entering on the left. Same as Shift
ROR Destination Count
INC: Increments the Destination by one
DEC: Decrements the Destination by one.
CALL: Saves the address of the next instruction onto the stack and then changes the IP.
XCHG: ExChange the source with destination
--------------------------------------------------------------------------------------------------------------------------------
1.
ORG 2000H: Set program origin to 2000h
MOV DX, 0FFE6H: Moves value from 0FFE6H to DX
MOV AL, 82H: Moves value from 82H to AL
OUT DX, AL: Outputs bytes in AL to input address in DX
XOR AX, AX: Performs exclusive or operation on source and destination, here source and destination are same.
2.
LOOP1: Label to access particular set of code for jumping
MOV AL, AH: Move byte from AH to AL
OR AL, 0F0H: Perform bitwise or operation on values at 0f0h and AL and store in AL
MOV DX, 0FFE0H: Move value from 0FFE0H to DX
OUT DX, AL: Outputs bytes in AL to input address in DX
3.
LOOP2: Label to access particular set of code for jumping
MOV DX, 0FFE2H: Move value form 0FFE2H to DX
IN AL, DX: Inpute byte from address in DX to AL
AND AL, 0FH: Perform bitwise and operation on 0fh and AL and store value in AL
CMP AL, 0FH: Compare value in AL with value in 0FH location by substration
JZ: LOOP2 Jump to LOOP2 label if value at AL and 0FH are equal
4.
FINDF: Label to access particular set of code for jumping
MOV SI, 00H: Move value from 00H to SI
ROR AL, 01H: Rotate bites in AL to right end according to the count value specified in
01H
JNC FOUND: Jump to label of code FOUND and perform code instruction below it.
INC SI: Increment value in SI by 1.
JMP SHORT FINDF: short jump to FINDF label.
5.
FOUND:
MOV AL, [SI]2100H: Mov value from base address of SI + location 2100H to AL
CMP AL,AH: Compare value in AL with value in AH by substration
JA GROUP: Jump to GROUP Label if AL > AH (unsiged)
JB GODN: Jump to GODN Label if AL< AH
6.
CLEAR:
MOV AL, [SI]2104H: Mov value from base address of SI + location 2104H to AL
MOV DX, 0FFE0M: Mov value from 0FFE0M to DX
OUT DX, AL: Outputs bytes in AL to input address in DX
JMP SHORT LOOP1: Unconditional short jump to LOOP1 label.
7.
GOUP:
CALL DELAY: Call Delay labeland perform the instruction and comeback.
INC AH: Increment AH value by 1.
XCHG AL, AH: Exchange values of AL and AH
OR AL, 0f0h: Perfrom bitwise or operation on values in 0F0H and AL and stor it in AL
MOV DX, 0FFE0H: Move value from 0FFE0H to DX
OUT DX, AL: Outputs bytes in AL to input address in DX
AND AL, 0FH: Perform bitwise and operation on 0fh and AL and store value in AL
XCHG AL, AH: Exchange values of AL and AH
CMP AL, AH: Compare value in AL with value in 0FH location by subtraction store flag.
JNZ GROUP: Conditional jump to GROUP label if AL is not equal to AH
JMP SHORT CLEAR: Unconditional short jump to CLEAR.
8.
GODN:
CALL DELAY: Call Delay label and perform the instruction and comeback.
DEC AH: Decrement AH value by 1.
XCHG AH, AL: Exchange value of AH and AL
OR AL, 0f0h: Perfrom bitwise or operation on values in 0F0H and AL and stor it in AL
MOV DX, 0FFE0H: Move value from 0FFE0H to DX
OUT DX, AL: Outputs bytes in AL to input address in DX
AND AL, 0FH: Perform bitwise and operation on 0fh and AL and store value in AL
XCHG AL, AH: Exchange values of AL and AH
CMP AL, AH: Compare value in AL with value in 0FH location by subtraction store flag.
JNZ GODN: Conditional jump to GODN label if AL is not equal to AH
JMP SHORT CLEAR: Unconditional short jump to CLEAR.
9.
DELAY:
MOV CX, 0800H: Move value from 0800H to CX.
HR1: LOOP HR1: Flag to delay
HR2: LOOP HR2: Flag to delay
RET Return back to calling label
10.
Value 1: DB 00H, 03H…: Reserve the Data bytes of specified memory location in available.
memory
Value 2: DB 0E0H, 0D3M,: Reserve the Data bytes of specified memory location in available.
memory
------------------------------------------------------------------------------------------------------------------------------
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.