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

📄 pm2_mp3.asm

📁 A MP3 Player Source Code, Enjoy it!
💻 ASM
📖 第 1 页 / 共 5 页
字号:
	mov	r4, #255
	anl	a, #00001111b
	ret
gnn2:	mov	r4, #0
	inc	dptr
	swap	a
	anl	a, #00001111b
	ret


;---------------------------------------------------------;
;							  ;
;	 Here begins the data tables and strings	  ;
;							  ;
;---------------------------------------------------------;

;this is the dictionary of 128 words used by pcstr.

words:
	.db	0x82, 0x90, 0xE8, 0x23, 0x86, 0x05, 0x4C, 0xF8
	.db	0x44, 0xB3, 0xB0, 0xB1, 0x48, 0x5F, 0xF0, 0x11
	.db	0x7F, 0xA0, 0x15, 0x7F, 0x1C, 0x2E, 0xD1, 0x40
	.db	0x5A, 0x50, 0xF1, 0x03, 0xBF, 0xBA, 0x0C, 0x2F
	.db	0x96, 0x01, 0x8D, 0x3F, 0x95, 0x38, 0x0D, 0x6F
	.db	0x5F, 0x12, 0x07, 0x71, 0x0E, 0x56, 0x2F, 0x48
	.db	0x3B, 0x62, 0x58, 0x20, 0x1F, 0x76, 0x70, 0x32
	.db	0x24, 0x40, 0xB8, 0x40, 0xE1, 0x61, 0x8F, 0x01
	.db	0x34, 0x0B, 0xCA, 0x89, 0xD3, 0xC0, 0xA3, 0xB9
	.db	0x58, 0x80, 0x04, 0xF8, 0x02, 0x85, 0x60, 0x25
	.db	0x91, 0xF0, 0x92, 0x73, 0x1F, 0x10, 0x7F, 0x12
	.db	0x54, 0x93, 0x10, 0x44, 0x48, 0x07, 0xD1, 0x26
	.db	0x56, 0x4F, 0xD0, 0xF6, 0x64, 0x72, 0xE0, 0xB8
	.db	0x3B, 0xD5, 0xF0, 0x16, 0x4F, 0x56, 0x30, 0x6F
	.db	0x48, 0x02, 0x5F, 0xA8, 0x20, 0x1F, 0x01, 0x76
	.db	0x30, 0xD5, 0x60, 0x25, 0x41, 0xA4, 0x2C, 0x60
	.db	0x05, 0x6F, 0x01, 0x3F, 0x26, 0x1F, 0x30, 0x07
	.db	0x8E, 0x1D, 0xF0, 0x63, 0x99, 0xF0, 0x42, 0xB8
	.db	0x20, 0x1F, 0x23, 0x30, 0x02, 0x7A, 0xD1, 0x60
	.db	0x2F, 0xF0, 0xF6, 0x05, 0x8F, 0x93, 0x1A, 0x50
	.db	0x28, 0xF0, 0x82, 0x04, 0x6F, 0xA3, 0x0D, 0x3F
	.db	0x1F, 0x51, 0x40, 0x23, 0x01, 0x3E, 0x05, 0x43
	.db	0x01, 0x7A, 0x01, 0x17, 0x64, 0x93, 0x30, 0x2A
	.db	0x08, 0x8C, 0x24, 0x30, 0x99, 0xB0, 0xF3, 0x19
	.db	0x60, 0x25, 0x41, 0x35, 0x09, 0x8E, 0xCB, 0x19
	.db	0x12, 0x30, 0x05, 0x1F, 0x31, 0x1D, 0x04, 0x14
	.db	0x4F, 0x76, 0x12, 0x04, 0xAB, 0x27, 0x90, 0x56
	.db	0x01, 0x2F, 0xA8, 0xD5, 0xF0, 0xAA, 0x26, 0x20
	.db	0x5F, 0x1C, 0xF0, 0xF3, 0x61, 0xFE, 0x01, 0x41
	.db	0x73, 0x01, 0x27, 0xC1, 0xC0, 0x84, 0x8F, 0xD6
	.db	0x01, 0x87, 0x70, 0x56, 0x4F, 0x19, 0x70, 0x1F
	.db	0xA8, 0xD9, 0x90, 0x76, 0x02, 0x17, 0x43, 0xFE
	.db	0x01, 0xC1, 0x84, 0x0B, 0x15, 0x7F, 0x02, 0x8B
	.db	0x14, 0x30, 0x8F, 0x63, 0x39, 0x6F, 0x19, 0xF0
	.db	0x11, 0xC9, 0x10, 0x6D, 0x02, 0x3F, 0x91, 0x09
	.db	0x7A, 0x41, 0xD0, 0xBA, 0x0C, 0x1D, 0x39, 0x5F
	.db	0x07, 0xF2, 0x11, 0x17, 0x20, 0x41, 0x6B, 0x35
	.db	0x09, 0xF7, 0x75, 0x12, 0x0B, 0xA7, 0xCC, 0x48
	.db	0x02, 0x3F, 0x64, 0x12, 0xA0, 0x0C, 0x27, 0xE3
	.db	0x9F, 0xC0, 0x14, 0x77, 0x70, 0x11, 0x40, 0x71
	.db	0x21, 0xC0, 0x68, 0x25, 0x41, 0xF0, 0x62, 0x7F
	.db	0xD1, 0xD0, 0x21, 0xE1, 0x62, 0x58, 0xB0, 0xF3
	.db	0x05, 0x1F, 0x73, 0x30, 0x77, 0xB1, 0x6F, 0x19
	.db	0xE0, 0x19, 0x43, 0xE0, 0x58, 0x2F, 0xF6, 0xA4
	.db	0x14, 0xD0, 0x23, 0x03, 0xFE, 0x31, 0xF5, 0x14
	.db	0x30, 0x99, 0xF8, 0x03, 0x3F, 0x64, 0x22, 0x51
	.db	0x60, 0x25, 0x41, 0x2F, 0xE3, 0x01, 0x56, 0x27
	.db	0x93, 0x09, 0xFE, 0x11, 0xFE, 0x79, 0xBA, 0x60
	.db	0x75, 0x42, 0xEA, 0x62, 0x58, 0xA0, 0xE5, 0x1F
	.db	0x53, 0x4F, 0xD1, 0xC0, 0xA3, 0x09, 0x42, 0x53
	.db	0xF7, 0x12, 0x04, 0x62, 0x1B, 0x30, 0xF5, 0x05
	.db	0xF7, 0x69, 0x0C, 0x35, 0x1B, 0x70, 0x82, 0x2F
	.db	0x2F, 0x14, 0x4F, 0x51, 0xC0, 0x64, 0x25, 0x00

