uclock.rmh
来自「PacoBlaze is a from-scratch synthesizabl」· 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: ;// #423: [transmit_string]00120 // #423: load(s1,string_start) ;locate start of string// #424: [next_char_tx]07f10 // #424: fetch(UART_data,s1) ;read character from memory3009d // #425: call(send_to_UART) ;transmit character14f0d // #426: compare(UART_data,character_CR) ;test for last character2b000 // #427: return(z)18101 // #428: add(s1,1) ;move to next character340bd // #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: ;// #451: [receive_string]00120 // #451: load(s1,string_start) ;locate start of string01210 // #452: load(s2,s1) ;compute 16 character address18210 // #453: add(s2,16)// #454: [receive_full_test]04000 // #454: input(s0,UART_status_port) ;test Rx_FIFO buffer for full12008 // #455: test(s0,rx_full)354db // #456: jump(nz,read_error)30095 // #457: call(read_from_UART) ;obtain and echo character2ff10 // #458: store(UART_data,s1) ;write to memory14f0d // #459: compare(UART_data,character_CR) ;test for end of string2b000 // #460: return(z)14f08 // #461: compare(UART_data,character_BS) ;test for back space350d3 // #462: jump(z,BS_edit)18101 // #463: add(s1,1) ;increment memory pointer15120 // #464: compare(s1,s2) ;test for pointer exceeding 16 characters354c6 // #465: jump(nz,receive_full_test) ;next character300ea // #466: call(send_backspace) ;hold end of string position on terminal display// #467: [BS_edit]1c101 // #467: sub(s1,1) ;memory pointer back one14120 // #468: compare(s1,string_start) ;test for under flow358d9 // #469: jump(c,string_start_again)300e7 // #470: call(send_space) ;clear character at current position300ea // #471: call(send_backspace) ;position cursor340c6 // #472: jump(receive_full_test) ;next character// #473: [string_start_again]30122 // #473: call(send_greater_than) ;restore '>' at prompt340c3 // #474: jump(receive_string) ;begin again// #475: ;Receiver buffer overflow condition// #476: [read_error]300e4 // #476: call(send_CR) ;Transmit error message2ef20 // #477: store(UART_data,string_start) ;empty string in memory (start with CR)300fa // #478: call(send_Overflow_Error)300e4 // #479: call(send_CR)// #480: [clear_UART_Rx_loop]04000 // #480: input(s0,UART_status_port) ;test Rx_FIFO buffer for data12010 // #481: test(s0,rx_data_present)2b000 // #482: return(z) ;finish when buffer is empty04f01 // #483: input(UART_data,UART_read_port) ;read from FIFO and ignore340df // #484: jump(clear_UART_Rx_loop)// #485: ;// #486: ;// #487: ;// #488: ;Send Carriage Return to the UART// #489: ;// #490: [send_CR]00f0d // #490: load(UART_data,character_CR)3009d // #491: call(send_to_UART)2a000 // #492: return// #493: ;// #494: ;// #495: ;// #496: ;Send a space to the UART// #497: ;// #498: [send_space]00f20 // #498: load(UART_data,character_space)3009d // #499: call(send_to_UART)2a000 // #500: return// #501: ;// #502: ;// #503: ;Send a back space to the UART// #504: ;// #505: [send_backspace]00f08 // #505: load(UART_data,character_BS)3009d // #506: call(send_to_UART)2a000 // #507: return// #508: ;// #509: ;Send 'Syntax Error' to the UART// #510: ;// #511: [send_Syntax_Error]00f53 // #511: load(UART_data,character_S)3009d // #512: call(send_to_UART)00f79 // #513: load(UART_data,character_y)3009d // #514: call(send_to_UART)00f6e // #515: load(UART_data,character_n)3009d // #516: call(send_to_UART)00f74 // #517: load(UART_data,character_t)3009d // #518: call(send_to_UART)00f61 // #519: load(UART_data,character_a)3009d // #520: call(send_to_UART)00f78 // #521: load(UART_data,character_x)3009d // #522: call(send_to_UART)3410a // #523: jump(send_space_Error)// #524: ;// #525: ;Send 'Overflow Error' to the UART// #526: ;// #527: [send_Overflow_Error]00f4f // #527: load(UART_data,character_O)3009d // #528: call(send_to_UART)00f76 // #529: load(UART_data,character_v)3009d // #530: call(send_to_UART)00f65 // #531: load(UART_data,character_e)3009d // #532: call(send_to_UART)00f72 // #533: load(UART_data,character_r)3009d // #534: call(send_to_UART)00f66 // #535: load(UART_data,character_f)3009d // #536: call(send_to_UART)00f6c // #537: load(UART_data,character_l)3009d // #538: call(send_to_UART)00f6f // #539: load(UART_data,character_o)3009d // #540: call(send_to_UART)00f77 // #541: load(UART_data,character_w)3009d // #542: call(send_to_UART)// #543: [send_space_Error]300e7 // #543: call(send_space)// #544: ;// #545: ;Send 'Error' to the UART// #546: ;// #547: [send_Error]00f45 // #547: load(UART_data,character_E)3009d // #548: call(send_to_UART)00f72 // #549: load(UART_data,character_r)3009d // #550: call(send_to_UART)3009d // #551: call(send_to_UART)00f6f // #552: load(UART_data,character_o)3009d // #553: call(send_to_UART)00f72 // #554: load(UART_data,character_r)3009d // #555: call(send_to_UART)2a000 // #556: return// #557: ;// #558: ;Send 'KCPSM3>' prompt to the UART// #559: ;// #560: [send_prompt]300e4 // #560: call(send_CR) ;start new line00f4b // #561: load(UART_data,character_K)3009d // #562: call(send_to_UART)00f43 // #563: load(UART_data,character_C)3009d // #564: call(send_to_UART)00f50 // #565: load(UART_data,character_P)3009d // #566: call(send_to_UART)00f53 // #567: load(UART_data,character_S)3009d // #568: call(send_to_UART)00f4d // #569: load(UART_data,character_M)3009d // #570: call(send_to_UART)00f33 // #571: load(UART_data,character_3)3009d // #572: call(send_to_UART)// #573: ;// #574: ;Send '>' character to the UART// #575: ;// #576: [send_greater_than]00f3e // #576: load(UART_data,character_greater_than)3009d // #577: call(send_to_UART)2a000 // #578: return// #579: ;// #580: ;Send 'Invalid' string to the UART// #581: ;// #582: [send_Invalid]00f49 // #582: load(UART_data,character_I)3009d // #583: call(send_to_UART)00f6e // #584: load(UART_data,character_n)3009d // #585: call(send_to_UART)00f76 // #586: load(UART_data,character_v)3009d // #587: call(send_to_UART)00f61 // #588: load(UART_data,character_a)3009d // #589: call(send_to_UART)00f6c // #590: load(UART_data,character_l)3009d // #591: call(send_to_UART)00f69 // #592: load(UART_data,character_i)3009d // #593: call(send_to_UART)00f64 // #594: load(UART_data,character_d)3009d // #595: call(send_to_UART)2a000 // #596: return// #597: ;// #598: ;Send 'Time' string to the UART// #599: ;// #600: [send_Time]00f54 // #600: load(UART_data,character_T)3009d // #601: call(send_to_UART)00f69 // #602: load(UART_data,character_i)3009d // #603: call(send_to_UART)00f6d // #604: load(UART_data,character_m)3009d // #605: call(send_to_UART)00f65 // #606: load(UART_data,character_e)3009d // #607: call(send_to_UART)2a000 // #608: return// #609: ;// #610: ;Send 'Alarm' string to the UART// #611: ;// #612: [send_Alarm]00f41 // #612: load(UART_data,character_A)3009d // #613: call(send_to_UART)00f6c // #614: load(UART_data,character_l)3009d // #615: call(send_to_UART)00f61 // #616: load(UART_data,character_a)3009d // #617: call(send_to_UART)00f72 // #618: load(UART_data,character_r)3009d // #619: call(send_to_UART)00f6d // #620: load(UART_data,character_m)3009d // #621: call(send_to_UART)2a000 // #622: return// #623: ;// #624: ;Send 'OFF' string to the UART// #625: ;// #626: [send_OFF]00f4f // #626: load(UART_data,character_O)3009d // #627: call(send_to_UART)00f46 // #628: load(UART_data,character_F)3009d // #629: call(send_to_UART)3009d // #630: call(send_to_UART)2a000 // #631: return// #632: ;// #633: ;Send 'ON' string to the UART// #634: ;// #635: [send_ON]00f4f // #635: load(UART_data,character_O)3009d // #636: call(send_to_UART)00f4e // #637: load(UART_data,character_N)3009d // #638: call(send_to_UART)2a000 // #639: return// #640: ;// #641: ;Send 'Active' string to the UART// #642: ;// #643: [send_Active]00f41 // #643: load(UART_data,character_A)3009d // #644: call(send_to_UART)00f63 // #645: load(UART_data,character_c)3009d // #646: call(send_to_UART)00f74 // #647: load(UART_data,character_t)3009d // #648: call(send_to_UART)00f69 // #649: load(UART_data,character_i)3009d // #650: call(send_to_UART)00f76 // #651: load(UART_data,character_v)3009d // #652: call(send_to_UART)00f65 // #653: load(UART_data,character_e)3009d // #654: call(send_to_UART)2a000 // #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: ;// #676: [time_to_ASCII]00220 // #676: load(s2,string_start) ;location for string070e0 // #677: fetch(s0,store_pointer) ;read hours value3017e // #678: call(decimal_to_ASCII) ;convert to ASCII2f120 // #679: store(s1,s2) ;write hours to string18201 // #680: add(s2,1)2f020 // #681: store(s0,s2)18201 // #682: add(s2,1)0003a // #683: load(s0,character_colon) ;write ':' to string2f020 // #684: store(s0,s2)18201 // #685: add(s2,1)18e01 // #686: add(store_pointer,1) ;move to minutes070e0 // #687: fetch(s0,store_pointer) ;read minutes value3017e // #688: call(decimal_to_ASCII) ;convert to ASCII2f120 // #689: store(s1,s2) ;write minutes to string18201 // #690: add(s2,1)2f020 // #691: store(s0,s2)18201 // #692: add(s2,1)0003a // #693: load(s0,character_colon) ;write ':' to string2f020 // #694: store(s0,s2)18201 // #695: add(s2,1)18e01 // #696: add(store_pointer,1) ;move to seconds070e0 // #697: fetch(s0,store_pointer) ;read seconds value3017e // #698: call(decimal_to_ASCII) ;convert to ASCII2f120 // #699: store(s1,s2) ;write seconds to string18201 // #700: add(s2,1)2f020 // #701: store(s0,s2)18201 // #702: add(s2,1)0000d // #703: load(s0,character_CR) ;finish string with carriage return2f020 // #704: store(s0,s2)2a000 // #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 + -
显示快捷键?