1 |
2 |
sinclairrf |
; Copyright 2013, Sinclair R.F., Inc.
|
2 |
4 |
sinclairrf |
; Test bench for ../../char.s
|
3 |
2 |
sinclairrf |
|
4 |
|
|
.include char.s
|
5 |
|
|
|
6 |
|
|
.main
|
7 |
|
|
|
8 |
|
|
; Test the single hex digit to nibble conversion.
|
9 |
|
|
0x00 ${ord('0')-1} '0' '9' ${ord('9')+1} ${ord('A')-1} 'A' 'F' ${ord('F')+1} ${ord('a')-1} 'a' 'f' ${ord('f')+1}
|
10 |
|
|
${13-1} :loop__hex_to_nibble .call(test__hex_to_nibble,swap) .jumpc(loop__hex_to_nibble,1-) drop
|
11 |
|
|
|
12 |
|
|
; Test dual hex digit to nibble conversion.
|
13 |
|
|
"0A" "0F" "0G" "A0" "F0" "G0"
|
14 |
|
|
${6-1} :loop__2hex_to_byte >r .call(test__2hex_to_byte) r> .jumpc(loop__2hex_to_byte,1-) drop
|
15 |
|
|
|
16 |
|
|
; Test the nibble to hex digit conversion.
|
17 |
|
|
0x00 0x09 0x0A 0x0F
|
18 |
|
|
${4-1} :loop__nibble_to_hex .call(test__nibble_to_hex,swap) .jumpc(loop__nibble_to_hex,1-) drop
|
19 |
|
|
|
20 |
|
|
; Test the byte to 2-digit hex conversion.
|
21 |
|
|
0x00 0x09 0x0A 0x0F 0x90 0x99 0x9A 0x9F 0xA0 0xA9 0xAA 0xAF 0xF0 0xF9 0xFA 0xFF
|
22 |
|
|
${16-1} :loop__byte_to_2hex .call(test__byte_to_2hex,swap) .jumpc(loop__byte_to_2hex,1-) drop
|
23 |
|
|
|
24 |
|
|
; terminate and wait forever
|
25 |
|
|
.outstrobe(O_TERMINATE) :infinite .jump(infinite)
|
26 |
|
|
|
27 |
|
|
; Evaluate the nibble to hex conversion and the output the error status, the
|
28 |
|
|
; converted value, and the original value.
|
29 |
|
|
.function test__byte_to_2hex
|
30 |
|
|
.call(char__byte_to_2hex,dup) .outport(O_VALUE) .outport(O_VALUE) .outport(O_VALUE) .return
|
31 |
|
|
|
32 |
|
|
; Evaluate the nibble to hex conversion and the output the error status, the
|
33 |
|
|
; converted value, and the original value.
|
34 |
|
|
.function test__nibble_to_hex
|
35 |
|
|
.call(char__nibble_to_hex,dup) .outport(O_VALUE) .outport(O_VALUE) .return
|
36 |
|
|
|
37 |
|
|
; Evaluate the 2-digit hex to byte conversion and the output the error status,
|
38 |
|
|
; the converted value, and the original values.
|
39 |
|
|
.function test__2hex_to_byte
|
40 |
|
|
over .call(char__2hex_to_byte,over) .outport(O_VALUE) .outport(O_VALUE) .outport(O_VALUE) .outport(O_VALUE) .return
|
41 |
|
|
|
42 |
|
|
; Evaluate the hex to nibble conversion and the output the error status, the
|
43 |
|
|
; converted value, and the original value.
|
44 |
|
|
.function test__hex_to_nibble
|
45 |
|
|
.call(char__hex_to_nibble,dup) .outport(O_VALUE) .outport(O_VALUE) .outport(O_VALUE) .return
|