uclock.rmh

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

RMH
1,263
字号
35012 // @01d #121: jump(z,prompt_input)// #122: ;// #123: ;// @01e #124: [test_for_TIME]30091 // @01e #124: call(fetch_char_from_memory)14049 // @01f #125: compare(s0,character_I) ;test for rest of 'TIME'3541c // @020 #126: jump(nz,bad_input_command)30091 // @021 #127: call(fetch_char_from_memory)1404d // @022 #128: compare(s0,character_M)3541c // @023 #129: jump(nz,bad_input_command)30091 // @024 #130: call(fetch_char_from_memory)14045 // @025 #131: compare(s0,character_E)3541c // @026 #132: jump(nz,bad_input_command)// #133: ;now have a valid TIME command to process30091 // @027 #134: call(fetch_char_from_memory)1400d // @028 #135: compare(s0,character_CR) ;carriage return means display time3542c // @029 #136: jump(nz,set_time_command)300a8 // @02a #137: call(transmit_time) ;transmit time to UART34012 // @02b #138: jump(prompt_input)// @02c #139: [set_time_command]14020 // @02c #139: compare(s0,character_space)3541c // @02d #140: jump(nz,bad_input_command)3006d // @02e #141: call(test_time_string) ;interpret 'hh:mm:ss' string35812 // @02f #142: jump(c,prompt_input) ;test for invalid input2e606 // @030 #143: store(s6,real_time_hours) ;set new time into clock2e507 // @031 #144: store(s5,real_time_minutes)2e408 // @032 #145: store(s4,real_time_seconds)2e004 // @033 #146: store(s0,ms_time_lsb) ;clear 'ms' counter (s0=00)2e005 // @034 #147: store(s0,ms_time_msb)300a8 // @035 #148: call(transmit_time) ;transmit new time to UART34012 // @036 #149: jump(prompt_input)// #150: ;// #151: ;// @037 #152: [test_for_ALARM]30091 // @037 #152: call(fetch_char_from_memory)1404c // @038 #153: compare(s0,character_L) ;test for rest of 'ALARM'3541c // @039 #154: jump(nz,bad_input_command)30091 // @03a #155: call(fetch_char_from_memory)14041 // @03b #156: compare(s0,character_A)3541c // @03c #157: jump(nz,bad_input_command)30091 // @03d #158: call(fetch_char_from_memory)14052 // @03e #159: compare(s0,character_R)3541c // @03f #160: jump(nz,bad_input_command)30091 // @040 #161: call(fetch_char_from_memory)1404d // @041 #162: compare(s0,character_M)3541c // @042 #163: jump(nz,bad_input_command)// #164: ;now have a valid ALARM command to process30091 // @043 #165: call(fetch_char_from_memory)1400d // @044 #166: compare(s0,character_CR) ;carriage return means display alarm time35448 // @045 #167: jump(nz,set_alarm_command)300ac // @046 #168: call(transmit_alarm_time) ;transmit time to UART34012 // @047 #169: jump(prompt_input)// @048 #170: [set_alarm_command]14020 // @048 #170: compare(s0,character_space) ;test for ON or OFF command3541c // @049 #171: jump(nz,bad_input_command)30091 // @04a #172: call(fetch_char_from_memory)1404f // @04b #173: compare(s0,character_O)35055 // @04c #174: jump(z,set_alarm_on_off)1c101 // @04d #175: sub(s1,1) ;move memory pointer back to first character of 'hh:mm:ss' string3006d // @04e #176: call(test_time_string) ;interpret 'hh:mm:ss' string35812 // @04f #177: jump(c,prompt_input) ;test for invalid input2e609 // @050 #178: store(s6,alarm_time_hours) ;set new time into clock2e50a // @051 #179: store(s5,alarm_time_minutes)2e40b // @052 #180: store(s4,alarm_time_seconds)300ac // @053 #181: call(transmit_alarm_time) ;transmit new alarm time and status34012 // @054 #182: jump(prompt_input)// @055 #183: [set_alarm_on_off]30091 // @055 #183: call(fetch_char_from_memory)1404e // @056 #184: compare(s0,character_N) ;test for 'ON'35460 // @057 #185: jump(nz,test_OFF)30091 // @058 #186: call(fetch_char_from_memory)1400d // @059 #187: compare(s0,character_CR)3541c // @05a #188: jump(nz,bad_input_command)0600c // @05b #189: fetch(s0,alarm_status) ;turn alarm on0c002 // @05c #190: or(s0,alarm_armed)2e00c // @05d #191: store(s0,alarm_status)300ac // @05e #192: call(transmit_alarm_time) ;transmit alarm time and status34012 // @05f #193: jump(prompt_input)// @060 #194: [test_OFF]14046 // @060 #194: compare(s0,character_F) ;test for for 'OFF'3541c // @061 #195: jump(nz,bad_input_command)30091 // @062 #196: call(fetch_char_from_memory)14046 // @063 #197: compare(s0,character_F)3541c // @064 #198: jump(nz,bad_input_command)30091 // @065 #199: call(fetch_char_from_memory)1400d // @066 #200: compare(s0,character_CR)3541c // @067 #201: jump(nz,bad_input_command)00000 // @068 #202: load(s0,0) ;turn alarm off and stop an active alarm2e00c // @069 #203: store(s0,alarm_status)300a4 // @06a #204: call(alarm_drive) ;turn off alarm300ac // @06b #205: call(transmit_alarm_time) ;transmit alarm time and status34012 // @06c #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: ;// @06d #228: [test_time_string]301ec // @06d #228: call(_2char_to_value) ;obtain hours value3588b // @06e #229: jump(c,invalid_time) ;test for non-decimal characters01620 // @06f #230: load(s6,s2) ;remember hours18101 // @070 #231: add(s1,1) ;increment memory pointer past hours30091 // @071 #232: call(fetch_char_from_memory)1403a // @072 #233: compare(s0,character_colon) ;test for colon3548b // @073 #234: jump(nz,invalid_time)301ec // @074 #235: call(_2char_to_value) ;obtain minutes value3588b // @075 #236: jump(c,invalid_time) ;test for non-decimal characters01520 // @076 #237: load(s5,s2) ;remember minutes18101 // @077 #238: add(s1,1) ;increment memory pointer past minutes30091 // @078 #239: call(fetch_char_from_memory)1403a // @079 #240: compare(s0,character_colon) ;test for colon3548b // @07a #241: jump(nz,invalid_time)301ec // @07b #242: call(_2char_to_value) ;obtain seconds value3588b // @07c #243: jump(c,invalid_time) ;test for non-decimal characters01420 // @07d #244: load(s4,s2) ;remember minutes18101 // @07e #245: add(s1,1) ;increment memory pointer past seconds30091 // @07f #246: call(fetch_char_from_memory)1400d // @080 #247: compare(s0,character_CR) ;finish with carriage return3548b // @081 #248: jump(nz,invalid_time)// #249: ;Have values for hh:mm:ss but need to test if each is valid range.14618 // @082 #250: compare(s6,hours_in_a_day)35c8b // @083 #251: jump(nc,invalid_time)1453c // @084 #252: compare(s5,minutes_in_an_hour)35c8b // @085 #253: jump(nc,invalid_time)1443c // @086 #254: compare(s4,seconds_in_a_minute)35c8b // @087 #255: jump(nc,invalid_time)00000 // @088 #256: load(s0,0)2000e // @089 #257: sr0(s0) ;reset CARRY flag (with s0=0)2a000 // @08a #258: return ;time string was OK// @08b #259: [invalid_time]30125 // @08b #259: call(send_Invalid)300e7 // @08c #260: call(send_space)30134 // @08d #261: call(send_Time)00001 // @08e #262: load(s0,1)2000e // @08f #263: sr0(s0) ;set CARRY flag2a000 // @090 #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: ;// @091 #275: [fetch_char_from_memory]07010 // @091 #275: fetch(s0,s1) ;read character301e2 // @092 #276: call(upper_case) ;convert to upper case18101 // @093 #277: add(s1,1) ;increment memory pointer2a000 // @094 #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: ;// @095 #294: [read_from_UART]04000 // @095 #294: input(s0,UART_status_port) ;test Rx_FIFO buffer12010 // @096 #295: test(s0,rx_data_present)3549a // @097 #296: jump(nz,read_character)30185 // @098 #297: call(update_time) ;Perform useful operation whilst waiting34095 // @099 #298: jump(read_from_UART)// @09a #299: [read_character]04f01 // @09a #299: input(UART_data,UART_read_port) ;read from FIFO3009d // @09b #300: call(send_to_UART) ;echo received character2a000 // @09c #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: ;// @09d #325: [send_to_UART]04000 // @09d #325: input(s0,UART_status_port) ;test Tx_FIFO buffer12002 // @09e #326: test(s0,tx_full)350a2 // @09f #327: jump(z,UART_write)30185 // @0a0 #328: call(update_time) ;Perform useful operation whilst waiting3409d // @0a1 #329: jump(send_to_UART)// @0a2 #330: [UART_write]2cf01 // @0a2 #330: output(UART_data,UART_write_port)2a000 // @0a3 #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: ;// @0a4 #343: [alarm_drive]0600c // @0a4 #343: fetch(s0,alarm_status) ;read status0a001 // @0a5 #344: and(s0,alarm_active) ;isolate bit02c000 // @0a6 #345: output(s0,alarm_port)2a000 // @0a7 #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: ;// @0a8 #371: [transmit_time]00e06 // @0a8 #371: load(store_pointer,real_time_hours) ;locate current time in memory30160 // @0a9 #372: call(time_to_ASCII)300bc // @0aa #373: call(transmit_string)2a000 // @0ab #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: ;// @0ac #396: [transmit_alarm_time]00e09 // @0ac #396: load(store_pointer,alarm_time_hours) ;locate alarm time in memory30160 // @0ad #397: call(time_to_ASCII)300bc // @0ae #398: call(transmit_string)3013d // @0af #399: call(send_Alarm)300e7 // @0b0 #400: call(send_space)0600c // @0b1 #401: fetch(s0,alarm_status) ;read alarm status12001 // @0b2 #402: test(s0,alarm_active) ;test for active350b6 // @0b3 #403: jump(z,test_armed)30153 // @0b4 #404: call(send_Active)2a000 // @0b5 #405: return// @0b6 #406: [test_armed]12002 // @0b6 #406: test(s0,alarm_armed) ;test for on350ba // @0b7 #407: jump(z,alarm_is_off)3014e // @0b8 #408: call(send_ON)2a000 // @0b9 #409: return// @0ba #410: [alarm_is_off]30148 // @0ba #410: call(send_OFF)2a000 // @0bb #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 + -
显示快捷键?