-
Notifications
You must be signed in to change notification settings - Fork 0
/
putx.asm
executable file
·45 lines (41 loc) · 1.05 KB
/
putx.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
; file putx.asm ; display a hex value
.include "m103def.inc" ; include register definitions
.include "macros.asm" ; include macro definitions
.include "definitions.asm"
reset:
LDSP RAMEND ; load stack pointer
OUTI DDRB,0xff ; make portB output
rcall LCD_init ; initialize LCD
rjmp main
.include "lcd.asm"
main: rcall LCD_home ; place cursor to home position
in a0,PIND ; read switches
out PORTB,a0 ; write to LED
com a0 ; invert a0
rcall LCD_putx ; display in hex on LCD
WAIT_MS 100
rjmp main
hextb:
.db "0123456789abcdef"
LCD_putx:
; in a0
push a0 ; save
swap ; display high nibble first
andi a0, ; mask higher nibble
mov ; load low byte of z
clr ; clear high byte of z
subi zl, low ; add offset to table base
sbci
; look up ASCII code
mov a0,r0
LCD_putc ; put character to LCD
pop
andi
mov ; load offset in low byte
clr ; clear high byte
subi ; add offset to table base
sbci
; look up ASCII code
mov a0,r0
; put character to LCD
ret