hex.input_as_hex (arity 2)¶
hex = hex_from_ascii(input(1byte))
*supports 0-9,a-f,A-F. if can’t cast, jumps to error.
Signature¶
def input_as_hex hex, error @ try_dec, do_dec, do_hex, hex_switch, finish_hex, upper, end { ... }
Defined in hex/input.fj — lines 48–86 (view on GitHub).
Complexity¶
Time:
7@+11Space:
8.5@+92
See the complexity glossary for what @, w, dw, dbit, n mean.
Source¶
Click to view the macro body
def input_as_hex hex, error @ try_dec, do_dec, do_hex, hex_switch, finish_hex, upper, end {
.input_hex hex
.input_hex upper
.if_flags upper, (1<<4)|(1<<6), try_dec, do_hex
try_dec:
.if_flags upper, (1<<3), error, do_dec
do_dec: // if input==0x3i for 0<=i<=9, finish; else, goto error.
.if_flags hex, (1<<10)-1, error, end
do_hex: // if input==0x4i or input==0x6i:
wflip hex+w, hex_switch, hex
finish_hex:
hex+dbit+3;
wflip hex+w, hex_switch, end
pad 16
hex_switch: // if 1<=hex<=6, hex+=9; else, goto error.
wflip hex+w, hex_switch, error // 0
hex+dbit+1;hex_switch+2*dw // 1
hex+dbit+0;finish_hex // 2
hex+dbit+2;hex_switch+1*dw // 3
hex+dbit+0;finish_hex // 4
hex+dbit+1;hex_switch+2*dw // 5
hex+dbit+0;finish_hex // 6
;hex_switch // 7
;hex_switch
;hex_switch
;hex_switch
;hex_switch
;hex_switch
;hex_switch
;hex_switch
;hex_switch
upper: .hex
end:
}
Depends on¶
← Previous: hex.input/2
Next: hex.input_as_hex/3 →