Re: боинг выпустил инструкцию

by nemiga [22 Views] 2019-03-22 02:10:44
In response to: Re: боинг выпустил инструкцию by PisaDrisa, 2019-03-21 19:12:28

Тоже девяностые :-)


;THE PROGRAM FOR "DOOWON" CO.
;FUEL INJECTION SOLENOID VALVE DRIVER
;(C) A.MARTYCHENKO, 1994

ORG 0H
SJMP START
ORG 0BH ;IF TIMER 0 GENERATES AN INTERRUPT,
LJMP IN0 ;THEN GO TO THE LABEL IN0
ORG 1BH ;IF THERE IS AN INTERRUPT FROM THE TIMER1,
LJMP IN1 ;GO TO THE LABEL IN1

;VARIABLES

TT1L EQU 10H
TT1H EQU 11H
TT1U EQU 12H
TT2L EQU 13H
TT2H EQU 14H
TT2U EQU 15H
TT3L EQU 16H
TT3H EQU 17H
TT3U EQU 18H
TT4L EQU 19H
TT4H EQU 1AH
TT4U EQU 1BH
TTL EQU 1CH
TTH EQU 1DH
TTU EQU 1EH
FL0 EQU 1FH
FL1 EQU 20H


START: NOP

;WE USE FOLLOWING

CLR A

;LOW BYTES

MOV TT1L, A ;TT1 IS THE INITIAL (BIG) PULSE
MOV TT2L, A ;TT2 IS 1'S OF THE TAIL
MOV TT3L, A ;TT3 IS 0'S OF THE TAIL
MOV TT4L, A ;TT4 IS THE TAIL'S LENGTH
MOV TTL, A ;TT IS THE VALUE TO BE DISPLAYED ON THE INDICATOR


;UPPER BYTES

MOV TT1U, A ;TT1 IS THE INITIAL (BIG) PULSE
MOV TT2U, A ;TT2 IS 1'S OF THE TAIL
MOV TT3U, A ;TT3 IS 0'S OF THE TAIL
MOV TT4U, A ;TT4 IS THE TAIL'S LENGTH
MOV TTU, A ;TT IS THE VALUE TO BE DISPLAYED ON THE INDICATOR


;BEGIN MAIN PROGRAM

INI: NOP ;COMING FROM THE END
MOV P0, A ;CLEAR PORT0
MOV A, P3 ;READ PORT3
MOV R7, A ;SAVE READ VALUE FOR FURTHER REFERENCE
SUBB A, #1 ;COMPARE WITH 1 (IF FIRST BUTTON PRESSED?)
JZ L1 ;IF SO, JUMP TO THE FIRST BRANCH (DISPLAY TT1 +1000)
MOV A, R7 ;RESTORE READ VALUE
SUBB A, #2 ;COMPARE WITH 2 (IF SECOND BUTTON PRESSED?)
JZ L2 ;IF SO, GO TO THE SECOND BRANCH (DISPLAY TT2 +2000)
MOV A, R7 ;RESTORE
SUBB A, #4 ;IF THE THIRD BUTTON PRESSED?
JZ L3 ;GO TO DISPLAY TT3+3000
MOV A, #8 ;THE FOURTH BUTTON?
JZ L4 ;GO TO TT4+4000
LJMP COMMON ;BYPASS FOUR BRANCHES. "COMMON" LABELS THEIR END
L1: LJMP DISP1
L2: LJMP DISP2
L3: LJMP DISP3
L4: LJMP DISP4

;THIS IS THE FIRST BRANCH

DISP1: NOP ;FROM HERE WE DISPLAY TT1+1000, LIKE 1025 IF TT1=25
CLR C
MOV A, TT1L ;DOING TT1+1000
MOV TT1L, A
ADDC A, #232
MOV A, TT1H
ADDC A, #3
MOV TT1H, A
CLR C

LCALL CONVERT ;"CONVERT" IS A SUBROUTINE CONVERTING TT TO BCD
LCALL SHOW ;"SHOW" IS A SUBRUTINE OF DYNAMIC INDICATION

MOV A, P3 ;READ PORT3
MOV R7, A ;SAVE PORT3 FOR REFERENCE
SUBB A, #32 ;IF PORT3=32 IT MEANS "UP" IS PRESSED
JNZ SKIP1 ;ANOTHER BUTTON WAS PRESSED (OR NONE OF THEM)
MOV A, TT1L ;FROM HERE, TT1 (TWO BYTES) := TT1 + 1
ADD A, #1
MOV TT1L, A
MOV A, TT1H
ADDC A, #0
MOV TT1H, A ;TO HERE
CLR C

LJMP MADE1 ;TO SKIP THE OTHER BRANCH ("DOWN")

