-
Notifications
You must be signed in to change notification settings - Fork 0
/
score.asm
executable file
·52 lines (38 loc) · 831 Bytes
/
score.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
46
47
48
49
50
51
52
gen_score_str:
; Converts a BCD encoded score (word) to a fixed length, ASCII encoded score
; (double word)
; Modifies registers a, f, b, d, e
; de register pair must be set to the destination memory address (double word)
; hl register pair must be set to the memory address of the score
; (word, encoded as BCD, little endian)
ld b,0x30
inc hl
ld a,(hl) ; score + 1
and 0xf0
rrca
rrca
rrca
rrca
add a,b ; 0x30
ld (de),a ; str_score
inc de
ld a,(hl) ; score + 1
and 0x0f
add a,b ; 0x30
ld (de),a ; str_score + 1
dec hl
inc de
ld a,(hl) ; score
and 0xf0
rrca
rrca
rrca
rrca
add a,b ; 0x30
ld (de),a ; str_score + 2
inc de
ld a,(hl) ; score
and 0x0f
add a,b ; 0x30
ld (de),a ; str_score + 3
ret