;STR

logon1: .db	"Welcome",128,148,"2 v2.1 (MP3 Player Version)",13
	.db	"by",31,248,31,254,13,13
	.db	"http://www.pjrc.com/tech/mp3/",13,13
	.db	31,228," 'S'",128,160,188,143,13,14
abort:	.db	" ",31,158,31,160,"!",13,14
prompt1:.db	148,"2_MP3 Loc:",0
prompt2:.db	" >", 160	;must follow after prompt1
prompt3:.db	134,202,130,'(',0
prompt4:.db	"),",149,140,128,200,": ",0
prompt5:.db	31,151,130,195,"s",199,166,131,","
	.db	186," JUMP",128,134,161,"r",130,13,14
prompt6:.db	13,13,31,135,131,129,": ",0
prompt7:.db	31,228,251," key: ",0
prompt8:.db	13,13,31,136,128,131,129," (",0
prompt9:.db	13,13,31,130,31,253,0
prompt9b:.db	 31,129,32,32,32,32,32,31,201,14	;must follow prompt9
prompt10:.db	") ",31,135,31,178,": ",0
beg_str:.db	"First",31,129,": ",0
end_str:.db	"Last",31,129,":",32,32,0
sure:	.db	31,185,161," sure?",0
edits1: .db	13,13,31,156,154,146,",",140,128,200,14
edits2: .db	"  ",31,156,193,",",142,129,247,13,14
dnlds1: .db	13,13,31,159," ascii",249,150,31,152,132,137
	.db	",",149,140,128,160,13,14
