-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoint.asm
More file actions
49 lines (42 loc) · 1.16 KB
/
point.asm
File metadata and controls
49 lines (42 loc) · 1.16 KB
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
; Copyright 2017 Julian Merkle
; This file is part of asm_Snake.
; asm_Snake is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
; asm_Snake is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
; You should have received a copy of the GNU General Public License
; along with asm_Snake. If not, see <http://www.gnu.org/licenses/>.
; R1 (R3,R2)
; Takes X axis R3 and Y axis R2 and
; combines them to 1 byte representation R3
encode_axes_to_byte:
; Handle Y
MOV A, R3
ANL A, #0111b ; Mask 3 lowest bits
SWAP A
MOV R1, A
; Handle X
MOV A, R2
ANL A, #0111b ; Mask 3 lowest bits
ORL A, R1 ; Combine X and Y
MOV R1, A
RET
; R2 (R1)
; Decode X axis from element R1
get_axis_x:
MOV A, R1
ANL A, #0xF0
SWAP A
MOV R2, A
RET
; R2 (R1)
; Decode Y axis from element R1
get_axis_y:
MOV A, R1
ANL A, #0x0F
MOV R2, A
RET