📄 mem_play.asm
字号:
mov dptr, #irq_identmp3_dma_wait: jnb ri, mp3_dma_wait2 acall cin cjne a, #27, mp3_dma_wait2 ljmp paulmon2 ;abort if they press ESCmp3_dma_wait2: movx a, @dptr ;now we just wait for it to finish jnb acc.1, mp3_dma_wait mov a, r2 cjne a, last_block+0, play_loop mov a, r3 cjne a, last_block+1, play_loop ;finished playing the file... now what? ajmp play_from_dram;*************************************************************;** **;** Memory Manager **;** **;************************************************************* ;map block number r2/r3 into a page # specified by Accmap_block: anl a, #15 rl a add a, #dram_page_cfg & 255 mov dpl, a clr a addc a, #dram_page_cfg >> 8 mov dph, a mov a, r2 movx @dptr, a inc dptr mov a, r3 movx @dptr, a ret ;initialize the memory manager, figure out what ;SIMM is installed, and initialize the memory ;block descriptor table. The first 32 blocks ;are always used for the table itself, regardless ;of what SIMM is installed. All the rest are ;either free blocks, or not implemented by the SIMM. ;The xilinx chip needs to be configured with the ;DRAM controller before calling here. ;return: C=1 if an error (no SIMM), C=0 for successinit_memory_mgr: mov dptr, #mesg_xilinx_cfg lcall pstr mov dptr, #alt_xdownload lcall call_bank1 jc error mov dptr, #mesg_ok lcall pstr clr a mov r2, a mov r3, a lcall map_block lcall write_test_bytes lcall check_test_bytes jnc initmm2 mov dptr, #msg_bad_simm lcall pstr setb c ret ;error, no simm is installederror: mov dptr, #mesg_error lcall pstr ljmp paulmon2initmm2: ;in a smaller 4 or 8 meg simm, writing to block 2048 will ;overwrite whatever's in block 0, but 16 and 32 meg simms ;have a block 2048, so writing to block 0, then 2048, and ;checking to see if block 0 still is correct will tell if ;the simm is (4 or 8) vs (16 or 32). mov r2, #2048 & 255 mov r3, #2048 >> 8 clr a lcall map_block lcall write_test_bytes clr a mov r2, a mov r3, a lcall map_block lcall check_test_bytes mov acc.1, c push acc ;double sided simms (8 and 32 megs) implement block 1024 ;whereas single sided simms can't implement block 1024, so ;writing and checking 1024 will tell if it's a single ;(4 or 16) or double (8 or 32). mov r2, #1024 & 255 mov r3, #1024 >> 8 clr a lcall map_block lcall write_test_bytes lcall check_test_bytes pop acc mov acc.0, c cpl a anl a, #3 mov simm_size, a ;store the simm size add a, #2 movc a, @a+pc ;now Acc has simm size, in Mbytes sjmp initmm3 .db 4, 8, 16, 32initmm3: ;print a message here about which simm we found push acc mov dptr, #msg_found lcall pstr pop acc lcall pint8 mov dptr, #msg_size lcall pstr ret ;write a simple test to a DRAM page, just write ;the page number a couple times, with different ;XOR'd with different bit patterns. This way, ;we are unlikely to read garbage as good, and ;it will always detect a page that is corrupted ;by writing to a different page (small simms ;which appear repeated 4 times)write_test_bytes: mov dptr, #dram_page_cfg movx a, @dptr ;read page # lsb mov b, a inc dptr movx a, @dptr ;read page # msb mov dptr, #0 xrl a, #0x5A movx @dptr, a inc dptr cpl a movx @dptr, a inc dptr mov a, b xrl a, #0x9C movx @dptr, a inc dptr cpl a movx @dptr, a ret ;read a page previously written with "write_test_bytes" ;and return C=0 if good, C=1 if wrong bytes read backcheck_test_bytes: mov dptr, #dram_page_cfg movx a, @dptr ;read page # lsb mov r0, a inc dptr movx a, @dptr ;read page # msb mov b, a mov dptr, #0 movx a, @dptr xrl a, #0x5A cjne a, b, cktb_err inc dptr movx a, @dptr xrl a, #0xA5 cjne a, b, cktb_err inc dptr mov b, r0 movx a, @dptr xrl a, #0x9C cjne a, b, cktb_err inc dptr movx a, @dptr xrl a, #0x63 cjne a, b, cktb_err clr c retcktb_err: setb c ret ;advance to the next available block... this ought to know ;about the simm size and avoid going beyond the end, and in ;the case of a 16 meg simm, move the next implemented rangenext_block: mov a, r2 add a, #1 mov r2, a mov a, r3 addc a, #0 mov r3, a ret; mov a, simm_size;next_4meg:; cjne a, #0, next_8meg;next_8meg:; cjne a, #0, next_8meg;next_16meg:; cjne a, #0, next_8meg;next_32meg:; cjne a, #0, next_8meg;*************************************************************;** **;** Serial Port I/O Functions **;** **;*************************************************************phex: acall phex_bphex_b: swap a ;SWAP A will be twice => A unchangedphex1: push acc anl a, #15 add a, #0x90 ; acc is 0x9X, where X is hex digit da a ; if A to F, C=1 and lower four bits are 0..5 addc a, #0x40 da a acall cout pop acc retpstr: push accpstr1: clr a movc a, @a+dptr inc dptr jz pstr2 mov c, acc.7 anl a, #0x7F acall cout jc pstr2 sjmp pstr1pstr2: pop acc retcin: jnb ri, cin clr ri mov a, sbuf retcout: jnb ti, cout clr ti ;clr ti before the mov to sbuf! mov sbuf, a retnewline:push acc ;print one newline mov a, #13 acall cout mov a, #10 acall cout pop acc retpint8u: ;prints the unsigned 8 bit value in Acc in base 10 push b push acc sjmp pint8bpint8: ;prints the signed 8 bit value in Acc in base 10 push b push acc jnb acc.7, pint8b mov a, #'-' lcall cout pop acc push acc cpl a add a, #1pint8b: mov b, #100 div ab setb f0 jz pint8c clr f0 add a, #'0' lcall coutpint8c: mov a, b mov b, #10 div ab jnb f0, pint8d jz pint8epint8d: add a, #'0' lcall coutpint8e: mov a, b add a, #'0' lcall cout pop acc pop b retmsg_bad_simm: .db "Bad or Missing SIMM",13,10,0msg_found: .db "Found ",0msg_size: .db " meg SIMM",13,10,0mesg_xilinx_cfg: .db "Configuring Xilinx XCS10XL FPGA Chip: ",0mesg_ok: .db "Ok",13,10,0mesg_error: .db "Error!",13,10,0mesg_abort: .db "Abort",13,10,0msg_dl_ok: .db 13,10,"Download completed",13,10,0msg_begin_dl: .db "Begin sending the MP3 file " .db "(converted with mp3_to_dl):",13,10,0msg_err_dram: .db "Error, DRAM not initialize from download",13,10,0msg_err_mp3: .db "Error, Memory doesn't contain a MP3 file",13,10,0msg_play1: .db "Playing MP3 file from block ",0msg_play2: .db " to ",0mesg_sta013_cfg: .db "Configuring STA013 MP3 Decoder Chip: ",0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -