-
Notifications
You must be signed in to change notification settings - Fork 0
/
toy_vm_video_pattern.asm
52 lines (47 loc) · 1020 Bytes
/
toy_vm_video_pattern.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
# Fill screen with pattern
LOADA 0x3E80 # Offset to end of video memory
PUSHA
LABEL .ROW_LOOP:
# Decrement row offset
# We can get here more efficiently if we just
# push the result of the column iteration but
# this is easier to read, maybe ?!
POPA
LOADB -320
ADD
PUSHA
# Increment col offset to end of row
LOADB 320
ADD
PUSHA
LABEL .COL_LOOP
# Write second 2 bytes of pixel
POPA
LOADB -2
MOVAC
ADD
MOVAIX
MSTOREC 0x1000 # Video memory
# Write first 2 bytes of pixel
LOADC 0xFFFF
ADD
MOVAIX
MSTOREC 0x1000 # Video memory
# Remove row offset see if at COL=0
POPB
PUSHB
PUSHA
NEGB
ADD
JZ .EXIT_COL_LOOP
JMP .COL_LOOP
LABEL .EXIT_COL_LOOP:
# Check if ROW = 0
POPA
PUSHA
LOADB 0
ADD
JZ .EXIT_CHECKERED_VIDEO_LOOP
JMP .ROW_LOOP
LABEL .EXIT_CHECKERED_VIDEO_LOOP:
HALT