dnlds2: .db	13,31,138,160,"ed",13,14
dnlds3: .db	13,31,138,193,"d",13,14
dnlds4: .db	"Summary:",14
dnlds5: .db	" ",198,"s",145,"d",14
dnlds6a:.db	" ",139,145,"d",14
dnlds6b:.db	" ",139," written",14
dnlds7: .db	31,155,":",14
dnlds8: .db	" ",139," unable",128," write",14
dnlds9: .db	32,32,"bad",245,"s",14
dnlds10:.db	" ",133,159,150,198,14
dnlds11:.db	" ",133,132,157,14
dnlds12:.db	" ",133," non",132,157,14
dnlds13:.db	31,151,155," detected",13,14
runs1:	.db	13,134,"ning",130,":",13,14
uplds3: .db	13,13,"Sending",31,152,132,137,172,32,32,0
uplds4: .db	" ",128,32,32,0		;must follow uplds3
help1txt:.db	13,13,"Standard",31,158,"s",14
help2txt:.db	31,218,31,244,"ed",31,158,"s",14
type1:	.db	31,154,158,0
type2:	.db	31,130,0
type4:	.db	31,143,31,226,31,170,0
type5:	.db	"???",0
help_cmd2:.db	31,215,0
help_cmd: .db	31,142,215,209,0	;these 11 _cmd string must be in order
dir_cmd:  .db	31,209,130,"s",0
run_cmd:  .db	31,134,130,0
dnld_cmd: .db	31,138,0
upld_cmd: .db	31,147,0
nloc_cmd: .db	31,135,129,0
jump_cmd: .db	31,136,128,131,129,0
dump_cmd: .db	31,132,219,154,131,0
intm_cmd: .db	31,132,219,192,131,0
edit_cmd: .db	31,156,154,146,0
clrm_cmd: .db	31,237,131,0
erfr_cmd: .db	31,203,153,144,0
erfr_ok:  .db	31,153,144,203,'d',13,14
erfr_err: .db	31,133,155,13,14





;-----------------------------------------------------------
;  MP3 player specific functions
;-----------------------------------------------------------


	.org	0x0FC0

;to call a function in either bank, code should call here
;with the function's address in DPTR, and the bank in carry.
;This allows either bank to call an ordinary callable function
;is either bank, but it is slow and requires 5 bytes of stack
;space instead of the usual 2 bytes

call_function:
	push	selected_bank_byte	; remember which bank we're in now
	mov	flash_a16_pin, c	; switch to the target bank
	mov	selected_bank_bit, c
	mov	a, #(ret_function & 255) ;when the function returns, return
	push	acc			; to "ret_function" so we can restore
	mov	a, #(ret_function >> 8) ; the selected bank and properly
	push	acc			; return to the caller
	clr	a
	jmp	@a+dptr			; run the function

rst_devices:
	clr	reset_pin
	mov	r0, #200
	djnz	r0, *
	setb	reset_pin
	ret

ret_function:
	pop	selected_bank_byte
	mov	c, selected_bank_bit
	mov	flash_a16_pin, c
	ret

	.org	0x0FE0

;use this do call library functions in bank1 from bank0, where
;the library function is coded specifically to return properly
;This allows library functions located in bank1 to be called
;from the main program, located in bank 0, with minimal overhead.
;The library functions have to be coded to JMP to "ret_bank1_lib".

call_bank1_lib:
	setb	selected_bank_bit
	setb	flash_a16_pin
	clr	a
	jmp	@a+dptr			; run the function


	;set to bank 1
set_bank1:
	setb	c
set_bank:
	mov	selected_bank_bit, c
	mov	flash_a16_pin, c
	ret


;library functions in bank1, intended to be called from bank0
;will jump here to return to their caller

	.org	0x0FF0

ret_bank1_lib:
set_bank0:
	clr	selected_bank_bit
	clr	flash_a16_pin
	ret


	;which bank is currently selected?
get_bank:
	mov	c, selected_bank_bit
	ret











;---------------------------------------------------------;
;                                                         ;
;                  External Memory Editor                 ;
;                                                         ;
;---------------------------------------------------------;

;register usage:
; R4,    Flags:
;         bit0: 0=display CODE memory, 1=display DATA memory
;         bit1: 0=editing disabled, 1=editing enabled
;         bit2: 0=editing in hex, 1=editing in ascii
;         bit3: 0=normal, 1=in middle of hex entry (value in r5)
; R6/R7, current memory location
;

.org	0x1000
.db	0xA5,0xE5,0xE0,0xA5	;signiture
.db	254,'E',0,0		;id (254=user installed command)
.db	0,0,0,0			;prompt code vector
.dB	0,0,0,0			;reserved
.db	0,0,0,0			;reserved
.db	0,0,0,0			;reserved
.db	0,0,0,0			;user defined
.db	255,255,255,255		;length and checksum (255=unused)
.db	"Memory Editor (VT100)",0

.org	0x1040            ;executable code begins here


	mov	r4, #0
	acall	redraw
main:
	mov	a, r4
	clr	acc.3
	mov	r4, a
main2:	lcall   cin_filter
	acall	input_ck_2nd
