forked from rileym65/Basic-02
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcdpoke.c
More file actions
49 lines (46 loc) · 1.75 KB
/
Copy pathcdpoke.c
File metadata and controls
49 lines (46 loc) · 1.75 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
/*
*******************************************************************
*** This software is copyright 2021 by Michael H Riley ***
*** You have permission to use, modify, copy, and distribute ***
*** this software so long as this copyright notice is retained. ***
*** This software may not be used in commercial applications ***
*** without express written permission from the author. ***
*******************************************************************
*/
#include "header.h"
char* cdpoke(char* line) {
line = cexpr(line, 0);
line = trim(line);
if (*line != ',') {
showError("Syntax error");
exit(1);
}
line++;
Asm(" inc r7 ; Get poke address");
Asm(" lda r7");
Asm(" stxd ; Store for now");
Asm(" ldn r7");
Asm(" stxd");
if (use32Bits) {
Asm(" inc r7 ; Remove high word");
Asm(" inc r7");
}
line = cexpr(line, 0);
Asm(" irx ; Recover poke address");
Asm(" ldxa");
Asm(" phi rf");
Asm(" ldx");
Asm(" plo rf");
Asm(" inc rf ; Point to LSB");
Asm(" inc r7");
Asm(" lda r7 ; Get low byte of poke value");
Asm(" str rf ; And write it to memory");
Asm(" dec rf");
Asm(" ldn r7 ; Get high byte of poke value");
Asm(" str rf ; And write it to memory");
if (use32Bits) {
Asm(" inc r7 ; Remove high word");
Asm(" inc r7");
}
return line;
}