Skip to content

Commit aded830

Browse files
committed
fix absolute addresses for loc in inline assembly
1 parent e744c16 commit aded830

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

Changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Version 7.0.2
22
- Avoid a crash if a .fpide file is not found
3+
- Fixed a problem with `loc #\imm` in inline asm
34

45
Version 7.0.1
56
- Fixed incorrect casts of arrays

Test/Expect/stest316.p2asm

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
con
2+
_clkfreq = 20000000
3+
_clkmode = 16779595
4+
dat
5+
nop
6+
cogid pa
7+
coginit pa,##$404
8+
orgh $10
9+
long 0 'reserved
10+
long 0 ' clock frequency: will default to 20000000
11+
long 0 ' clock mode: will default to $100094b
12+
orgh $400
13+
_ret_ mov result1, #0
14+
org 0
15+
entry
16+
17+
_demo
18+
loc ptrb, #\65536
19+
_demo_ret
20+
ret
21+
builtin_bytefill_
22+
shr arg03, #1 wc
23+
if_c wrbyte arg02, arg01
24+
if_c add arg01, #1
25+
movbyts arg02, #0
26+
builtin_wordfill_
27+
shr arg03, #1 wc
28+
if_c wrword arg02, arg01
29+
if_c add arg01, #2
30+
setword arg02, arg02, #1
31+
builtin_longfill_
32+
wrfast #0,arg01
33+
cmp arg03, #0 wz
34+
if_nz rep #1, arg03
35+
if_nz wflong arg02
36+
ret
37+
38+
COG_BSS_START
39+
fit 480
40+
orgh
41+
org COG_BSS_START
42+
fit 480

Test/stest316.spin2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pub demo()
2+
org
3+
loc ptrb,#\$10000
4+
end

backends/asm/assemble_ir.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,11 @@ doPrintOperand(struct flexbuf *fb, Operand *reg, int useimm, enum OperandEffect
163163
ERROR(NULL, "internal error, pcrelative operand found");
164164
break;
165165
case IMM_INT:
166-
if (reg->val >= 0 && reg->val <= maximm) {
166+
if (useabsaddr || (reg->val >= 0 && reg->val <= maximm)) {
167167
flexbuf_addstr(fb, "#");
168+
if (useabsaddr) {
169+
flexbuf_addstr(fb, "\\");
170+
}
168171
if (reg->name && reg->name[0]) {
169172
flexbuf_addstr(fb, RemappedName(reg->name));
170173
} else {

0 commit comments

Comments
 (0)