Break a dependency from `print-int32` to `from-hex-char`.
This commit is contained in:
Kartik Agaram 2019-07-21 22:23:20 -07:00
parent 8a1a3fb45f
commit ac8a9396b9
13 changed files with 13 additions and 13 deletions

View File

@ -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

View File

@ -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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.