はっくはっくキッチン
Hack Hack Kitchen

bin2ascii.asm

 2021/12/12

converts a value to ascii code. This code is a part of pAVRlib.

Subroutines

char B2AH(char val) (in: r24, out: r24)

converts the upper nibble of r24 to ASCII code. The next code will result '4' (0x34).

	ldi	r24, 0x4f
	rcall	B2AH

char B2AL(char val) (in: r24, out: r24)

converts the lower nibble of r24 to ASCII code. The next code will result 'F' (0x46).

	ldi	r24, 0x4f
	rcall	B2AL

Example

This program requires usart.asm. (See also: usart-puthex.asm)

	ldi 	r24, 0x4f

	push	r24
	rcall	B2AH
	rcall	USART_TRANSMIT
	pop	r24

	;; push and pop can be omitted if you don't
	;; need to preserve the value of r24
	push	r24
	rcall	B2AL
	rcall	USART_TRANSMIT
	pop	r24