-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.a
More file actions
71 lines (69 loc) · 3.38 KB
/
Copy pathtest.a
File metadata and controls
71 lines (69 loc) · 3.38 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
; ASM format guidelines (just for myself, not for the assembler):
; - Use uppercase for instructions, registers, and directives.
; - Use UPPER_SNAKE_CASE for constants.
; - Use snake_case or camelCase for labels and variable names.
; - Prefer using "" for string literals, not ''.
; - Prefer using uppercase hexadecimal notation for addresses.
.CONST PCG_VRAM_BASE 0x10000000 ; Base address of PCG VRAM
;.CONST PCG_VRAM_END 0x100004B0 ; End address of PCG VRAM
.CONST PCG_VRAM_END 0x10000960 ; End address of PCG VRAM (80 columns)
.CONST PCG_VRAM_ATTR_BASE 0x10001000 ; Base address of PCG VRAM attributes
.CONST VDP_MODE_REG_ADDR 0x80030001 ; VDP Mode Register Address
.CONST VDP_BORDER_COLOR_REG_ADDR 0x80030003 ; VDP Border Color Register Address
.CONST VDP_PCG_SCREEN_MODE_REG_ADDR 0x8003F003 ; VDP PCG Screen Mode Register Address
.CONST VDP_PCG_CURSOR_ENABLE_REG_ADDR 0x8003F007 ; VDP PCG Cursor Enable Register Address
.CONST VDP_PCG_CURSOR_LINE_REG_ADDR 0x8003F008 ; VDP PCG Cursor Line Register Address
.CONST VDP_PCG_CURSOR_BLINK_PERIOD_REG_ADDR 0x8003F009 ; VDP PCG Cursor Blink Period Register Address
.CONST TEXT_COLOR 0x3F ; Text color attribute (white on black)
LDIH R1, VDP_MODE_REG_ADDR ; Load VDP Mode Register Address
LDIL R1, VDP_MODE_REG_ADDR
LDIH R2, 0x00 ; Load value to set VDP to text mode
LDIL R2, 0x01
STB [R1], R2 ; Set VDP to text mode
LDIH R1, VDP_PCG_SCREEN_MODE_REG_ADDR ; Load VDP PCG Screen Mode Register Address
LDIL R1, VDP_PCG_SCREEN_MODE_REG_ADDR
LDIH R2, 0x00 ; Load value to set PCG screen mode to 80x30
LDIL R2, 0x00
STB [R1], R2 ; Set PCG screen mode to 80x30
LDIH R1, VDP_PCG_CURSOR_ENABLE_REG_ADDR ; Load VDP PCG Cursor Enable Register Address
LDIL R1, VDP_PCG_CURSOR_ENABLE_REG_ADDR
LDIH R2, 0x00 ; Load value to enable PCG cursor
LDIL R2, 0x01
STB [R1], R2 ; Enable PCG cursor
LDIH R1, VDP_PCG_CURSOR_LINE_REG_ADDR ; Load VDP PCG Cursor Line Register Address
LDIL R1, VDP_PCG_CURSOR_LINE_REG_ADDR
LDIH R2, 0x00 ; Load value to set cursor lines (all visible)
LDIL R2, 0x00
STB [R1], R2 ; Set cursor lines
LDIH R1, VDP_PCG_CURSOR_BLINK_PERIOD_REG_ADDR ; Load VDP PCG Cursor Blink Period Register Address
LDIL R1, VDP_PCG_CURSOR_BLINK_PERIOD_REG_ADDR
LDIH R2, 0x00 ; Load value for cursor blink period (16 frames)
LDIL R2, 0x10
STB [R1], R2 ; Set cursor blink period
LDIH R1, VDP_BORDER_COLOR_REG_ADDR ; Load VDP PCG Cursor Blink Period Register Address
LDIL R1, VDP_BORDER_COLOR_REG_ADDR
LDIH R2, 0x00 ; Load value for border color
LDIL R2, 0x10
STB [R1], R2 ; Set border color
LDIH R2, 0x0000 ; Initialize pointer to the start of the string
LDIL R2, 0x0000
LDIH R1, 0x0000 ; increment value for pointer
LDIL R1, 0x0001
LDIH R5, PCG_VRAM_BASE ; Base address of PCG VRAM
LDIL R5, PCG_VRAM_BASE
LDIH R6, PCG_VRAM_ATTR_BASE ; Base address of PCG VRAM attributes
LDIL R6, PCG_VRAM_ATTR_BASE
LDIH R7, TEXT_COLOR ; Text color attribute
LDIL R7, TEXT_COLOR
LDIH R8, PCG_VRAM_END ; End address of PCG VRAM
LDIL R8, PCG_VRAM_END
loop:
STB [R5], R2 ; Store the character in PCG VRAM
;MUL R2, R2, R5
STB [R6], R7 ; Store the text color attribute 1 in PCG VRAM attributes
;STB [R6 + 0x1000], R2 ; set the attribute 2 (BG color) to pointer to the string
ADD R2, R2, R1 ; Increment the pointer to the next character
ADD R5, R5, R1 ; Increment the PCG VRAM pointer
ADD R6, R6, R1 ; Increment the PCG VRAM attributes pointer
BNE R8, R5, loop ; loop if address is not end
HALT ; Stop the program