cmd1:	cjne	a, #27, cmd2		;quit
	ajmp	quit
cmd2:	cjne	a, #11, cmd3		;up
	ajmp	cmd_up
cmd3:	cjne	a, #10, cmd4		;down
	ajmp	cmd_down
cmd4:	cjne	a, #8, cmd5		;left
	ajmp	cmd_left
cmd5:	cjne	a, #21, cmd6		;right
	ajmp	cmd_right
cmd6:	cjne	a, #12, cmd7		;redraw
	acall	redraw
	ajmp	main
cmd7:	cjne	a, #17, cmd8		;quit
	ajmp	quit
cmd8:	cjne	a, #3, cmd9		;code memory
	mov	a, r4
	anl	a, #11111110b
	mov	r4, a
	acall	cursor_home
	mov	dptr, #str_code
	acall	pstr_hh
	acall	redraw_data
	ajmp	main
cmd9:	cjne	a, #4, cmd10		;data memory
	mov	a, r4
	orl	a, #00000001b
	mov	r4, a
	acall	cursor_home
	mov	dptr, #str_data
	acall	pstr_hh
	acall	redraw_data
	ajmp	main
cmd10:	cjne	a, #7, cmd11		;goto memory loc
	ajmp	cmd_goto
cmd11:	cjne	a, #5, cmd12		;toggle editing
	ajmp	cmd_edit
cmd12:	cjne	a, #6, cmd13		;fill memory
	ajmp	cmd_fill
cmd13:	cjne	a, #1, cmd14		;edit in ascii
	mov	a, r4
	jnb	acc.1, main
	setb	acc.2
	mov	r4, a
	acall	erase_commands
	acall	print_commands
	acall	redraw_cursor
	ajmp	main
cmd14:	cjne	a, #24, cmd15		;edit in hex
        mov     a, r4
        jnb     acc.1, main
        clr     acc.2
        mov     r4, a
        acall   erase_commands
        acall   print_commands
        acall   redraw_cursor
        ajmp    main
cmd15:	cjne    a, #25, cmd16           ;page up
	ajmp	cmd_pgup
cmd16:	cjne    a, #26, cmd17           ;page down
	ajmp	cmd_pgdown
cmd17:


cmd_data:	;the input character wasn't any particular command, so
		;maybe it's some input data being typed for edit mode
	mov	b, a			;keep a copy of user data in b
	mov	a, r4
	jb	acc.1, cmd_data2
cmd_abort:
	ajmp	main			;ignore if not in edit mode
cmd_data2:
	jnb	acc.2, input_hex
input_ascii:
	mov	a, b
	acall	ascii_only
	cjne	a, b, cmd_abort		;check that input is an ascii char
	mov	dph, r7
	mov	dpl, r6
	acall	edit_smart_wr		;write the char to memory
	ajmp	cmd_right

input_hex:
	mov	a, b
	lcall	upper
	lcall	asc2hex
	jc	cmd_abort		;ignore if not hex
	mov	r0, a			;keep hex value of input in r0
        mov     dph, r7			;load dptr with address
        mov     dpl, r6
	mov	a, r4
	jb	acc.3, input_hex_2nd
input_hex_1st:
	mov	a, r0
	mov	r5, a
	mov	a, r4
	setb	acc.3		;remember that we're waiting for 2nd char
	mov	r4, a
	acall	redraw_cursor
	ajmp	main2
input_hex_2nd:
	mov	a, r5			;get data from memory
	swap	a			;shift nibbles
	anl	a, #11110000b		;just in case
	add	a, r0			;add in this input to lower part
	acall	edit_smart_wr		;write back to memory
	mov	a, r4
	clr	acc.3
	mov	r4, a
	ajmp	cmd_right

input_ck_2nd:
	;the main input routine will always call here when a new
	;byte is entered... so we can do something special if we
	;were waiting for the second character and it is not a
	;legal hex character
	push	acc
	mov	a, r4
	jb	acc.1, inck2d
	;if editing is disabled, don't do anything
	clr	acc.3
inck2b:	mov	r4, a
inck2c:	pop	acc
	ret
inck2d:	jnb	acc.3, inck2b
	;if we get here, we were actually waiting for the 2nd char
	pop	acc
	push	acc
	lcall	upper
	lcall	asc2hex
	jnc	inck2c		;proceed normally if it is valid
	;if we get here, we did not get a hex legal char
	pop	acc
	push	acc
	cjne	a, #esc_char, inck2e
        mov     a, r4
        clr     acc.3
        mov     r4, a
        acall   redraw_cursor
	pop	acc
	pop	acc		;don't return and do the quit cmd
	pop	acc		;just quit this entry and wait for next cmd
	ajmp	main
