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

📄 paulmon.txt

📁 国外一个可根据需要剪裁的51系列单片机的监控程序
💻 TXT
📖 第 1 页 / 共 5 页
字号:

;dnlds7:  = "Errors:"
;dnlds8:  = " bytes unable to write"
;dnlds9:  = " incorrect checksums"
;dnlds10: = " unexpected begin of line"
;dnlds11: = " unexpected hex digits"
;dnlds12: = " unexpected non-hex digits"
;dnlds13: = "No errors detected"



;---------------------------------------------------------;


jump:
	mov	dptr, #prompt8
	acall	pcstr_h
	acall	r6r7todptr
	acall	phex16
	mov	dptr, #prompt4
	acall	pcstr_h
	acall	ghex16
	jb	psw.5, jump3
	jnc	jump2
	ajmp	abort2
jump2:
	acall	dptrtor6r7
jump3:	acall	newline
	mov	dptr, #runs1
	acall	pcstr_h
	acall	r6r7todptr

jump_doit:  ;jump to user code @dptr (this used by run command also)
	clr	a
	mov	psw, a
	mov	b, a
	mov	r0, #7
jditclr:mov	@r0, a		;clear r7 to r1
	djnz	r0, jditclr	;clear r0
	mov	sp, #8		;start w/ sp=7, like a real reset
	push	acc		;unlike a real reset, push 0000
	push	acc		;in case they end with a RET
	jmp	@a+dptr


;---------------------------------------------------------;

dump:	
	mov	r2, #16		;number of lines to print
	acall	newline2
dump1:	acall	r6r7todptr
	acall	phex16		;tell 'em the memory location
	mov	a,#':'
	acall	cout_sp
	mov	r3, #16		;r3 counts # of bytes to print
	acall	r6r7todptr
dump2:	clr	a
	movc	a, @a+dptr
	inc	dptr
	acall	phex		;print each byte in hex
	acall	space
	djnz	r3, dump2
	acall	dspace		;print a couple extra space
	mov	r3, #16
	acall	r6r7todptr
dump3:	clr	a
	movc	a, @a+dptr
	inc	dptr
	anl	a, #01111111b	;avoid unprintable characters
	cjne	a, #127, dump3b
	clr	a		;avoid 127/255 (delete/rubout) char
dump3b: add	a, #224
	jc	dump4
	clr	a		;avoid control characters
dump4:	add	a, #32
	acall	cout
	djnz	r3, dump3
	acall	newline
	acall	line_dly
	acall	dptrtor6r7
	acall	esc
	jc	dump5
	djnz	r2, dump1	;loop back up to print next line
dump5:	ajmp	newline

;---------------------------------------------------------;

edit:	   ;edit external ram...
	mov	dptr, #edits1
	acall	pcstr_h
	acall	r6r7todptr
edit1:	acall	phex16
	mov	a,#':'
	acall	cout_sp
	mov	a,#'('
	acall	cout
	acall	dptrtor6r7
	clr	a
	movc	a, @a+dptr
	acall	phex
	mov	dptr,#prompt10
	acall	pcstr_h
	acall	ghex
	jb	psw.5,edit2
	jc	edit2
	acall	r6r7todptr
	lcall	smart_wr
	acall	newline
	acall	r6r7todptr
	inc	dptr
	acall	dptrtor6r7
	ajmp	edit1
edit2:	mov	dptr,#edits2
	ajmp	pcstr_h

;---------------------------------------------------------;

dir:
	mov	dptr, #prompt9
	acall	pcstr_h
	mov	r0, #21
dir0a:	acall	space
	djnz	r0, dir0a
	;mov	dptr, #prompt9b
	acall	pcstr_h

	mov	dph, #(bmem >> 8)
dir1:	acall	find		;find the next program in memory
	jc	dir2
dir_end:ajmp	newline		;we're done if no more found
dir2:
	acall	dspace
	mov	dpl, #32	;print its name
	acall	pstr
	mov	dpl, #32	;how long is the name
	acall	lenstr
	mov	a, #33
	clr	c
	subb	a, r0
	mov	r0, a
	mov	a, #' '		;print the right # of spaces
dir3:	acall	cout
	djnz	r0, dir3
	mov	dpl, #0
	acall	phex16		;print the memory location
	mov	r0, #6
	mov	a, #' '
dir4:	acall	cout
	djnz	r0, dir4
	mov	dpl, #4		;now figure out what type it is
	clr	a
	movc	a, @a+dptr
	mov	r2, dph		;save this, we're inside a search

dir5:	cjne	a, #254, dir5b
	mov	dptr, #type1	;it's an external command
	sjmp	dir7
dir5b:	cjne	a, #253, dir5c
dir5bb: mov	dptr, #type4	;it's a startup routine
	sjmp	dir7
dir5c:	cjne	a, #35, dir5d
	mov	dptr, #type2	;it's an ordinary program
	sjmp	dir7
