Prev: D01B Up: Map Next: D02C
D023: Sign Extend A To HL
Used by the routine at MoveObject.
Makes a signed number into a signed word.
Input
A The number
Output
HL The word
Put the number in the low byte. The high byte is zero, or FF if the number is negative.
SignExtendAToHL D023 LD L,A Make the number the low byte.
D024 XOR A Start with a high byte of zero.
D025 BIT 7,L Jump to SignExtendAToHL_Set if the number is not negative.
D027 JR Z,SignExtendAToHL_Set
D029 CPL Make the high byte FF.
SignExtendAToHL_Set D02A LD H,A Set the high byte.
D02B RET Return.
View the equivalent code in;
Prev: D01B Up: Map Next: D02C