
![]() |
||
| Updates | Knowledge base | Manuals | Resellers | Warranties | Feedback | ||
Knowledge Base[ Back ] [ Index ] [ Categories ] [ Next ] Q10023. Routine (Word2Hex) of preparing a 16 bit number to be printed in HEX form.More informationConverts a 2-byte value to four hexadecimal characters. All values are considered positive. Uses Byte2Hex routine twice...AssemblerAny assembler.Input(SP+4) -> Number to convert(SP+2) -> Four-byte ASCII buffer start address (SP+0) -> Normal return address OutputASCII buffer is filled with the converted numberA : Ascii code of lowest nibble of converted number DE: Number to convert HL: Pointer to last char in buffer RoutineWord2Hex: POP DE ;Get ret address temporarily POP HL ;Get Buffer address LD (W2HBuf),HL ;Save Buffer address POP HL ;Get Number LD (W2HNum),HL ;Save Number PUSH DE ;Push return address LD L,H ;MSB to LSB PUSH HL ;Push MSB LD HL,(W2HBuf) ;Retrieve buffer pointer PUSH HL ;Push buffer address CALL Byte2Hex ;Fill half buffer INC HL ;HL points to third char in buffer LD DE,(W2HNum) ;DE now holds LSB of Number PUSH DE ;Number to Stack PUSH HL ;Buffer to Stack CALL Byte2Hex ;Fill rest of buffer RET ;Done. W2HBuf: DW 0000h W2HNum: DW 0000h Added byMarcelo Lopez14 May 2003. |