ls_test.rmh

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

RMH
1,595
字号
04010 // @17b #715: INPUT(s0,line_store4c_output_L)30213 // @17c #716: CALL(send_hex_byte)30220 // @17d #717: CALL(send_space)30220 // @17e #718: CALL(send_space)04014 // @17f #719: INPUT(s0,line_store5_output_H) ;read 12-bit line store 5 output and display30219 // @180 #720: CALL(send_nibble)04013 // @181 #721: INPUT(s0,line_store5_output_L)30213 // @182 #722: CALL(send_hex_byte)30220 // @183 #723: CALL(send_space)30220 // @184 #724: CALL(send_space)04016 // @185 #725: INPUT(s0,line_store6_output_H) ;read 9-bit line store 6 output and display30219 // @186 #726: CALL(send_nibble)04015 // @187 #727: INPUT(s0,line_store6_output_L)30213 // @188 #728: CALL(send_hex_byte)30220 // @189 #729: CALL(send_space)30220 // @18a #730: CALL(send_space)04019 // @18b #731: INPUT(s0,line_store7a_output_H) ;read 24-bit line store 7 output 'A' and display30213 // @18c #732: CALL(send_hex_byte)04018 // @18d #733: INPUT(s0,line_store7a_output_M)30213 // @18e #734: CALL(send_hex_byte)04017 // @18f #735: INPUT(s0,line_store7a_output_L)30213 // @190 #736: CALL(send_hex_byte)30220 // @191 #737: CALL(send_space)0401c // @192 #738: INPUT(s0,line_store7b_output_H) ;read 24-bit line store 7 output 'B' and display30213 // @193 #739: CALL(send_hex_byte)0401b // @194 #740: INPUT(s0,line_store7b_output_M)30213 // @195 #741: CALL(send_hex_byte)0401a // @196 #742: INPUT(s0,line_store7b_output_L)30213 // @197 #743: CALL(send_hex_byte)3021d // @198 #744: CALL(send_CR)// #745: ;// #746: ;// @199 #747: [skip_display]2c008 // @199 #747: OUTPUT(s0,line_store_write_en) ;dummy write to enable line stores0600c // @19a #748: FETCH(s0,auto_inc) ;increment input value if auto is 'on'19a00 // @19b #749: ADD(sA,s0)1ab00 // @19c #750: ADDCY(sB,0)1ac00 // @19d #751: ADDCY(sC,0)2ea05 // @19e #752: STORE(sA,test_data_in0) ;store new line store input value2eb06 // @19f #753: STORE(sB,test_data_in1)2ec07 // @1a0 #754: STORE(sC,test_data_in2)2ca01 // @1a1 #755: OUTPUT(sA,line_store_input_L) ;Write data to register driving line store2cb02 // @1a2 #756: OUTPUT(sB,line_store_input_M)2cc04 // @1a3 #757: OUTPUT(sC,line_store_input_H)2a000 // @1a4 #758: RETURN// #759: ;// #760: ;// #761: ;**************************************************************************************// #762: ; UART communication routines// #763: ;**************************************************************************************// #764: ;// #765: ; Read one character from the UART// #766: ;// #767: ; Character read will be returned in a register called 'UART_data'.// #768: ;// #769: ; The routine first tests the receiver FIFO buffer to see if data is present.// #770: ; If the FIFO is empty, the routine waits until there is a character to read.// #771: ; As this could take any amount of time the wait loop could include a call to a// #772: ; subroutine which performs a useful function.// #773: ;// #774: ;// #775: ; Registers used s0 and UART_data// #776: ;// @1a5 #777: [read_from_UART]04000 // @1a5 #777: INPUT(s0,status_port) ;test Rx_FIFO buffer12004 // @1a6 #778: TEST(s0,rx_data_present) ;wait if empty355a9 // @1a7 #779: JUMP(NZ,read_character)341a5 // @1a8 #780: JUMP(read_from_UART)// @1a9 #781: [read_character]04f01 // @1a9 #781: INPUT(UART_data,UART_read_port) ;read from FIFO2a000 // @1aa #782: RETURN// #783: ;// #784: ;// #785: ;// #786: ; Transmit one character to the UART// #787: ;// #788: ; Character supplied in register called 'UART_data'.// #789: ;// #790: ; The routine first tests the transmit FIFO buffer to see if it is full.// #791: ; If the FIFO is full, then the routine waits until it there is space.// #792: ;// #793: ; Registers used s0// #794: ;// @1ab #795: [send_to_UART]04000 // @1ab #795: INPUT(s0,status_port) ;test Tx_FIFO buffer12002 // @1ac #796: TEST(s0,tx_full) ;wait if full351af // @1ad #797: JUMP(Z,UART_write)341ab // @1ae #798: JUMP(send_to_UART)// @1af #799: [UART_write]2cf40 // @1af #799: OUTPUT(UART_data,UART_write_port)2a000 // @1b0 #800: RETURN// #801: ;// #802: ;// #803: ;**************************************************************************************// #804: ; Receive ASCII string from UART// #805: ;**************************************************************************************// #806: ;// #807: ;An ASCII string will be read from the UART and stored in scratch pad memory// #808: ;commencing at the location specified by a constant named 'string_start'.// #809: ;The string will have a maximum length of 16 characters including a// #810: ;carriage return (0D) denoting the end of the string.// #811: ;// #812: ;As each character is read, it is echoed to the UART transmitter.// #813: ;Some minor editing is supported using backspace (BS=08) which is used// #814: ;to adjust what is stored in scratch pad memory and adjust the display// #815: ;on the terminal screen using characters sent to the UART transmitter.// #816: ;// #817: ;A test is made for the receiver FIFO becoming full. A full status is treated as// #818: ;a potential error situation and will result in a 'Overflow Error' message being// #819: ;transmitted to the UART, the receiver FIFO being purged of all data and an// #820: ;empty string being stored (carriage return at first location).// #821: ;// #822: ;Registers used s0, s1, s2 and 'UART_data'.// #823: ;// @1b1 #824: [receive_string]00130 // @1b1 #824: LOAD(s1,string_start) ;locate start of string01210 // @1b2 #825: LOAD(s2,s1) ;compute 16 character address18210 // @1b3 #826: ADD(s2,16)// @1b4 #827: [receive_full_test]04000 // @1b4 #827: INPUT(s0,status_port) ;test Rx_FIFO buffer for full12010 // @1b5 #828: TEST(s0,rx_full)355ca // @1b6 #829: JUMP(NZ,read_error)301a5 // @1b7 #830: CALL(read_from_UART) ;obtain and echo character301ab // @1b8 #831: CALL(send_to_UART)2ff10 // @1b9 #832: STORE(UART_data,s1) ;write to memory14f0d // @1ba #833: COMPARE(UART_data,character_CR) ;test for end of string2b000 // @1bb #834: RETURN(Z)14f08 // @1bc #835: COMPARE(UART_data,character_BS) ;test for back space351c2 // @1bd #836: JUMP(Z,BS_edit)18101 // @1be #837: ADD(s1,1) ;increment memory pointer15120 // @1bf #838: COMPARE(s1,s2) ;test for pointer exceeding 16 characters355b4 // @1c0 #839: JUMP(NZ,receive_full_test) ;next character30223 // @1c1 #840: CALL(send_backspace) ;hold end of string position on terminal display// @1c2 #841: [BS_edit]1c101 // @1c2 #841: SUB(s1,1) ;memory pointer back one14130 // @1c3 #842: COMPARE(s1,string_start) ;test for under flow359c8 // @1c4 #843: JUMP(C,string_start_again)30220 // @1c5 #844: CALL(send_space) ;clear character at current position30223 // @1c6 #845: CALL(send_backspace) ;position cursor341b4 // @1c7 #846: JUMP(receive_full_test) ;next character// @1c8 #847: [string_start_again]3026b // @1c8 #847: CALL(send_greater_than) ;restore '>' at prompt341b1 // @1c9 #848: JUMP(receive_string) ;begin again// #849: ;Receiver buffer overflow condition// @1ca #850: [read_error]3021d // @1ca #850: CALL(send_CR) ;Transmit error message2ef30 // @1cb #851: STORE(UART_data,string_start) ;empty string in memory (start with CR)3026e // @1cc #852: CALL(send_Overflow_Error)3021d // @1cd #853: CALL(send_CR)// @1ce #854: [clear_UART_Rx_loop]04000 // @1ce #854: INPUT(s0,status_port) ;test Rx_FIFO buffer for data12004 // @1cf #855: TEST(s0,rx_data_present)2b000 // @1d0 #856: RETURN(Z) ;finish when buffer is empty04f01 // @1d1 #857: INPUT(UART_data,UART_read_port) ;read from FIFO and ignore341ce // @1d2 #858: JUMP(clear_UART_Rx_loop)// #859: ;// #860: ;// #861: ;**************************************************************************************// #862: ; Useful ASCII conversion and handling routines// #863: ;**************************************************************************************// #864: ;// #865: ;// #866: ;// #867: ; Convert character to upper case// #868: ;// #869: ; The character supplied in register s0.// #870: ; If the character is in the range 'a' to 'z', it is converted// #871: ; to the equivalent upper case character in the range 'A' to 'Z'.// #872: ; All other characters remain unchanged.// #873: ;// #874: ; Registers used s0.// #875: ;// @1d3 #876: [upper_case]14061 // @1d3 #876: COMPARE(s0,97) ;eliminate character codes below 'a' (61 hex)2b800 // @1d4 #877: RETURN(C)1407b // @1d5 #878: COMPARE(s0,123) ;eliminate character codes above 'z' (7A hex)2bc00 // @1d6 #879: RETURN(NC)0a0df // @1d7 #880: AND(s0,DF) ;mask bit5 to convert to upper case2a000 // @1d8 #881: RETURN// #882: ;// #883: ;// #884: ;// #885: ; Convert string held in scratch pad memory to upper case.// #886: ;// #887: ; Registers used s0, s1// #888: ;// @1d9 #889: [upper_case_string]00130 // @1d9 #889: LOAD(s1,string_start)// @1da #890: [ucs_loop]07010 // @1da #890: FETCH(s0,s1)1400d // @1db #891: COMPARE(s0,character_CR)2b000 // @1dc #892: RETURN(Z)301d3 // @1dd #893: CALL(upper_case)2f010 // @1de #894: STORE(s0,s1)18101 // @1df #895: ADD(s1,1)341da // @1e0 #896: JUMP(ucs_loop)// #897: ;// #898: ;// #899: ; Convert character '0' to '9' to numerical value in range 0 to 9// #900: ;// #901: ; The character supplied in register s0. If the character is in the// #902: ; range '0' to '9', it is converted to the equivalent decimal value.// #903: ; Characters not in the range '0' to '9' are signified by the return// #904: ; with the CARRY flag set.// #905: ;// #906: ; Registers used s0.// #907: ;// @1e1 #908: [onechar_to_value]180c6 // @1e1 #908: ADD(s0,C6) ;reject character codes above '9' (39 hex)2b800 // @1e2 #909: RETURN(C) ;carry flag is set1c0f6 // @1e3 #910: SUB(s0,F6) ;reject character codes below '0' (30 hex)2a000 // @1e4 #911: RETURN ;carry is set if value not in range// #912: ;// #913: ;// #914: ;// #915: ; Convert the HEX ASCII characters contained in 's3' and 's2' into// #916: ; an equivalent hexadecimal value in register 's0'.// #917: ;     The upper nibble is represented by an ASCII character in register s3.// #918: ;     The lower nibble is represented by an ASCII character in register s2.// #919: ;// #920: ; Input characters must be in the range 00 to FF hexadecimal or the CARRY flag// #921: ; will be set on return.// #922: ;// #923: ; Registers used s0, s2 and s3.// #924: ;// @1e5 #925: [ASCII_byte_to_hex]01030 // @1e5 #925: LOAD(s0,s3) ;Take upper nibble301f2 // @1e6 #926: CALL(ASCII_to_hex) ;convert to value2b800 // @1e7 #927: RETURN(C) ;reject if out of range01300 // @1e8 #928: LOAD(s3,s0) ;remember value20306 // @1e9 #929: SL0(s3) ;multiply value by 16 to put in upper nibble20306 // @1ea #930: SL0(s3)20306 // @1eb #931: SL0(s3)20306 // @1ec #932: SL0(s3)01020 // @1ed #933: LOAD(s0,s2) ;Take lower nibble301f2 // @1ee #934: CALL(ASCII_to_hex) ;convert to value2b800 // @1ef #935: RETURN(C) ;reject if out of range0d030 // @1f0 #936: OR(s0,s3) ;merge in the upper nibble with CARRY reset2a000 // @1f1 #937: RETURN// #938: ;// #939: ;// #940: ; Routine to convert ASCII data in 's0' to an equivalent HEX value.// #941: ;// #942: ; If character is not valid for hex, then CARRY is set on return.// #943: ;// #944: ; Register used s0// #945: ;// @1f2 #946: [ASCII_to_hex]180b9 // @1f2 #946: ADD(s0,B9) ;test for above ASCII code 46 ('F')2b800 // @1f3 #947: RETURN(C)1c0e9 // @1f4 #948: SUB(s0,E9) ;normalise 0 to 9 with A-F in 11 to 16 hex2b800 // @1f5 #949: RETURN(C) ;reject below ASCII code 30 ('0')1c011 // @1f6 #950: SUB(s0,17) ;isolate A-F down to 00 to 05 hex35dfc // @1f7 #951: JUMP(NC,ASCII_letter)18007 // @1f8 #952: ADD(s0,7) ;test for above ASCII code 46 ('F')2b800 // @1f9 #953: RETURN(C)1c0f6 // @1fa #954: SUB(s0,F6) ;convert to range 00 to 092a000 // @1fb #955: RETURN// @1fc #956: [ASCII_letter]1800a // @1fc #956: ADD(s0,10) ;convert to range 0A to 0F2a000 // @1fd #957: RETURN// #958: ;// #959: ;// #960: ;// #961: ;// #962: ; Routine to convert ASCII data in 's0' to an equivalent DECIMAL value.// #963: ;// #964: ; If character is not valid for decimal, then CARRY is set on return.// #965: ;// #966: ; Register used s0// #967: ;// @1fe #968: [ASCII_to_decimal]180c6 // @1fe #968: ADD(s0,C6) ;test for above ASCII code 39 ('9')2b800 // @1ff #969: RETURN(C)1c0f6 // @200 #970: SUB(s0,F6) ;normalise to 0 to 92a000 // @201 #971: RETURN ;carry set for ASCII code below 30 ('0')// #972: ;// #973: ;// #974: ;// #975: ; Convert hexadecimal value provided in register s0 into ASCII characters// #976: ;// #977: ; The value provided must can be any value in the range 00 to FF and will be converted into// #978: ; two ASCII characters.// #979: ;     The upper nibble will be represented by an ASCII character returned in register s2.// #980: ;     The lower nibble will be represented by an ASCII character returned in register s1.// #981: ;// #982: ; The ASCII representations of '0' to '9' are 30 to 39 hexadecimal which is simply 30 hex// #983: ; added to the actual decimal value. The ASCII representations of 'A' to 'F' are 41 to 46// #984: ; hexadecimal requiring a further addition of 07 to the 30 already added.// #985: ;// #986: ; Registers used s0, s1 and s2.// #987: ;// @202 #988: [hex_byte_to_ASCII]01100 // @202 #988: LOAD(s1,s0) ;remember value supplied2000e // @203 #989: SR0(s0) ;isolate upper nibble2000e // @204 #990: SR0(s0)2000e // @205 #991: SR0(s0)2000e // @206 #992: SR0(s0)3020e // @207 #993: CALL(hex_to_ASCII) ;convert01200 // @208 #994: LOAD(s2,s0) ;upper nibble value in s201010 // @209 #995: LOAD(s0,s1) ;restore complete value0a00f // @20a #996: AND(s0,15) ;isolate lower nibble3020e // @20b #997: CALL(hex_to_ASCII) ;convert01100 // @20c #998: LOAD(s1,s0) ;lower nibble value in s12a000 // @20d #999: RETURN// #1000: ;// #1001: ; Convert hexadecimal value provided in register s0 into ASCII character// #1002: ;// #1003: ;Register used s0// #1004: ;// @20e #1005: [hex_to_ASCII]1c00a // @20e #1005: SUB(s0,10) ;test if value is in range 0 to 935a11 // @20f #1006: JUMP(C,number_char)18007 // @210 #1007: ADD(s0,7) ;ASCII char A to F in range 41 to 46// @211 #1008: [number_char]1803a // @211 #1008: ADD(s0,58) ;ASCII char 0 to 9 in range 30 to 402a000 // @212 #1009: RETURN// #1010: ;// #1011: ;

⌨️ 快捷键说明

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