Documentos de Académico
Documentos de Profesional
Documentos de Cultura
0001 0000
0002 0000 .ORG 2000h
0003 2000 31 00 29 LXI SP, 2900H ;Initialise the
Stack Pointer
0004 2003 3E 08 MVI A,08h
0005 2005 20 RIM
0006 2006 CD 32 20 KBREAD: CALL RDKBD ;READ KEYBOARD
FUNCTION
0007 2009
0008 2009
; 9
; 4 5 6
; 1
;Given below is the assembly code that checks the key-value. This is
analogous to switch-case programming structure in C
0023 2009 FE 09 CPI 09h ;compare with
key value 09
0024 200B CC 00 21 CZ FRONT ;If matched
call the subroutine FRONT
0025 200E CA 06 20 JZ KBREAD ;Go back to
Read the Keyboard
0026 2011
0027 2011
0028 2011 FE 01 CPI 01h ;compare with key
value 01
0029 2013 CC 1E 21 CZ BACK ;If matched call
the subroutine BACK
0030 2016 CA 06 20 JZ KBREAD ;Go back to
Read the Keyboard
0031 2019
0032 2019 FE 06 CPI 06h ;;compare with
key value 01
0033 201B CC 3C 21 CZ RIGHT ;If matched call
the subroutine RIGHT
0034 201E CA 06 20 JZ KBREAD
0035 2021
0036 2021 FE 04 CPI 04h
0037 2023 CC 5A 21 CZ LEFT
0038 2026 CA 06 20 JZ KBREAD
0039 2029
0040 2029 FE 05 CPI 05h
0041 202B CA 31 20 JZ EXIT;If Key 5 was
pressed Exit
0042 202E C3 06 20 JMP KBREAD
0043 2031
0044 2031 76 EXIT: HLT
0045 2032
;PORT B has been used by our application for Output .So the A register
has been initialised with the control word 90H
; A ---> 10010000
; The data sent via the control port XX03H .Here XX=00
; The data to be sent to the output port for the SUBROUTINE FRONT
is A0H (10100000) [ Refer to the L293D Pin Configuration]
; The data to be sent to the output port for the SUBROUTINE BACK is
50H(01010000)
;The data to be sent to the output port for the SUBROUTINE RIGHT
is 60H(01100000)
;The data to be sent to the output port for the SUBROUTINE LEFT is
90H(10010000)
;This data is sent via the control port XX02H . Here XX=00
;For each subroutine C has been initialised as a counter, with initial
value of 50 .
;This has to be manipulated during the TESTING PHASE to get the
desired accuracy
0069 2035
0070 2035
0071 2035 .ORG 2100H
0072 2100
0073 2100
0074 2100 FRONT:
0075 2100 ; Save the machine registers by pushing them
inside the stack.
0080 2100 F5 PUSH PSW
0081 2101 C5 PUSH B
0082 2102 00 NOP
0083 2103 D5 PUSH D
0084 2104
0085 2104 3E 90 MVI A,90H ;Control
word
0086 2106 32 03 00 STA 0003H ;Control
Port
0087 2109 0E 50 MVI C,50H ;Counter
value
0088 210B
0089 210B 3E A0 MVI A,0A0H;Output Data
0090 210D 32 02 00 STA 0002H ;Data transferred
to the 8255
;Once a value is set at PORT B wait till the counter reduces to Zero
;Reset the PORT B after the work is done