SKIP1: NOP ;COME HERE TO CHECK WHETHER "DOWN" WAS PRESSED
CLR C
MOV A, R7 ;RESTORE VALUE OF PORT3
SUBB A, #64 ;PRESSED "DOWN"?
JNZ MADE1 ;NEITHER UP NOR DOWN
MOV A, TT1L ;FROM HERE, TT1 (2BYTES) := TT1 - 1
SUBB A, #1
MOV TT1L, A
MOV A, TT1H
SUBB A, #0
MOV TT1H, A ;TO HERE
CLR C
MADE1: NOP ;THE END OF A BUTTON READING CYCLE
LJMP COMMON ;COMMON IS THE LABEL WHERE ALL FOUR BRANCHES GATHER


;THIS IS THE SECOND BRANCH

DISP2: NOP ;FROM HERE WE DISPLAY TT2+2000, LIKE 2099 IF TT2=99

CLR C
MOV A, TT2L ;DOING TT1+2000
ADDC A, #208 ;2000=07D0H
MOV TT2L, A
MOV A, TT2H
ADDC A, #7
MOV TT2H, A
CLR C

LCALL CONVERT ;"CONVERT" IS A SUBROUTINE CONVERTING TT TO BCD
LCALL SHOW ;"SHOW" IS A SUBRUTINE OF DYNAMIC INDICATION

MOV A, P3 ;READ PORT3
MOV R7, A ;SAVE PORT3 FOR REFERENCE
SUBB A, #32 ;IF PORT3=32 IT MEANS "UP" IS PRESSED
JNZ SKIP2 ;ANOTHER BUTTON WAS PRESSED (OR NONE OF THEM)
MOV A, TT2L
ADD A, #1
MOV TT2L, A
MOV A, TT2H
ADDC A, #0
MOV TT2H, A
CLR C
LJMP MADE2 ;TO SKIP THE OTHER BRANCH ("DOWN")
SKIP2: NOP ;COME HERE TO CHECK WHETHER "DOWN" WAS PRESSED
MOV A, R7 ;RESTORE VALUE OF PORT3
SUBB A, #64 ;PRESSED "DOWN"?
JNZ MADE2 ;NEITHER UP NOR DOWN
MOV A, TT2L
SUBB A, #1
MOV TT2L, A
MOV A, TT2H
SUBB A, #0
MOV TT2H, A
CLR C
MADE2: NOP ;THE END OF A BUTTON READING CYCLE
LJMP COMMON ;COMMON IS THE LABEL WHERE ALL FOUR BRANCHES GATHER



;THIS IS THE THIRD BRANCH

DISP3: NOP ;FROM HERE WE DISPLAY TT3+3000, LIKE 3004 IF TT3=4

CLR C
MOV A, TT3L ;DOING TT1+3000
ADDC A, #184 ;3000=0BB8H
MOV TT3L, A
MOV A, TT3H
ADDC A, #11
MOV TT3H, A
CLR C

LCALL CONVERT ;"CONVERT" IS A SUBROUTINE CONVERTING TT TO BCD
LCALL SHOW ;"SHOW" IS A SUBRUTINE OF DYNAMIC INDICATION

MOV A, P3 ;READ PORT3
MOV R7, A ;SAVE PORT3 FOR REFERENCE
SUBB A, #32 ;IF PORT3=32 IT MEANS "UP" IS PRESSED
JNZ SKIP3 ;ANOTHER BUTTON WAS PRESSED (OR NONE OF THEM)

MOV A, TT3L
ADD A, #1
MOV TT3L, A
MOV A, TT3H
ADDC A, #0
MOV TT3H, A
CLR C

LJMP MADE3 ;TO SKIP THE OTHER BRANCH ("DOWN")
SKIP3: NOP ;COME HERE TO CHECK WHETHER "DOWN" WAS PRESSED
MOV A, R7 ;RESTORE VALUE OF PORT3
SUBB A, #64 ;PRESSED "DOWN"?
JNZ MADE3 ;NEITHER UP NOR DOWN

MOV A, TT3L
SUBB A, #1
MOV TT3L, A
MOV A, TT3H
SUBB A, #0
MOV TT3H, A
CLR C

MADE3: NOP ;THE END OF A BUTTON READING CYCLE
LJMP COMMON ;COMMON IS THE LABEL WHERE ALL FOUR BRANCHES GATHER


;THIS IS THE FOURTH BRANCH

DISP4: NOP ;FROM HERE WE DISPLAY TT4+4000, LIKE 4017 IF TT1 =17

CLR C
MOV A, TT4L ;DOING TT1+4000
ADDC A, #160 ;4000=0FA0H
MOV TT4L, A
MOV A, TT3H
ADDC A, #15
MOV TT4H, A
CLR C


LCALL CONVERT ;"CONVERT" IS A SUBROUTINE CONVERTING TT TO BCD
LCALL SHOW ;"SHOW" IS A SUBRUTINE OF DYNAMIC INDICATION

