progctrl.rmh
来自「和picoblaze完全兼容的mcu ip core」· RMH 代码 · 共 1,519 行 · 第 1/5 页
RMH
1,519 行
18101 // @138 #947: ADD(s1,1) ;increment 'tens' value1c00a // @139 #948: SUB(s0,10) ;try to subtract 10 from the supplied value35d38 // @13a #949: JUMP(NC,test_for_ten) ;repeat if subtraction was possible without underflow.1c101 // @13b #950: SUB(s1,1) ;'tens' value one less ten due to underflow1803a // @13c #951: ADD(s0,58) ;restore units value (the remainder) and convert to ASCII2a000 // @13d #952: RETURN// #953: ;// #954: ;// #955: ;// #956: ;Convert character to upper case// #957: ;// #958: ;The character supplied in register s0.// #959: ;If the character is in the range 'a' to 'z', it is converted// #960: ;to the equivalent upper case character in the range 'A' to 'Z'.// #961: ;All other characters remain unchanged.// #962: ;// #963: ;Registers used s0.// #964: ;// @13e #965: [upper_case]14061 // @13e #965: COMPARE(s0,97) ;eliminate character codes below 'a' (61 hex)2b800 // @13f #966: RETURN(C)1407b // @140 #967: COMPARE(s0,123) ;eliminate character codes above 'z' (7A hex)2bc00 // @141 #968: RETURN(NC)0a0df // @142 #969: AND(s0,DF) ;mask bit5 to convert to upper case2a000 // @143 #970: RETURN// #971: ;// #972: ;// #973: ;Convert character '0' to '9' to numerical value in range 0 to 9// #974: ;// #975: ;The character supplied in register s0. If the character is in the// #976: ;range '0' to '9', it is converted to the equivalent decimal value.// #977: ;Characters not in the range '0' to '9' are signified by the return// #978: ;with the CARRY flag set.// #979: ;// #980: ;Registers used s0.// #981: ;// @144 #982: [onechar_to_value]180c6 // @144 #982: ADD(s0,C6) ;reject character codes above '9' (39 hex)2b800 // @145 #983: RETURN(C) ;carry flag is set1c0f6 // @146 #984: SUB(s0,F6) ;reject character codes below '0' (30 hex)2a000 // @147 #985: RETURN ;carry is set if value not in range// #986: ;// #987: ;// #988: ;Determine the numerical value of a two character decimal string held in// #989: ;scratch pad memory such the result is in the range 0 to 99 (00 to 63 hex).// #990: ;// #991: ;The string must be stored in two consecutive memory locations and the// #992: ;location of the first (tens) character supplied in the s1 register.// #993: ;The result is provided in register s2. Strings not using characters in the// #994: ;range '0' to '9' are signified by the return with the CARRY flag set.// #995: ;// #996: ;Registers used s0, s1 and s2.// #997: ;// @148 #998: [twochar_to_value]07010 // @148 #998: FETCH(s0,s1) ;read 'tens' character30144 // @149 #999: CALL(onechar_to_value) ;convert to numerical value2b800 // @14a #1000: RETURN(C) ;bad character - CARRY set01200 // @14b #1001: LOAD(s2,s0)20206 // @14c #1002: SL0(s2) ;multiply 'tens' value by 10 (0A hex)20206 // @14d #1003: SL0(s2)19200 // @14e #1004: ADD(s2,s0)20206 // @14f #1005: SL0(s2)18101 // @150 #1006: ADD(s1,1) ;read 'units' character07010 // @151 #1007: FETCH(s0,s1)30144 // @152 #1008: CALL(onechar_to_value) ;convert to numerical value2b800 // @153 #1009: RETURN(C) ;bad character - CARRY set19200 // @154 #1010: ADD(s2,s0) ;add units to result and clear CARRY flag2a000 // @155 #1011: RETURN// #1012: ;// #1013: ;// #1014: ;Convert hexadecimal value provided in register s0 into ASCII characters// #1015: ;// #1016: ;The value provided must can be any value in the range 00 to FF and will be converted into// #1017: ;two ASCII characters.// #1018: ; The upper nibble will be represented by an ASCII character returned in register s2.// #1019: ; The lower nibble will be represented by an ASCII character returned in register s1.// #1020: ;// #1021: ;The ASCII representations of '0' to '9' are 30 to 39 hexadecimal which is simply 30 hex// #1022: ;added to the actual decimal value. The ASCII representations of 'A' to 'F' are 41 to 46// #1023: ;hexadecimal requiring a further addition of 07 to the 30 already added.// #1024: ;// #1025: ;Registers used s0, s1 and s2.// #1026: ;// @156 #1027: [hex_byte_to_ASCII]01100 // @156 #1027: LOAD(s1,s0) ;remember value supplied2000e // @157 #1028: SR0(s0) ;isolate upper nibble2000e // @158 #1029: SR0(s0)2000e // @159 #1030: SR0(s0)2000e // @15a #1031: SR0(s0)30162 // @15b #1032: CALL(hex_to_ASCII) ;convert01200 // @15c #1033: LOAD(s2,s0) ;upper nibble value in s201010 // @15d #1034: LOAD(s0,s1) ;restore complete value0a00f // @15e #1035: AND(s0,15) ;isolate lower nibble30162 // @15f #1036: CALL(hex_to_ASCII) ;convert01100 // @160 #1037: LOAD(s1,s0) ;lower nibble value in s12a000 // @161 #1038: RETURN// #1039: ;// #1040: ;Convert hexadecimal value provided in register s0 into ASCII character// #1041: ;// #1042: ;Register used s0// #1043: ;// @162 #1044: [hex_to_ASCII]1c00a // @162 #1044: SUB(s0,10) ;test if value is in range 0 to 935965 // @163 #1045: JUMP(C,number_char)18007 // @164 #1046: ADD(s0,7) ;ASCII char A to F in range 41 to 46// @165 #1047: [number_char]1803a // @165 #1047: ADD(s0,58) ;ASCII char 0 to 9 in range 30 to 402a000 // @166 #1048: RETURN// #1049: ;// #1050: ;// #1051: ;Send the two character HEX value of the register contents 's0' to the UART// #1052: ;// #1053: ;Registers used s0, s1, s2// #1054: ;// @167 #1055: [send_hex_byte]30156 // @167 #1055: CALL(hex_byte_to_ASCII)01f20 // @168 #1056: LOAD(UART_data,s2)30131 // @169 #1057: CALL(send_to_UART)01f10 // @16a #1058: LOAD(UART_data,s1)30131 // @16b #1059: CALL(send_to_UART)2a000 // @16c #1060: RETURN// #1061: ;// #1062: ;// #1063: ;// #1064: ;Send the six character HEX value of the register contents [s9,s8,s7] to the UART// #1065: ;// #1066: ;Registers used s0, s1, s2// #1067: ;// @16d #1068: [send_hex_3bytes]01090 // @16d #1068: LOAD(s0,s9)30167 // @16e #1069: CALL(send_hex_byte)01080 // @16f #1070: LOAD(s0,s8)30167 // @170 #1071: CALL(send_hex_byte)01070 // @171 #1072: LOAD(s0,s7)30167 // @172 #1073: CALL(send_hex_byte)2a000 // @173 #1074: RETURN// #1075: ;// #1076: ;// #1077: ;Convert the HEX ASCII characters contained in 's3' and 's2' into// #1078: ;an equivalent hexadecimal value in register 's0'.// #1079: ; The upper nibble is represented by an ASCII character in register s3.// #1080: ; The lower nibble is represented by an ASCII character in register s2.// #1081: ;// #1082: ;Input characters must be in the range 00 to FF hexadecimal or the CARRY flag// #1083: ;will be set on return.// #1084: ;// #1085: ;Registers used s0, s2 and s3.// #1086: ;// @174 #1087: [ASCII_byte_to_hex]01030 // @174 #1087: LOAD(s0,s3) ;Take upper nibble30181 // @175 #1088: CALL(ASCII_to_hex) ;convert to value2b800 // @176 #1089: RETURN(C) ;reject if out of range01300 // @177 #1090: LOAD(s3,s0) ;remember value20306 // @178 #1091: SL0(s3) ;multiply value by 16 to put in upper nibble20306 // @179 #1092: SL0(s3)20306 // @17a #1093: SL0(s3)20306 // @17b #1094: SL0(s3)01020 // @17c #1095: LOAD(s0,s2) ;Take lower nibble30181 // @17d #1096: CALL(ASCII_to_hex) ;convert to value2b800 // @17e #1097: RETURN(C) ;reject if out of range0d030 // @17f #1098: OR(s0,s3) ;merge in the upper nibble with CARRY reset2a000 // @180 #1099: RETURN// #1100: ;// #1101: ;// #1102: ;Routine to convert ASCII data in 's0' to an equivalent HEX value.// #1103: ;// #1104: ;If character is not valid for hex, then CARRY is set on return.// #1105: ;// #1106: ;Register used s0// #1107: ;// @181 #1108: [ASCII_to_hex]180b9 // @181 #1108: ADD(s0,B9) ;test for above ASCII code 46 ('F')2b800 // @182 #1109: RETURN(C)1c0e9 // @183 #1110: SUB(s0,E9) ;normalise 0 to 9 with A-F in 11 to 16 hex2b800 // @184 #1111: RETURN(C) ;reject below ASCII code 30 ('0')1c011 // @185 #1112: SUB(s0,17) ;isolate A-F down to 00 to 05 hex35d8b // @186 #1113: JUMP(NC,ASCII_letter)18007 // @187 #1114: ADD(s0,7) ;test for above ASCII code 46 ('F')2b800 // @188 #1115: RETURN(C)1c0f6 // @189 #1116: SUB(s0,F6) ;convert to range 00 to 092a000 // @18a #1117: RETURN// @18b #1118: [ASCII_letter]1800a // @18b #1118: ADD(s0,10) ;convert to range 0A to 0F2a000 // @18c #1119: RETURN// #1120: ;// #1121: ;// #1122: ;Read two hex characters from UART and convert to single byte data// #1123: ;// @18d #1124: [obtain_8bits]30022 // @18d #1124: CALL(read_upper_case) ;obtain one byte from UART01300 // @18e #1125: LOAD(s3,s0)30022 // @18f #1126: CALL(read_upper_case)01200 // @190 #1127: LOAD(s2,s0)30174 // @191 #1128: CALL(ASCII_byte_to_hex)2a000 // @192 #1129: RETURN// #1130: ;// #1131: ;**************************************************************************************// #1132: ;Text messages// #1133: ;**************************************************************************************// #1134: ;// #1135: ;// #1136: ;Send Carriage Return to the UART// #1137: ;// @193 #1138: [send_CR]00f0d // @193 #1138: LOAD(UART_data,character_CR)30131 // @194 #1139: CALL(send_to_UART)2a000 // @195 #1140: RETURN// #1141: ;// #1142: ;Send a space to the UART// #1143: ;// @196 #1144: [send_space]00f20 // @196 #1144: LOAD(UART_data,character_space)30131 // @197 #1145: CALL(send_to_UART)2a000 // @198 #1146: RETURN// #1147: ;// #1148: ;// #1149: ;Send 'PicoBlaze NOR FLASH Programmer' string to the UART// #1150: ;// @199 #1151: [send_welcome]30193 // @199 #1151: CALL(send_CR)30193 // @19a #1152: CALL(send_CR)00f50 // @19b #1153: LOAD(UART_data,character_P)30131 // @19c #1154: CALL(send_to_UART)00f69 // @19d #1155: LOAD(UART_data,character_i)30131 // @19e #1156: CALL(send_to_UART)00f63 // @19f #1157: LOAD(UART_data,character_c)30131 // @1a0 #1158: CALL(send_to_UART)00f6f // @1a1 #1159: LOAD(UART_data,character_o)30131 // @1a2 #1160: CALL(send_to_UART)00f42 // @1a3 #1161: LOAD(UART_data,character_B)30131 // @1a4 #1162: CALL(send_to_UART)00f6c // @1a5 #1163: LOAD(UART_data,character_l)30131 // @1a6 #1164: CALL(send_to_UART)00f61 // @1a7 #1165: LOAD(UART_data,character_a)30131 // @1a8 #1166: CALL(send_to_UART)00f7a // @1a9 #1167: LOAD(UART_data,character_z)30131 // @1aa #1168: CALL(send_to_UART)00f65 // @1ab #1169: LOAD(UART_data,character_e)30131 // @1ac #1170: CALL(send_to_UART)30196 // @1ad #1171: CALL(send_space)00f4e // @1ae #1172: LOAD(UART_data,character_N)30131 // @1af #1173: CALL(send_to_UART)00f4f // @1b0 #1174: LOAD(UART_data,character_O)30131 // @1b1 #1175: CALL(send_to_UART)00f52 // @1b2 #1176: LOAD(UART_data,character_R)30131 // @1b3 #1177: CALL(send_to_UART)30196 // @1b4 #1178: CALL(send_space)00f46 // @1b5 #1179: LOAD(UART_data,character_F)30131 // @1b6 #1180: CALL(send_to_UART)00f4c // @1b7 #1181: LOAD(UART_data,character_L)30131 // @1b8 #1182: CALL(send_to_UART)00f41 // @1b9 #1183: LOAD(UART_data,character_A)30131 // @1ba #1184: CALL(send_to_UART)00f53 // @1bb #1185: LOAD(UART_data,character_S)30131 // @1bc #1186: CALL(send_to_UART)00f48 // @1bd #1187: LOAD(UART_data,character_H)30131 // @1be #1188: CALL(send_to_UART)30196 // @1bf #1189: CALL(send_space)00f50 // @1c0 #1190: LOAD(UART_data,character_P)30131 // @1c1 #1191: CALL(send_to_UART)00f72 // @1c2 #1192: LOAD(UART_data,character_r)30131 // @1c3 #1193: CALL(send_to_UART)00f6f // @1c4 #1194: LOAD(UART_data,character_o)30131 // @1c5 #1195: CALL(send_to_UART)00f67 // @1c6 #1196: LOAD(UART_data,character_g)30131 // @1c7 #1197: CALL(send_to_UART)00f72 // @1c8 #1198: LOAD(UART_data,character_r)30131 // @1c9 #1199: CALL(send_to_UART)00f61 // @1ca #1200: LOAD(UART_data,character_a)30131 // @1cb #1201: CALL(send_to_UART)00f6d // @1cc #1202: LOAD(UART_data,character_m)30131 // @1cd #1203: CALL(send_to_UART)00f6d // @1ce #1204: LOAD(UART_data,character_m)30131 // @1cf #1205: CALL(send_to_UART)00f65 // @1d0 #1206: LOAD(UART_data,character_e)30131 // @1d1 #1207: CALL(send_to_UART)00f72 // @1d2 #1208: LOAD(UART_data,character_r)30131 // @1d3 #1209: CALL(send_to_UART)30196 // @1d4 #1210: CALL(send_space)00f76 // @1d5 #1211: LOAD(UART_data,character_v)30131 // @1d6 #1212: CALL(send_to_UART)00f31 // @1d7 #1213: LOAD(UART_data,character_1)30131 // @1d8 #1214: CALL(send_to_UART)00f2e // @1d9 #1215: LOAD(UART_data,character_fullstop)30131 // @1da #1216: CALL(send_to_UART)00f30 // @1db #1217: LOAD(UART_data,character_0)30131 // @1dc #1218: CALL(send_to_UART)00f30 // @1dd #1219: LOAD(UART_data,character_0)30131 // @1de #1220: CALL(send_to_UART)30193 // @1df #1221: CALL(send_CR)30193 // @1e0 #1222: CALL(send_CR)2a000 // @1e1 #1223: RETURN// #1224: ;// #1225: ;// #1226: ;// #1227: ;Send 'Waiting_MCS_file' string to the UART// #1228: ;// @1e2 #1229: [send_Waiting_MCS_file]00f57 // @1e2 #1229: LOAD(UART_data,character_W)30131 // @1e3 #1230: CALL(send_to_UART)00f61 // @1e4 #1231: LOAD(UART_data,character_a)30131 // @1e5 #1232: CALL(send_to_UART)00f69 // @1e6 #1233: LOAD(UART_dat
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?