uclock.rmh

来自「和picoblaze完全兼容的mcu ip core」· RMH 代码 · 共 1,263 行 · 第 1/4 页

RMH
1,263 行
字号
// #419: ;// #420: ;Registers used s1 and 'UART_data'.// #421: ;               s0 is then used in subroutine 'send_to_UART'// #422: ;// @0bc #423: [transmit_string]00120 // @0bc #423: load(s1,string_start) ;locate start of string// @0bd #424: [next_char_tx]07f10 // @0bd #424: fetch(UART_data,s1) ;read character from memory3009d // @0be #425: call(send_to_UART) ;transmit character14f0d // @0bf #426: compare(UART_data,character_CR) ;test for last character2b000 // @0c0 #427: return(z)18101 // @0c1 #428: add(s1,1) ;move to next character340bd // @0c2 #429: jump(next_char_tx)// #430: ;// #431: ;// #432: ;Receive ASCII string from UART// #433: ;// #434: ;An ASCII string will be read from the UART and stored in scratch pad memory// #435: ;commencing at the location specified by a constant named 'string_start'.// #436: ;The string will will have a maximum length of 16 characters including a// #437: ;carriage return (0D) denoting the end of the string.// #438: ;// #439: ;As each character is read, it is echoed to the UART transmitter.// #440: ;Some minor editing is supported using backspace (BS=08) which is used// #441: ;to adjust what is stored in scratch pad memory and adjust the display// #442: ;on the terminal screen using characters sent to the UART transmitter.// #443: ;// #444: ;A test is made for the receiver FIFO becoming full. A full status is treated as// #445: ;a potential error situation and will result in a 'Overflow Error' message being// #446: ;transmitted to the UART, the receiver FIFO being purged of all data and an// #447: ;empty string being stored (carriage return at first location).// #448: ;// #449: ;Registers used s0, s1, s2 and 'UART_data'.// #450: ;// @0c3 #451: [receive_string]00120 // @0c3 #451: load(s1,string_start) ;locate start of string01210 // @0c4 #452: load(s2,s1) ;compute 16 character address18210 // @0c5 #453: add(s2,16)// @0c6 #454: [receive_full_test]04000 // @0c6 #454: input(s0,UART_status_port) ;test Rx_FIFO buffer for full12008 // @0c7 #455: test(s0,rx_full)354db // @0c8 #456: jump(nz,read_error)30095 // @0c9 #457: call(read_from_UART) ;obtain and echo character2ff10 // @0ca #458: store(UART_data,s1) ;write to memory14f0d // @0cb #459: compare(UART_data,character_CR) ;test for end of string2b000 // @0cc #460: return(z)14f08 // @0cd #461: compare(UART_data,character_BS) ;test for back space350d3 // @0ce #462: jump(z,BS_edit)18101 // @0cf #463: add(s1,1) ;increment memory pointer15120 // @0d0 #464: compare(s1,s2) ;test for pointer exceeding 16 characters354c6 // @0d1 #465: jump(nz,receive_full_test) ;next character300ea // @0d2 #466: call(send_backspace) ;hold end of string position on terminal display// @0d3 #467: [BS_edit]1c101 // @0d3 #467: sub(s1,1) ;memory pointer back one14120 // @0d4 #468: compare(s1,string_start) ;test for under flow358d9 // @0d5 #469: jump(c,string_start_again)300e7 // @0d6 #470: call(send_space) ;clear character at current position300ea // @0d7 #471: call(send_backspace) ;position cursor340c6 // @0d8 #472: jump(receive_full_test) ;next character// @0d9 #473: [string_start_again]30122 // @0d9 #473: call(send_greater_than) ;restore '>' at prompt340c3 // @0da #474: jump(receive_string) ;begin again// #475: ;Receiver buffer overflow condition// @0db #476: [read_error]300e4 // @0db #476: call(send_CR) ;Transmit error message2ef20 // @0dc #477: store(UART_data,string_start) ;empty string in memory (start with CR)300fa // @0dd #478: call(send_Overflow_Error)300e4 // @0de #479: call(send_CR)// @0df #480: [clear_UART_Rx_loop]04000 // @0df #480: input(s0,UART_status_port) ;test Rx_FIFO buffer for data12010 // @0e0 #481: test(s0,rx_data_present)2b000 // @0e1 #482: return(z) ;finish when buffer is empty04f01 // @0e2 #483: input(UART_data,UART_read_port) ;read from FIFO and ignore340df // @0e3 #484: jump(clear_UART_Rx_loop)// #485: ;// #486: ;// #487: ;// #488: ;Send Carriage Return to the UART// #489: ;// @0e4 #490: [send_CR]00f0d // @0e4 #490: load(UART_data,character_CR)3009d // @0e5 #491: call(send_to_UART)2a000 // @0e6 #492: return// #493: ;// #494: ;// #495: ;// #496: ;Send a space to the UART// #497: ;// @0e7 #498: [send_space]00f20 // @0e7 #498: load(UART_data,character_space)3009d // @0e8 #499: call(send_to_UART)2a000 // @0e9 #500: return// #501: ;// #502: ;// #503: ;Send a back space to the UART// #504: ;// @0ea #505: [send_backspace]00f08 // @0ea #505: load(UART_data,character_BS)3009d // @0eb #506: call(send_to_UART)2a000 // @0ec #507: return// #508: ;// #509: ;Send 'Syntax Error' to the UART// #510: ;// @0ed #511: [send_Syntax_Error]00f53 // @0ed #511: load(UART_data,character_S)3009d // @0ee #512: call(send_to_UART)00f79 // @0ef #513: load(UART_data,character_y)3009d // @0f0 #514: call(send_to_UART)00f6e // @0f1 #515: load(UART_data,character_n)3009d // @0f2 #516: call(send_to_UART)00f74 // @0f3 #517: load(UART_data,character_t)3009d // @0f4 #518: call(send_to_UART)00f61 // @0f5 #519: load(UART_data,character_a)3009d // @0f6 #520: call(send_to_UART)00f78 // @0f7 #521: load(UART_data,character_x)3009d // @0f8 #522: call(send_to_UART)3410a // @0f9 #523: jump(send_space_Error)// #524: ;// #525: ;Send 'Overflow Error' to the UART// #526: ;// @0fa #527: [send_Overflow_Error]00f4f // @0fa #527: load(UART_data,character_O)3009d // @0fb #528: call(send_to_UART)00f76 // @0fc #529: load(UART_data,character_v)3009d // @0fd #530: call(send_to_UART)00f65 // @0fe #531: load(UART_data,character_e)3009d // @0ff #532: call(send_to_UART)00f72 // @100 #533: load(UART_data,character_r)3009d // @101 #534: call(send_to_UART)00f66 // @102 #535: load(UART_data,character_f)3009d // @103 #536: call(send_to_UART)00f6c // @104 #537: load(UART_data,character_l)3009d // @105 #538: call(send_to_UART)00f6f // @106 #539: load(UART_data,character_o)3009d // @107 #540: call(send_to_UART)00f77 // @108 #541: load(UART_data,character_w)3009d // @109 #542: call(send_to_UART)// @10a #543: [send_space_Error]300e7 // @10a #543: call(send_space)// #544: ;// #545: ;Send 'Error' to the UART// #546: ;// @10b #547: [send_Error]00f45 // @10b #547: load(UART_data,character_E)3009d // @10c #548: call(send_to_UART)00f72 // @10d #549: load(UART_data,character_r)3009d // @10e #550: call(send_to_UART)3009d // @10f #551: call(send_to_UART)00f6f // @110 #552: load(UART_data,character_o)3009d // @111 #553: call(send_to_UART)00f72 // @112 #554: load(UART_data,character_r)3009d // @113 #555: call(send_to_UART)2a000 // @114 #556: return// #557: ;// #558: ;Send 'KCPSM3>' prompt to the UART// #559: ;// @115 #560: [send_prompt]300e4 // @115 #560: call(send_CR) ;start new line00f4b // @116 #561: load(UART_data,character_K)3009d // @117 #562: call(send_to_UART)00f43 // @118 #563: load(UART_data,character_C)3009d // @119 #564: call(send_to_UART)00f50 // @11a #565: load(UART_data,character_P)3009d // @11b #566: call(send_to_UART)00f53 // @11c #567: load(UART_data,character_S)3009d // @11d #568: call(send_to_UART)00f4d // @11e #569: load(UART_data,character_M)3009d // @11f #570: call(send_to_UART)00f33 // @120 #571: load(UART_data,character_3)3009d // @121 #572: call(send_to_UART)// #573: ;// #574: ;Send '>' character to the UART// #575: ;// @122 #576: [send_greater_than]00f3e // @122 #576: load(UART_data,character_greater_than)3009d // @123 #577: call(send_to_UART)2a000 // @124 #578: return// #579: ;// #580: ;Send 'Invalid' string to the UART// #581: ;// @125 #582: [send_Invalid]00f49 // @125 #582: load(UART_data,character_I)3009d // @126 #583: call(send_to_UART)00f6e // @127 #584: load(UART_data,character_n)3009d // @128 #585: call(send_to_UART)00f76 // @129 #586: load(UART_data,character_v)3009d // @12a #587: call(send_to_UART)00f61 // @12b #588: load(UART_data,character_a)3009d // @12c #589: call(send_to_UART)00f6c // @12d #590: load(UART_data,character_l)3009d // @12e #591: call(send_to_UART)00f69 // @12f #592: load(UART_data,character_i)3009d // @130 #593: call(send_to_UART)00f64 // @131 #594: load(UART_data,character_d)3009d // @132 #595: call(send_to_UART)2a000 // @133 #596: return// #597: ;// #598: ;Send 'Time' string to the UART// #599: ;// @134 #600: [send_Time]00f54 // @134 #600: load(UART_data,character_T)3009d // @135 #601: call(send_to_UART)00f69 // @136 #602: load(UART_data,character_i)3009d // @137 #603: call(send_to_UART)00f6d // @138 #604: load(UART_data,character_m)3009d // @139 #605: call(send_to_UART)00f65 // @13a #606: load(UART_data,character_e)3009d // @13b #607: call(send_to_UART)2a000 // @13c #608: return// #609: ;// #610: ;Send 'Alarm' string to the UART// #611: ;// @13d #612: [send_Alarm]00f41 // @13d #612: load(UART_data,character_A)3009d // @13e #613: call(send_to_UART)00f6c // @13f #614: load(UART_data,character_l)3009d // @140 #615: call(send_to_UART)00f61 // @141 #616: load(UART_data,character_a)3009d // @142 #617: call(send_to_UART)00f72 // @143 #618: load(UART_data,character_r)3009d // @144 #619: call(send_to_UART)00f6d // @145 #620: load(UART_data,character_m)3009d // @146 #621: call(send_to_UART)2a000 // @147 #622: return// #623: ;// #624: ;Send 'OFF' string to the UART// #625: ;// @148 #626: [send_OFF]00f4f // @148 #626: load(UART_data,character_O)3009d // @149 #627: call(send_to_UART)00f46 // @14a #628: load(UART_data,character_F)3009d // @14b #629: call(send_to_UART)3009d // @14c #630: call(send_to_UART)2a000 // @14d #631: return// #632: ;// #633: ;Send 'ON' string to the UART// #634: ;// @14e #635: [send_ON]00f4f // @14e #635: load(UART_data,character_O)3009d // @14f #636: call(send_to_UART)00f4e // @150 #637: load(UART_data,character_N)3009d // @151 #638: call(send_to_UART)2a000 // @152 #639: return// #640: ;// #641: ;Send 'Active' string to the UART// #642: ;// @153 #643: [send_Active]00f41 // @153 #643: load(UART_data,character_A)3009d // @154 #644: call(send_to_UART)00f63 // @155 #645: load(UART_data,character_c)3009d // @156 #646: call(send_to_UART)00f74 // @157 #647: load(UART_data,character_t)3009d // @158 #648: call(send_to_UART)00f69 // @159 #649: load(UART_data,character_i)3009d // @15a #650: call(send_to_UART)00f76 // @15b #651: load(UART_data,character_v)3009d // @15c #652: call(send_to_UART)00f65 // @15d #653: load(UART_data,character_e)3009d // @15e #654: call(send_to_UART)2a000 // @15f #655: return// #656: ;// #657: ;// #658: ;Convert time to ASCII string in scratch pad memory.// #659: ;// #660: ;The time to converted must be stored in 3 scratch pad memory locations as// #661: ;defined below. A register named 'store_pointer' must provide the address of// #662: ;first location.// #663: ;// #664: ;        Address                Data// #665: ;// #666: ;     store_pointer      ----> hours// #667: ;     store_pointer + 1  ----> minutes// #668: ;     store_pointer + 1  ----> seconds// #669: ;// #670: ;The resulting ASCII string will be stored in scratch pad memory starting at// #671: ;a location specified by a constant named 'string_start'. The string will// #672: ;take the format hh:mm:ss and end with a carriage return.// #673: ;// #674: ;Registers used s0, s1, s2 and 'store_pointer'.// #675: ;// @160 #676: [time_to_ASCII]00220 // @160 #676: load(s2,string_start) ;location for string070e0 // @161 #677: fetch(s0,store_pointer) ;read hours value3017e // @162 #678: call(decimal_to_ASCII) ;convert to ASCII2f120 // @163 #679: store(s1,s2) ;write hours to string18201 // @164 #680: add(s2,1)2f020 // @165 #681: store(s0,s2)18201 // @166 #682: add(s2,1)0003a // @167 #683: load(s0,character_colon) ;write ':' to string2f020 // @168 #684: store(s0,s2)18201 // @169 #685: add(s2,1)18e01 // @16a #686: add(store_pointer,1) ;move to minutes070e0 // @16b #687: fetch(s0,store_pointer) ;read minutes value3017e // @16c #688: call(decimal_to_ASCII) ;convert to ASCII2f120 // @16d #689: store(s1,s2) ;write minutes to string18201 // @16e #690: add(s2,1)2f020 // @16f #691: store(s0,s2)18201 // @170 #692: add(s2,1)0003a // @171 #693: load(s0,character_colon) ;write ':' to string2f020 // @172 #694: store(s0,s2)18201 // @173 #695: add(s2,1)18e01 // @174 #696: add(store_pointer,1) ;move to seconds070e0 // @175 #697: fetch(s0,store_pointer) ;read seconds value3017e // @176 #698: call(decimal_to_ASCII) ;convert to ASCII2f120 // @177 #699: store(s1,s2) ;write seconds to string18201 // @178 #700: add(s2,1)2f020 // @179 #701: store(s0,s2)18201 // @17a #702: add(s2,1)0000d // @17b #703: load(s0,character_CR) ;finish string with carriage return2f020 // @17c #704: store(s0,s2)2a000 // @17d #705: return// #706: ;// #707: ;Convert value provided in register s0 into ASCII characters// #708: ;// #709: ;The value provided must in the range 0 to 99 and will be converted into// #710: ;two ASCII characters.

⌨️ 快捷键说明

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