dir5d:	cjne	a, #249, dir5e
	sjmp	dir5bb
dir5e:
dir6:	mov	dptr, #type5	;who knows what the hell it is

dir7:	acall	pcstr_h		   ;print out the type
	mov	dph, r2		;go back and find the next one
	acall	newline
	mov	a, #(emem >> 8)
	cjne	a, dph, dir8	;did we just print the last one?
	ajmp	dir_end
dir8:	inc	dph
	mov	a, dph
	cjne	a, #((emem+1) >> 8) & 255, dir1
	ajmp	dir_end


;type1=Ext Command
;type4=Startup
;type2=Program
;type5=???

;---------------------------------------------------------;


run:   
	acall	newline2
	mov	r2, #255	;first print the menu, count items
	mov	dptr, #bmem
	dec	dph
run2:	inc	dph
	mov	a, dph
	cjne	a, #((emem+1) >> 8) & 255, run2b
	sjmp	run3
run2b:	acall	find
	jnc	run3		;have we found 'em all??
	mov	dpl, #4
	clr	a
	movc	a, @a+dptr
	orl	a, #00000011b
	cpl	a
	jz	run2		;this one doesn't run... find next
	acall	dspace
	inc	r2
	mov	a, #'A'		;print the key to press
	add	a, r2
	acall	cout_sp
	acall	dash_sp
	mov	dpl, #32
	acall	pstr		;and the command name
	acall	newline
	ajmp	run2		;and continue doing this
run3:	cjne	r2, #255, run4	;are there any to run??
	mov	dptr, #prompt5
	ajmp	pcstr_h
run4:	mov	dptr, #prompt3	;ask the big question!
	acall	pcstr_h
	mov	a, #'A'
	acall	cout
	acall	dash
	mov	a, #'A'		;such user friendliness...
	add	a, r2		;even tell 'em the choices
	acall	cout
	mov	dptr, #prompt4
	acall	pcstr_h
	acall	cin_filter_h
	cjne	a, #27, run4aa	;they they hit <ESC>
	ajmp	newline
run4aa: mov	r3, a
	mov	a, #31
	clr	c
	subb	a, r2
	mov	a, r3
	jc	run4a
	acall	upper
run4a:	acall	cout
	mov	r3, a
	acall	newline
	;check to see if it's under 32, if so convert to uppercase
	mov	a, r3
	add	a, #(256 - 'A')
	jnc	run4		;if they typed less than 'A'
	mov	r3, a		;R3 has the number they typed
	mov	a, r2		;A=R2 has the maximum number
	clr	c
	subb	a, r3
	jc	run4		;if they typed over the max
	inc	r3
	mov	dptr, #bmem
	dec	dph
run5:	inc	dph
	mov	a, dph
	cjne	a, #((emem+1) >> 8) & 255, run5b
	sjmp	run8
run5b:	acall	find
	jnc	run8		;Shouldn't ever do this jump!
	mov	dpl, #4
	clr	a
	movc	a, @a+dptr
	orl	a, #00000011b
	cpl	a
	jz	run5		;this one doesn't run... find next
	djnz	r3, run5	;count til we find the one they want
	acall	newline
	mov	dpl, #64
	ajmp	jump_doit
run8:	ret

;---------------------------------------------------------;

help:
	mov	dptr, #help1txt
	acall	pcstr_h
	mov	r4, #help_key
	mov	dptr, #help_cmd
	acall	help2
	mov	r4, #dir_key
	;mov	 dptr, #dir_cmd
	acall	help2
	mov	r4, #run_key
	;mov	 dptr, #run_cmd
	acall	help2
	mov	r4, #dnld_key
	;mov	 dptr, #dnld_cmd
	acall	help2
	mov	r4, #upld_key
	;mov	 dptr, #upld_cmd
	acall	help2
	mov	r4, #nloc_key
	;mov	 dptr, #nloc_cmd
	acall	help2
	mov	r4, #jump_key
	;mov	 dptr, #jump_cmd
	acall	help2
	mov	r4, #dump_key
	;mov	 dptr, #dump_cmd
	acall	help2
	mov	r4, #intm_key
	;mov	dptr, #intm_cmd
	acall	help2
	mov	r4, #edit_key
	;mov	 dptr, #edit_cmd
	acall	help2
	mov	r4, #clrm_key
	;mov	 dptr, #clrm_cmd
	acall	help2
	mov	a, #has_flash
	jz	help_skerfm
	mov	r4, #erfr_key
	;mov	 dptr, #erfr_cmd
	acall	help2
help_skerfm:
	mov	dptr, #help2txt
	acall	pcstr_h
	mov	dptr, #bmem
help3:	acall	find
	jnc	help4
	mov	dpl, #4
	clr	a
	movc	a,@a+dptr
	cjne	a, #254, help3a	   ;only FE is an ext command
	acall	dspace
	inc	dpl
	clr	a
	movc	a,@a+dptr
	acall	cout
	acall	dash_sp
	mov	dpl, #32
	acall	pstr
	acall	newline
help3a: inc	dph
	mov	a, dph
	cjne	a, #((emem+1) >> 8) & 255, help3
help4:	
	ajmp	newline

help2:				;print 11 standard lines
	acall	dspace		;given key in R4 and name in dptr
	mov	a, r4
	acall	cout
	acall	dash_sp
	acall	pcstr_h
	ajmp	newline

;---------------------------------------------------------;

upld:

	acall	get_mem
	;assume we've got the beginning address in r3/r2
	;and the final address in r5/r4 (r4=lsb)...

	;print out what we'll be doing
	mov	dptr, #uplds3
	acall	pcstr_h
	mov	a, r3
	acall	phex
	mov	a, r2
	acall	phex
	;mov	 dptr, #uplds4
	acall	pcstr_h
	mov	a, r5
	acall	phex
	mov	a, r4
	acall	phex
	acall	newline

	;need to adjust end location by 1...
	mov	dph, r5
	mov	dpl, r4
	inc	dptr
	mov	r4, dpl
	mov	r5, dph

	mov	dptr, #prompt7
	acall	pcstr_h
	acall	cin
	cjne	a, #27, upld2e
	ajmp	abort_it
upld2e: acall	newline
	mov	dpl, r2
	mov	dph, r3

upld3:	mov	a, r4		;how many more bytes to output??
	clr	c
	subb	a, dpl
	mov	r2, a
	mov	a, r5
	subb	a, dph
	jnz	upld4		;if >256 left, then do next 16
	mov	a, r2
	jz	upld7		;if we're all done
	anl	a, #11110000b
	jnz	upld4		;if >= 16 left, then do next 16
	sjmp	upld5		;otherwise just finish it off
upld4:	mov	r2, #16
upld5:	mov	a, #':'		;begin the line
	acall	cout
	mov	a, r2
	acall	phex		;output # of data bytes
	acall	phex16		;output memory location
	mov	a, dph
	add	a, dpl
	add	a, r2
	mov	r3, a		;r3 will become checksum
	clr	a
	acall	phex		;output 00 code for data
upld6:	clr	a
	movc	a, @a+dptr
	acall	phex		;output each byte
	add	a, r3
	mov	r3, a
	inc	dptr
	djnz	r2, upld6	;do however many bytes we need
	mov	a, r3
	cpl	a
	inc	a
	acall	phex		;and finally the checksum
	acall	newline
	acall	line_dly
	acall	esc
	jnc	upld3		;keep working if no esc pressed
	sjmp	abort_it
upld7:	mov	a, #':'
	acall	cout
	clr	a
	acall	phex
	acall	phex
	acall	phex
	inc	a
	acall	phex
	mov	a, #255
	acall	phex
upld8:	ajmp	newline2


line_dly: ;a brief delay between line while uploading, so the
	;receiving host can be slow (i.e. most windows software)
	mov	a, r0
	push	acc
	mov	r0, #line_delay*2
line_d2:mov	a, th0		;get baud rate const
line_d3:inc	a
	nop
	nop
	jnz	line_d3
	djnz	r0, line_d2
	pop	acc
	mov	r0, a
	ret

;---------------------------------------------------------;

get_mem:     ;this thing gets the begin and end locations for
	     ;a few commands.  If an esc or enter w/ no input,
	     ;it pops it's own return and returns to the menu
	     ;(nasty programming, but we need tight code for 4k rom)
	acall	newline2
	mov	dptr, #beg_str
	acall	pcstr_h
	acall	ghex16
	jc	pop_it
	jb	psw.5, pop_it
	push	dph
	push	dpl
	acall	newline
	mov	dptr, #end_str
	acall	pcstr_h
	acall	ghex16
	mov	r5, dph
	mov	r4, dpl
	pop	acc
	mov	r2, a
	pop	acc
	mov	r3, a
	jc	pop_it
	jb	psw.5, pop_it
	ajmp	newline

pop_it: pop	acc
	pop	acc
abort_it:
	acall	newline
abort2: mov	dptr, #abort
	ajmp	pcstr_h


clrm:
	acall	get_mem
	mov	dptr, #sure
	acall	pcstr_h
	acall	cin_filter_h
	acall	upper
	cjne	a, #'Y', abort_it
	acall	newline2
     ;now we actually do it

clrm2:	mov	dph, r3
	mov	dpl, r2
clrm3:	clr	a
	lcall	smart_wr
	mov	a, r5
	cjne	a, dph, clrm4
	mov	a, r4
	cjne	a, dpl, clrm4
	ret
clrm4:	inc	dptr
	sjmp	clrm3

⌨️ 快捷键说明

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