inck2e: mov     dph, r7                 ;load dptr with address
        mov     dpl, r6
	mov	a, r5
        acall   edit_smart_wr                ;write to memory
	mov	a, r4
	clr	acc.3
	mov	r4, a
	acall	redraw_cursor
	sjmp	inck2c

; R4,    Flags:
;         bit0: 0=display CODE memory, 1=display DATA memory
;         bit1: 0=editing disabled, 1=editing enabled
;         bit2: 0=editing in hex, 1=editing in ascii
;         bit3: 0=normal, 1=in middle of hex entry (value in r5)


cmd_fill:
	mov	a, r4
	anl	a, #00000010b
	jnz	cmd_fill_ok
	ajmp	main			;don't allow if not in editing mode
cmd_fill_ok:
	acall	erase_commands
        mov     a, r4
        push    acc
	mov	dptr, #fill_prompt1
	acall	pcstr_hh
	lcall	ghex16
	jc	cmd_fill_abort
	jb	psw.5, cmd_fill_abort
	mov	r0, dpl
	mov	r1, dph
	mov	dptr, #fill_prompt2
	acall	pstr_hh
	lcall	ghex16
	jc	cmd_fill_abort
	jb	psw.5, cmd_fill_abort
	mov	r4, dpl
	mov	r5, dph
	mov	dptr, #fill_prompt3
	acall	pcstr_hh
	lcall	ghex
	jc	cmd_fill_abort
	jb	psw.5, cmd_fill_abort
	mov	r2, a
	mov	a, r4
	mov	r6, a
	mov	a, r5
	mov	r7, a
	pop	acc
	mov	r4, a
	mov	dpl, r0
	mov	dph, r1
	;now r4 is restored to its normal value, dptr holds the
	;first location to fill, and r6/r7 holds the last location to
	;fill, and r2 has the fill value.
cmd_fill_loop:
	mov	a, r2
	acall	edit_smart_wr
	mov	a, r6
	cjne	a, dpl, cmd_fill_next
	mov	a, r7
	cjne	a, dph, cmd_fill_next
	;when we get here, we're done!
	acall	erase_commands
	acall	print_commands
	acall	redraw_data
	ajmp	main
cmd_fill_next:
	inc	dptr
	sjmp	cmd_fill_loop

cmd_fill_abort:
        pop     acc
        mov     r4, a
        acall   erase_commands
        acall   print_commands
	acall	redraw_cursor
	ajmp	main

fill_prompt1:
        .db     "Fill",31,131,"; First: ",0
fill_prompt2:
        .db     "  Last: ",0
fill_prompt3:
        .db     " ",168,": ",0 

cmd_edit:
	acall	erase_commands
	mov	a, r4
	xrl	a, #00000010b
	mov	r4, a
        acall   print_commands
        acall   redraw_cursor
        ajmp    main

cmd_goto:
	acall	erase_commands
	mov	dptr, #goto_prompt
	acall	pcstr_hh
	mov	a, r4
	push	acc
	lcall	ghex16
	pop	acc
	mov	r4, a
	jc	cmdgt_abort
	jb	psw.5, cmdgt_abort
        mov     r6, dpl
        mov     r7, dph
        acall   cursor_home
        mov     a, #20
        acall   cursor_down
	acall	print_commands
	acall	redraw_data
	ajmp	main
cmdgt_abort:
        acall   cursor_home
        mov     a, #20
        acall   cursor_down
	acall	print_commands
	acall	redraw_cursor
	ajmp	main


goto_prompt:
	.db	31,131,31,129,": ",0

cmd_up:
	acall	blank_it
        mov     a, r6
        clr     c
        subb    a, #16
        mov     r6, a
        mov     a, r7
        subb    a, #0
        mov     r7, a
	mov	a, r6
	cpl	a
	anl	a, #11110000b
	jz	cmd_up_scroll
        mov     a, #1
        acall   cursor_up
        acall   invert_it
        ajmp    main
cmd_up_scroll:
	acall	redraw_data
	ajmp	main

cmd_pgup:
	dec	r7
	acall	redraw_data
	ajmp	main

cmd_pgdown:
	inc	r7
	acall	redraw_data
	ajmp	main

cmd_down:
	acall	blank_it
        mov     a, r6
        add     a

⌨️ 快捷键说明

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