# Help me

I'm a mechanics student who studying assembly language. I have a problem
even though, i have program, I don't know how to draw for flow chart for this program I read instructions i don't got the concept. That weird because i got first program. If i have flow chart concept i may be write new program or can modify old one. Please draw for me. I know the that is tread question but i am in hurry for flowchart.......please help me
thank in advance

#INCLUDE
#DEFINE SPD_UP PORTA,0
#DEFINE SPD_DOWN PORTA,1

SPD EQU H'20' ;STORE ACTUAL SPEED
TEMP4 EQU H'21' ;TEMP4 BUFFER
TEMP3 EQU H'22' ;TEMP3 BUFFER
REF_L EQU H'23' ;STORE LOWER LINIT OF SPEED
REF_H EQU H'24' ;STORE UPPER LIMIT OF SPEED
COUNTER EQU H'25' ;COUNTER
AVG_SPD EQU H'26' ;AVERAGE VALUE OF 6 SPED DATA
OUTER EQU H'27' ;OUTER COUNTER
INNER EQU H'28' ;INNER COUNTER
TEMP1 EQU H'29' ;TEMP1 BUFFER
TEMP2 EQU H'30' ;TEMP2 BUTTER

;*************************************************************
; MAIN PROGRAM
;*************************************************************
ORG H'00' ;ASSIGN START MEMORY ADDRESS
GOTO START ;GO START
START CALL SETTINGS ;RUN THE SETTINGS SUB-ROUTINE
REPEAT CALL SPD_READINGS ;REPEAT & RUN SPD READINGS SUB-ROUTINE
CALL SPD_CHECK ;RUN SPD_CHECK SUBROUTINE
GOTO REPEAT ;GO TO REPEAT
;*************************************************************
; CONFIGURATIONS
;*************************************************************
SETTINGS
CLRF ANSEL ; TO SET FROM DEFAULT ANALOG I/O TO DIGITAL I/O
BSF STATUS,RP0 ; SELECT BANK1
CLRF TRISA ; SET PORTA AS OUTPUT
MOVLW B'11110111' ; SET PORT B BIT 3 AS OUTPUT
MOVWF TRISB ; SET REST OF PORTB BITS AS INPUT
BCF STATUS,RP1 ; SELECT BANK
BCF STATUS,RP0 ; SELECT BANK 0
CLRF PORTA ; ERASE DATA IN SPD_UP AND SPD_DOWN
MOVLW D'70' ; D'70' lateral number to W
MOVWF SPD ; SET SPD AT 43KM/H
RETURN

;********************************************************************************
;*SUM UP THE 6 DIFFERENT SPD READINGS AND STORE THE RESULTS IN SPD_MSB & SPD_LSB*
;********************************************************************************
SPD_READINGS
MOVLW D'05'
MOVWF COUNTER ; SET THE LOOP TO ADD THE SPD 6 TIMES
CLRF TEMP4 ; CLEAR TEMP4
MOVF SPD,W ; READ SPD FROM H'20' AND STORE IN W
MOVWF TEMP3 ; STORE THE READING AT SPD_LSB
LOOP CALL DELAY ; CALL FOR 1OOMS DELAY
MOVF SPD,W ; READ NEW SPD FROM H'20'
ADDWF TEMP3,F ; ADD NEW SPD TO SPD_LSB
BTFSC STATUS,C ; IF C = 0, SPD_LSB =< 255
INCF TEMP4,F ; IF C = 1, SPD_LSB > 255
DECFSZ COUNTER,F ; DECREASE COUNTER, TO
GOTO LOOP
;****************************************************************
; CALCULATION OF AVERAGE SPEED
;****************************************************************
CLRF AVG_SPD
MINUS6 MOVLW D'06' ; STORE D'06' TO W
SUBWF TEMP3,F ; MINUS SPD_LSB WITH 6
BTFSS STATUS,C ; IF C = 0, SPD_LSB >= 6
GOTO MSB ; IF C = 1, SPD_LSB < 6
INCF AVG_SPD ; INCREASE AVG_SPD
GOTO MINUS6 ; GOTO MINUS6
MSB MOVF TEMP4,W ; READ SPD_MSB FROM H'21' AND STORE IN W
BTFSS STATUS,Z ; CHECK IF SPD_MSB IS ZERO
GOTO LSB ; GOTO LSB_255 IF SPD_MSB IS NOT ZERO
RETURN ; RETURN PROGRAM
LSB DECF TEMP4 ; DECREASE SPD_MSB
MOVLW D'255' ; STORE D'255' INTO W
MOVWF TEMP3 ; MOVE D'255' INTO SPD_LSB
GOTO MINUS6
RETURN

;*****************************************************************
; CHECK IF SPD IS AT 60KM/H TO 70KM/H.
;*****************************************************************

SPD_CHECK
MOVLW D'60' ; MOVE LATERAL D'60' TO W
MOVWF REF_L ; SET REFERENCE_L AT 60
MOVLW D'70' ; MOVE LATERAL D'70' TO W
MOVWF REF_H ; SET REFERENCE_H AT 70
MOVF AVG_SPD,W ; READ AVG_SPD FROM H'26' AND STORE IN W
SUBWF REF_L ; MINUS AVG_SPD TO 60
BTFSS STATUS,C ; IF C = 1, AVG_SPD CAN BE =< 60KM/H
GOTO SPD_CHECK2 ; IF C = 0, AVG_SPD IS MORE THAN 60KM/H
BTFSC STATUS,Z ; IF Z = 0, AVG_SPD < 60KM/H. IF Z = 1, AVG_SPD IS = 60KM/H
RETURN ; RETURN TO MAIN WHEN AVG_SPD IS = 60KM/H (WITHIN REQUIREMENT)
INC_SPD BSF SPD_UP ; AVG_SPD IS < 60KM/H, ACTIVATE SPD_UP
BCF SPD_DOWN ; TO ENSURE SPD_DOWN IS NOT SET.
MOVLW D'05' ; STORE D'05' INTO W
ADDWF SPD,F ; INCREASE SPEED
RETURN

SPD_CHECK2
MOVF AVG_SPD,W ; READ AVG_SPD FROM H'26' AND STORE IN W
SUBWF REF_H,W ; MINUS AVG_SPD TO 70
BTFSS STATUS,C ; IF C = 1, AVG_SPD IS < 70KM/H
GOTO REDUCE_SPD
BTFSS STATUS,Z ; IF Z = 0, 60KM/H < AVG_SPD > 70KM/H
RETURN ; RETURN TO MAIN

REDUCE_SPD BSF SPD_DOWN ; ACTIVATE SPD_DOWN
BCF SPD_UP ; ENSURE SPD_UP IS NOT SET
MOVLW D'10' ; MOVE D'20 INTO W
SUBWF SPD,W ; REDUCE SPD BY 10
RETURN

;***********************************************************
; 100MS DELAY SUB-ROUTINE
;***********************************************************

DELAY
MOVLW D'100' ; STORE 100 INTO W
MOVWF OUTER ; STORE 100 INTO OUTER
DELAY2 MOVLW D'124'
MOVWF INNER ; STORE 124 INTO INNER
DELAY1 NOP
DECFSZ INNER ; DECREASE INNER, SKIP IF ZERO
GOTO DELAY1
DECFSZ OUTER ; DECREASE OUTER, SKIP IF ZERO
GOTO DELAY2
RETURN
END
Sign In or Register to comment.

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!