-
Notifications
You must be signed in to change notification settings - Fork 3
/
cdpoke.c
52 lines (49 loc) · 1.84 KB
/
cdpoke.c
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
/*
*******************************************************************
*** 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);
if (exprErrors > 0) return line;
line = trim(line);
if (*line != ',') {
showError("Syntax error");
*line = 0;
return line;
}
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);
if (exprErrors > 0) return line;
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;
}