MOV A, P3 ;READ PORT3
MOV R7, A ;SAVE PORT3 FOR REFERENCE
SUBB A, #32 ;IF PORT3=32 IT MEANS "UP" IS PRESSED
JNZ SKIP4 ;ANOTHER BUTTON WAS PRESSED (OR NONE OF THEM)

MOV A, TT4L
ADD A, #1
MOV TT4L, A
MOV A, TT4H
ADDC A, #0
MOV TT4H, A
CLR C

LJMP MADE4 ;TO SKIP THE OTHER BRANCH ("DOWN")
SKIP4: NOP ;COME HERE TO CHECK WHETHER "DOWN" WAS PRESSED
MOV A, R7 ;RESTORE VALUE OF PORT3
SUBB A, #64 ;PRESSED "DOWN"?
JNZ MADE4 ;NEITHER UP NOR DOWN

MOV A, TT4L
SUBB A, #1
MOV TT4L, A
MOV A, TT4H
SUBB A, #0
MOV TT4H, A
CLR C

MADE4: NOP ;THE END OF A BUTTON READING CYCLE
LJMP COMMON ;COMMON IS THE LABEL WHERE ALL FOUR BRANCHES GATHER

;THE END OF BUTTON SERVICE
L5: LJMP INI

COMMON: MOV A, P1 ;READ P1 (BYNARY SIGNAL FROM ENC., NOT GRAY!!!)
SUBB A, #23 ;INJECTION DEFAULT IS TIMED AT -23 BTDC
JNZ L5 ;IF NOT, RETURN TO THE BEGINNING AND ENDLESS LOOPING
NOP ;IF YES, BEGIN TO MAKE A PULSE

;HERE WE FORM A PULSE SHAPED ACCORDINGLY TO THE SETTING OF TT1-T4

LOAD TIMER0, TT1 ;SET TIMER 0 AS TIMER. SET ITS VALUE TT1

LOOP: NOP ;ENDLESS LOOP AWAITING AN INTERRUPT FROM THE TIMER 0
MOV A, #8 ;SET "1" TO THE SOLENOID
MOV P0, A ;OUTPUT "1"
MOV A, #0
MOV FL0, A ;FL0 SERVES AS A FLAG. NOW FLAG=0
MOV FL1, A ;FL1 DOES AS WELL
LJMP LOOP ;WHEN TIMER 0 GENERATES AN INT., WE CONTINUE

L6: LJMP INI

IN0: NOP ;AN INTERRUPT FROM THE TIMER0 CAME!
MOV A, FL0 ;FLAG CHECK
JNZ L6 ;IF R6 ISN'T 0, IT IS NOW THE SECOND TIME WE ARE
;INTERRUPTED FROM THE TIMER0. SO, WE GO TO THE BEGINNING
MOV A, #1 ;BUT, IF IT WAS THE FIRST TIME, LET'S SET THE FLAG
MOV FL0, A ;IN ORDER NOT TO PASS THIS BRANCH AGAIN

LOAD TIMER0, TT4 ;AND, LET'S SET THE TAIL LENGTH. THE PULSE WILL BE OVER
;WHEN THE TIMER0 SETS AN INTERRUPT FOR THE SECOND TIME

SETB IE.7 ;ENABLE INTERRUPTS

IN1: NOP
MOV A, FL1
JZ PASS

LOAD TIMER1, TT3 ;SET TIMER1 AS TIMER. SET ITS VALUE TT3
SETB IE.7 ;ENABLE INTERRUPTS
LJMP FINE

PASS: NOP

LOAD TIMER1, TT2 ;SET TIMER1 AS TIMER WITH THE TIME=T2
SETB IE.7 ;ENABLE INTERRUPTS

FINE: NOP

;THE TIMER1 WILL BE SET EITHER TT3 OR TT2 REPEATEDLY

MOV A, FL1 ;THOSE OPERATORS
JZ ZERO ;ARE SETTING THE FLAG FL1
MOV A, #0 ;INTO "0" IF IT WAS "1"
MOV FL1, A ;AND INTO "1" IF IT WAS "0"
LJMP ALL ;THE TIMER1 IS LOADED WITH TT3 OR TT2
ZERO: NOP ;IN ODD AND EVEN CALLS RESPECTIVELY
MOV A, #1 ;THEN THE CURRENT FLAG SERVES AS THE VARIABLE
MOV FL1, A ;APPEARING FROM THE OUTPUT PORT
ALL: NOP
MOV A, FL1
MOV P0, A ;OUTPUT EITHER "0" OR "1" DEPENDING UPON FOR ODD OR
;TIME THE TIMER1 INTERRUPT IS EVOKED

;THIS IS THE END OF THE PROGRAM. THERE IS NOTHING TO DO ANY MORE ABOUT IT
;I THINK THAT THIS JOB IS JUST FINE.

Reply | Private Reply | Sync | Thread | Like | Useful | Dislike | Trash | Report