⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 自编isp测试.asm

📁 关于isp的一个测试程序
💻 ASM
字号:
/************************************************************************/
/**************************     isp测时程序    **************************/
/**************************    wxn 2005-6-11   **************************/
/************************************************************************/

MEM_TOP        EQU    2000H    ;use for 8KB code memory devices

INIT:
    ACALL    I_WDT        ;
    ANL    91H,#0FCH    ;RxD = quasi-bi
    ORL    92H,#01H    ;TxD = push-pull
    MOV    P1,#0FFH    ;

	MOV    TMOD,#20H    ;8-bit auto-reload mode
	ANL    0BAH,#0FAH
	CLR    A
	MOV    0BDH,A
    MOV    SCON,#50H    ;init UART 8-bit variable, TI=0 RI=0
	MOV    0BEH,#0F0H
	MOV    0BFH,#02H
	MOV    0BDH,#03H

QRZ:    
	ACALL    ECHO        ;wait until character is rcv'd & get it
    CJNE    A,#'U',QRZ    ;check to see if uppercase "U"
W1:	ACALL    CO

LCMD:
    MOV    R5,#0    ;begin record... zero checksum
    ACALL    ECHO        ;get first char and echo
	CJNE    A,#':',W1    ;record starts with ':' char
    ACALL    GET2        ;get the number of bytes in record
    MOV    33H,35H    ;and save
    ACALL    GET2        ;get MSB of load address
    MOV    31H,35H    ;and save
    ACALL    GET2        ;get LSB of load address
    MOV    30H,35H    ;and save it
    ACALL    GET2        ;get record type
    MOV    34H,35H    ;and save it
    MOV    A,33H    ;else, more than
    MOV    R2,A    
    JZ    EOR        ;zero data bytes ?
    MOV    R1,#80H    ;pointer for data bytes
LDATA:    ACALL    GET2        ;get data byte
    MOV    @R1,35H    ;store it
    INC    R1        ;and bump up the pointer    
    DJNZ    R2,LDATA    ;repeat if more bytes in record
EOR:
    MOV    A,R5        ;
    MOV    R4,A        ;save calculated checksum
    ACALL    GET2        ;get the checksum byte
    MOV    A,R4        ;and compare with calculated checksum byte
    CJNE    A,35H,CHKERR    ;recv'd & calc'd chksums match ?
    MOV    R1,#80H    ;pointer for data
;    AJMP    PROCESS        ;YES, process command

	MOV    A,#3AH
	ACALL    CO
	MOV    A,33H
	ACALL    CO
	MOV    A,31H
	ACALL    CO
	MOV    A,30H
	ACALL    CO
	MOV    A,34H
	ACALL    CO
	AJMP    LCMD

CHKERR:    MOV    A,#'X'
    AJMP    RSPND1

GET2:    ACALL    ECHO        ;get first char of length
    ACALL    A2HEX        ;convert to hex
    SWAP    A        ;set in high nibble
    MOV    35H,A        ;store in NBYTES
    ACALL    ECHO        ;get second char of length
    ACALL    A2HEX        ;convert to hex
    ORL    35H,A        ;add into NBYTES
    MOV    A,R5        ;get checksum
    CLR    C        ;subtract NBYTES
    SUBB    A,35H        ;from checksum and
    MOV    R5,A        ;store as new checksum
    RET

;***** ASCII to HEX routine *****
;
;This routine accepts an ASCII char in the ACC
;and converts it into the corresponding hex digit.
;The routine checks to see if the char is in the
;range of '0' through '9' or in the range of 'A'
;through 'F'. If not in either range then the ASCII
;char is not a valid hex entry from the operator
;and an error flag is returned true along with the
;original ASCII char returned in the ACC.

A2HEX:
    JNB    ACC.6,HEX1
    ADD    A,#09H
HEX1:    ANL    A,#0FH
    RET

;***** console output routine *****
;
;Outputs character in the ACC to 
;the serial output line.

CO:    ACALL    FD_WDT        ;feed the WDT
    MOV    SBUF,A    ;output char to SIO
    JNB    TI,$        ;wait till xmtr ready
    CLR    TI        ;reset xmtr flag
   RET            ;and done

;***** console input routine *****
;
;Waits until character has been received
;and then returns char in ACC.

CI:    ACALL    FD_WDT        ;feed the WDT
    JNB    RI,CI        ;wait till char
    CLR    RI        ;reset rcvr flag
    MOV    A,SBUF    ;read the char
    RET            ;and done

;***** character echo routine *****
;
;waits until a character is received from
;the console input and echos this character
;to the console output. The received char
;is also passed to the caller in the ACC.

ECHO:    ACALL    CI            ;get char from console 
;    ACALL    CO            ;print the character
    JNB    ACC.6,EXECHO    ;exit if not 4x,5x, or 6x Hex
    CLR    ACC.5            ;convert to upper case
EXECHO:  RET                ;and done

I_WDT:
    MOV    0C1H,#0FFH    ;set to max count
    ORL    0A7H,#0E0H    ;set pre= max
FD_WDT:
    MOV    0C2H,#0A5H    ;
    MOV    0C3H,#5AH     ;    
    RET

RSPND1:
    ACALL    CO        ;send an okay message
    AJMP    DEXIT        ;and done

DEXIT:
    ACALL    CRLF        ;print a CRLF
    JNB    TI,$
    SETB    REN        ;TURN ON UART RECEIVER
    AJMP    LCMD        ;branch to main loop

CRLF:    MOV    A,#0DH
    ACALL    CO
    MOV    A,#0AH
    ACALL    CO
    RET

END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -