uclock.rmh
来自「PacoBlaze is a from-scratch synthesizabl」· RMH 代码 · 共 1,263 行 · 第 1/4 页
RMH
1,263 行
35012 // #121: jump(z,prompt_input)// #122: ;// #123: ;// #124: [test_for_TIME]30091 // #124: call(fetch_char_from_memory)14049 // #125: compare(s0,character_I) ;test for rest of 'TIME'3541c // #126: jump(nz,bad_input_command)30091 // #127: call(fetch_char_from_memory)1404d // #128: compare(s0,character_M)3541c // #129: jump(nz,bad_input_command)30091 // #130: call(fetch_char_from_memory)14045 // #131: compare(s0,character_E)3541c // #132: jump(nz,bad_input_command)// #133: ;now have a valid TIME command to process30091 // #134: call(fetch_char_from_memory)1400d // #135: compare(s0,character_CR) ;carriage return means display time3542c // #136: jump(nz,set_time_command)300a8 // #137: call(transmit_time) ;transmit time to UART34012 // #138: jump(prompt_input)// #139: [set_time_command]14020 // #139: compare(s0,character_space)3541c // #140: jump(nz,bad_input_command)3006d // #141: call(test_time_string) ;interpret 'hh:mm:ss' string35812 // #142: jump(c,prompt_input) ;test for invalid input2e606 // #143: store(s6,real_time_hours) ;set new time into clock2e507 // #144: store(s5,real_time_minutes)2e408 // #145: store(s4,real_time_seconds)2e004 // #146: store(s0,ms_time_lsb) ;clear 'ms' counter (s0=00)2e005 // #147: store(s0,ms_time_msb)300a8 // #148: call(transmit_time) ;transmit new time to UART34012 // #149: jump(prompt_input)// #150: ;// #151: ;// #152: [test_for_ALARM]30091 // #152: call(fetch_char_from_memory)1404c // #153: compare(s0,character_L) ;test for rest of 'ALARM'3541c // #154: jump(nz,bad_input_command)30091 // #155: call(fetch_char_from_memory)14041 // #156: compare(s0,character_A)3541c // #157: jump(nz,bad_input_command)30091 // #158: call(fetch_char_from_memory)14052 // #159: compare(s0,character_R)3541c // #160: jump(nz,bad_input_command)30091 // #161: call(fetch_char_from_memory)1404d // #162: compare(s0,character_M)3541c // #163: jump(nz,bad_input_command)// #164: ;now have a valid ALARM command to process30091 // #165: call(fetch_char_from_memory)1400d // #166: compare(s0,character_CR) ;carriage return means display alarm time35448 // #167: jump(nz,set_alarm_command)300ac // #168: call(transmit_alarm_time) ;transmit time to UART34012 // #169: jump(prompt_input)// #170: [set_alarm_command]14020 // #170: compare(s0,character_space) ;test for ON or OFF command3541c // #171: jump(nz,bad_input_command)30091 // #172: call(fetch_char_from_memory)1404f // #173: compare(s0,character_O)35055 // #174: jump(z,set_alarm_on_off)1c101 // #175: sub(s1,1) ;move memory pointer back to first character of 'hh:mm:ss' string3006d // #176: call(test_time_string) ;interpret 'hh:mm:ss' string35812 // #177: jump(c,prompt_input) ;test for invalid input2e609 // #178: store(s6,alarm_time_hours) ;set new time into clock2e50a // #179: store(s5,alarm_time_minutes)2e40b // #180: store(s4,alarm_time_seconds)300ac // #181: call(transmit_alarm_time) ;transmit new alarm time and status34012 // #182: jump(prompt_input)// #183: [set_alarm_on_off]30091 // #183: call(fetch_char_from_memory)1404e // #184: compare(s0,character_N) ;test for 'ON'35460 // #185: jump(nz,test_OFF)30091 // #186: call(fetch_char_from_memory)1400d // #187: compare(s0,character_CR)3541c // #188: jump(nz,bad_input_command)0600c // #189: fetch(s0,alarm_status) ;turn alarm on0c002 // #190: or(s0,alarm_armed)2e00c // #191: store(s0,alarm_status)300ac // #192: call(transmit_alarm_time) ;transmit alarm time and status34012 // #193: jump(prompt_input)// #194: [test_OFF]14046 // #194: compare(s0,character_F) ;test for for 'OFF'3541c // #195: jump(nz,bad_input_command)30091 // #196: call(fetch_char_from_memory)14046 // #197: compare(s0,character_F)3541c // #198: jump(nz,bad_input_command)30091 // #199: call(fetch_char_from_memory)1400d // #200: compare(s0,character_CR)3541c // #201: jump(nz,bad_input_command)00000 // #202: load(s0,0) ;turn alarm off and stop an active alarm2e00c // #203: store(s0,alarm_status)300a4 // #204: call(alarm_drive) ;turn off alarm300ac // #205: call(transmit_alarm_time) ;transmit alarm time and status34012 // #206: jump(prompt_input)// #207: ;// #208: ;// #209: ;// #210: ;// #211: ;Read an 'hh:mm:ss' time string and provide new values.// #212: ;// #213: ;The string must be provided in successive scratch pad memory locations// #214: ;with the s1 register containing the location of the first character.// #215: ;// #216: ;A correct time specification will result in the return of new values// #217: ;as follows:-// #218: ;// #219: ; s6 = hours// #220: ; s5 = minutes// #221: ; s4 = seconds// #222: ;// #223: ;If the syntax is incorrect or values are not in the correct ranges an// #224: ;'Invalid Time' message will be transmitted and the CARRY flag will be set// #225: ;// #226: ;Registers used s0, s1, s6, s5 and s4// #227: ;// #228: [test_time_string]301ec // #228: call(_2char_to_value) ;obtain hours value3588b // #229: jump(c,invalid_time) ;test for non-decimal characters01620 // #230: load(s6,s2) ;remember hours18101 // #231: add(s1,1) ;increment memory pointer past hours30091 // #232: call(fetch_char_from_memory)1403a // #233: compare(s0,character_colon) ;test for colon3548b // #234: jump(nz,invalid_time)301ec // #235: call(_2char_to_value) ;obtain minutes value3588b // #236: jump(c,invalid_time) ;test for non-decimal characters01520 // #237: load(s5,s2) ;remember minutes18101 // #238: add(s1,1) ;increment memory pointer past minutes30091 // #239: call(fetch_char_from_memory)1403a // #240: compare(s0,character_colon) ;test for colon3548b // #241: jump(nz,invalid_time)301ec // #242: call(_2char_to_value) ;obtain seconds value3588b // #243: jump(c,invalid_time) ;test for non-decimal characters01420 // #244: load(s4,s2) ;remember minutes18101 // #245: add(s1,1) ;increment memory pointer past seconds30091 // #246: call(fetch_char_from_memory)1400d // #247: compare(s0,character_CR) ;finish with carriage return3548b // #248: jump(nz,invalid_time)// #249: ;Have values for hh:mm:ss but need to test if each is valid range.14618 // #250: compare(s6,hours_in_a_day)35c8b // #251: jump(nc,invalid_time)1453c // #252: compare(s5,minutes_in_an_hour)35c8b // #253: jump(nc,invalid_time)1443c // #254: compare(s4,seconds_in_a_minute)35c8b // #255: jump(nc,invalid_time)00000 // #256: load(s0,0)2000e // #257: sr0(s0) ;reset CARRY flag (with s0=0)2a000 // #258: return ;time string was OK// #259: [invalid_time]30125 // #259: call(send_Invalid)300e7 // #260: call(send_space)30134 // #261: call(send_Time)00001 // #262: load(s0,1)2000e // #263: sr0(s0) ;set CARRY flag2a000 // #264: return ;time string was bad// #265: ;// #266: ;// #267: ;fetch character from memory, $Convert to upper case// #268: ;and increment memory pointer.// #269: ;// #270: ;The memory pointer is provided in register s1.// #271: ;The character obtained is returned in register s0.// #272: ;// #273: ;Registers used s0 and s1.// #274: ;// #275: [fetch_char_from_memory]07010 // #275: fetch(s0,s1) ;read character301e2 // #276: call(upper_case) ;convert to upper case18101 // #277: add(s1,1) ;increment memory pointer2a000 // #278: return// #279: ;// #280: ;// #281: ;// #282: ;Read one character from the UART// #283: ;// #284: ;Character read will be returned in a register called 'UART_data' and will be// #285: ;echoed to the UART transmitter.// #286: ;// #287: ;The routine first tests the receiver FIFO buffer to see if data is present.// #288: ;If the FIFO is empty, the routine waits until there is a character to read.// #289: ;As this could take any amount of time the wait loop includes a call to the// #290: ;subroutine which updates the real time clock.// #291: ;// #292: ;Registers used s0 and UART_data// #293: ;// #294: [read_from_UART]04000 // #294: input(s0,UART_status_port) ;test Rx_FIFO buffer12010 // #295: test(s0,rx_data_present)3549a // #296: jump(nz,read_character)30185 // #297: call(update_time) ;Perform useful operation whilst waiting34095 // #298: jump(read_from_UART)// #299: [read_character]04f01 // #299: input(UART_data,UART_read_port) ;read from FIFO3009d // #300: call(send_to_UART) ;echo received character2a000 // #301: return// #302: ;// #303: ;// #304: ;// #305: ;Transmit one character to the UART// #306: ;// #307: ;Character supplied in register called 'UART_data'.// #308: ;// #309: ;The routine first tests the transmit FIFO buffer to see if it is full.// #310: ;If the FIFO is full, the routine waits until there is space which could// #311: ;be as long as it takes to transmit one complete character.// #312: ;// #313: ; Baud Rate Time per Character (10 bits)// #314: ; 9600 1,024us// #315: ; 19200 521us// #316: ; 38400 260us// #317: ; 57600 174us// #318: ; 115200 87us// #319: ;// #320: ;Since this is a relatively long duration, the wait loop includes a// #321: ;call to the subroutine which updates the real time clock.// #322: ;// #323: ;Registers used s0// #324: ;// #325: [send_to_UART]04000 // #325: input(s0,UART_status_port) ;test Tx_FIFO buffer12002 // #326: test(s0,tx_full)350a2 // #327: jump(z,UART_write)30185 // #328: call(update_time) ;Perform useful operation whilst waiting3409d // #329: jump(send_to_UART)// #330: [UART_write]2cf01 // #330: output(UART_data,UART_write_port)2a000 // #331: return// #332: ;// #333: ;// #334: ;// #335: ;// #336: ;Alarm output// #337: ;// #338: ;Uses the alarm status scratch pad memory to set or reset the alarm// #339: ;control bit on the alarm output port.// #340: ;// #341: ;Registers used s0// #342: ;// #343: [alarm_drive]0600c // #343: fetch(s0,alarm_status) ;read status0a001 // #344: and(s0,alarm_active) ;isolate bit02c000 // #345: output(s0,alarm_port)2a000 // #346: return// #347: ;// #348: ;// #349: ;// #350: ;// #351: ;// #352: ;Transmit the time to the UART port in the format hh:mm:ss and end// #353: ;with a carriage return.// #354: ;// #355: ;The time to converted must be stored in 3 scratch pad memory locations as// #356: ;defined below. A register named 'store_pointer' must provide the address of// #357: ;first location.// #358: ;// #359: ; Address Data// #360: ;// #361: ; store_pointer ----> hours// #362: ; store_pointer + 1 ----> minutes// #363: ; store_pointer + 1 ----> seconds// #364: ;// #365: ;The routine first converts the time into an ASCII string stored in scratch// #366: ;pad memory starting at a location specified by a constant named 'string_start'.// #367: ;The string will then be transmitted.// #368: ;// #369: ;Registers used s0, s1, s2, 'store_pointer' and 'UART_data'.// #370: ;// #371: [transmit_time]00e06 // #371: load(store_pointer,real_time_hours) ;locate current time in memory30160 // #372: call(time_to_ASCII)300bc // #373: call(transmit_string)2a000 // #374: return// #375: ;// #376: ;// #377: ;Transmit the alarm time and status to the UART port in the format hh:mm:ss and// #378: ;ending with carriage return.// #379: ;// #380: ;The alarm time to converted must be stored in 3 scratch pad memory locations as// #381: ;defined below. A register named 'store_pointer' must provide the address of// #382: ;first location.// #383: ;// #384: ; Address Data// #385: ;// #386: ; store_pointer ----> hours// #387: ; store_pointer + 1 ----> minutes// #388: ; store_pointer + 1 ----> seconds// #389: ;// #390: ;The routine first converts the time into an ASCII string stored in scratch// #391: ;pad memory starting at a location specified by a constant named 'string_start'.// #392: ;The string will then be transmitted.// #393: ;// #394: ;Registers used s0, s1, s2, 'store_pointer' and 'UART_data'.// #395: ;// #396: [transmit_alarm_time]00e09 // #396: load(store_pointer,alarm_time_hours) ;locate alarm time in memory30160 // #397: call(time_to_ASCII)300bc // #398: call(transmit_string)3013d // #399: call(send_Alarm)300e7 // #400: call(send_space)0600c // #401: fetch(s0,alarm_status) ;read alarm status12001 // #402: test(s0,alarm_active) ;test for active350b6 // #403: jump(z,test_armed)30153 // #404: call(send_Active)2a000 // #405: return// #406: [test_armed]12002 // #406: test(s0,alarm_armed) ;test for on350ba // #407: jump(z,alarm_is_off)3014e // #408: call(send_ON)2a000 // #409: return// #410: [alarm_is_off]30148 // #410: call(send_OFF)2a000 // #411: return// #412: ;// #413: ;// #414: ;Transmit ASCII string to UART// #415: ;// #416: ;An ASCII string must be provided in scratch pad memory commencing at the// #417: ;location specified by a constant named 'string_start'. The string must// #418: ;end with a carriage return (0D).
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?