mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-21 03:26:44 +00:00
Updated Snippet: Manhattan distance (markdown)
parent
ff7b76fee0
commit
a1cf5139e4
@ -1,8 +1,11 @@
|
|||||||
This simple program calculates the [Manhattan distance](https://en.wikipedia.org/wiki/Taxicab_geometry) between the current position of the Cubot and another tile.
|
This simple program calculates the [Manhattan distance](https://en.wikipedia.org/wiki/Taxicab_geometry) between the current position of the Cubot and another tile.
|
||||||
```assembly
|
```assembly
|
||||||
; Define constants
|
; Define constants
|
||||||
LIDAR_HW equ 0x0003 ; HWID of the LiDAR
|
HWID_LIDAR equ 0x3
|
||||||
HOLO_HW equ 0x0009 ; HWID of the Hologram projector
|
HWID_HOLO equ 0x9
|
||||||
|
|
||||||
|
HOLO_DISPLAY_HEX equ 0x1
|
||||||
|
LIDAR_GET_POS equ 0x1
|
||||||
|
|
||||||
; Data segment
|
; Data segment
|
||||||
.data
|
.data
|
||||||
@ -27,8 +30,8 @@ HOLO_HW equ 0x0009 ; HWID of the Hologram projector
|
|||||||
counter_is_odd:
|
counter_is_odd:
|
||||||
ADD [counter], 1 ; Increment counter
|
ADD [counter], 1 ; Increment counter
|
||||||
MOV B, A
|
MOV B, A
|
||||||
MOV A, 1
|
MOV A, HOLO_DISPLAY_HEX
|
||||||
HWI HOLO_HW ; Display the contents of A
|
HWI HWID_HOLO ; Display the contents of A
|
||||||
BRK ; Exit program
|
BRK ; Exit program
|
||||||
|
|
||||||
;**************************************
|
;**************************************
|
||||||
@ -37,8 +40,8 @@ counter_is_odd:
|
|||||||
;* Y = Y pos
|
;* Y = Y pos
|
||||||
getPos:
|
getPos:
|
||||||
PUSH A ; Save A
|
PUSH A ; Save A
|
||||||
MOV A, 0x0001 ; GET_POS
|
MOV A, LIDAR_GET_POS
|
||||||
HWI LIDAR_HW ; Send hardware interrupt to the LiDAR
|
HWI HWID_LIDAR ; Send hardware interrupt to the LiDAR
|
||||||
POP A ; Restore A
|
POP A ; Restore A
|
||||||
RET
|
RET
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user