5437
Break a dependency from `print-int32` to `from-hex-char`.
This commit is contained in:
parent
8a1a3fb45f
commit
ac8a9396b9
|
@ -5,6 +5,18 @@
|
|||
# . op subop mod rm32 base index scale r32
|
||||
# . 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes
|
||||
|
||||
to-hex-char: # in/EAX : nibble -> out/EAX : byte
|
||||
# no error checking; accepts argument in EAX
|
||||
# if (EAX <= 9) return EAX + '0'
|
||||
3d/compare-EAX-with 0x9/imm32/9
|
||||
7f/jump-if-greater $to-hex-char:else/disp8
|
||||
05/add-to-EAX 0x30/imm32/0
|
||||
c3/return
|
||||
$to-hex-char:else:
|
||||
# otherwise return EAX + 'a' - 10
|
||||
05/add-to-EAX 0x57/imm32/a-10
|
||||
c3/return
|
||||
|
||||
append-byte-hex: # f : (address stream), n : int -> <void>
|
||||
# . prolog
|
||||
55/push-EBP
|
|
@ -1,4 +1,4 @@
|
|||
# some utilities for converting numbers to/from hex
|
||||
# some utilities for converting numbers from hex
|
||||
# lowercase letters only for now
|
||||
|
||||
== code
|
||||
|
@ -806,16 +806,4 @@ $from-hex-char:else:
|
|||
2d/subtract-from-EAX 0x57/imm32/a-10
|
||||
c3/return
|
||||
|
||||
to-hex-char: # in/EAX : nibble -> out/EAX : byte
|
||||
# no error checking; accepts argument in EAX
|
||||
# if (EAX <= 9) return EAX + '0'
|
||||
3d/compare-EAX-with 0x9/imm32/9
|
||||
7f/jump-if-greater $to-hex-char:else/disp8
|
||||
05/add-to-EAX 0x30/imm32/0
|
||||
c3/return
|
||||
$to-hex-char:else:
|
||||
# otherwise return EAX + 'a' - 10
|
||||
05/add-to-EAX 0x57/imm32/a-10
|
||||
c3/return
|
||||
|
||||
# . . vim:nowrap:textwidth=0
|
BIN
subx/apps/assort
BIN
subx/apps/assort
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
subx/apps/handle
BIN
subx/apps/handle
Binary file not shown.
BIN
subx/apps/hex
BIN
subx/apps/hex
Binary file not shown.
BIN
subx/apps/pack
BIN
subx/apps/pack
Binary file not shown.
BIN
subx/apps/survey
BIN
subx/apps/survey
Binary file not shown.
BIN
subx/apps/tests
BIN
subx/apps/tests
Binary file not shown.
Loading…
Reference in New Issue