Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

something wrong with the compilation: Illegal addressing mode (CPU 6502) #35

Closed
GSoftwareDevelopment opened this issue May 6, 2021 · 6 comments

Comments

@GSoftwareDevelopment
Copy link
Contributor

GSoftwareDevelopment commented May 6, 2021

Suddenly I got this message during compilation:

rol #$00
"Illegal addressing mode (CPU 6502)"

This is for the following source line:

vol_dist[winShift+winPos]:=(vol_dist[winShift+winPos] and $0f) or (v shl 4);

Compilation result:

; optimize OK (instrument.inc), line = 346

	lda WINSHIFT
	add WINPOS
	sta :STACKORIGIN+9
	lda WINSHIFT
	add WINPOS
	tay
	lda adr.VOL_DIST,y
	and #$0F
	sta :STACKORIGIN+10
	lda V
	sta :STACKORIGIN+11
	lda WINPOS+1
	asl :STACKORIGIN+11
	rol @
	sta :STACKORIGIN+STACKWIDTH+11
	rol #$00     <--- it's here
	rol #$00
	asl :STACKORIGIN+11
	rol :STACKORIGIN+STACKWIDTH+11
	asl :STACKORIGIN+11
	rol :STACKORIGIN+STACKWIDTH+11
	asl :STACKORIGIN+11
	rol :STACKORIGIN+STACKWIDTH+11
	lda :STACKORIGIN+10
	ora :STACKORIGIN+11
	ldy :STACKORIGIN+9
	sta adr.VOL_DIST,y

I'll add that I didn't change anything at this point and this (source) code worked. What is wrong?

@GSoftwareDevelopment GSoftwareDevelopment changed the title something wrong with the compilation: something wrong with the compilation: Illegal addressing mode (CPU 6502) May 6, 2021
@GSoftwareDevelopment
Copy link
Contributor Author

It looks like the compiler can't handle a nested "SHL" instruction.

modulate[winShift+winPos]:=modulate[winShift+winPos] and $0f or (v shl 4);

If I move the "SHL" operations outside this area, everything is OK.

v:=v shl 4;
modulate[winShift+winPos]:=modulate[winShift+winPos] and $0f or v;

@tebe6502
Copy link
Owner

tebe6502 commented May 9, 2021

i can't reproduce this issue
whats type is: vol_dist, winShift, winPos, v ?

probably you use old compiler version, current 165 works fine

@GSoftwareDevelopment
Copy link
Contributor Author

var
  vol_dist is an array[0..127] of byte;
  winShift,winPos:smallint;
  v:byte;

I will try a newer version.

@GSoftwareDevelopment
Copy link
Contributor Author

It turns out that I'm using version 1.6.4, and the error is still showing.

@zbyti
Copy link
Collaborator

zbyti commented May 16, 2021

It turns out that I'm using version 1.6.4, and the error is still showing.

Mad Pascal Compiler version 1.6.5 [2021/05/02] for 6502

In Mad Pascal world most stable version is ALWAYS master branch.

@zbyti
Copy link
Collaborator

zbyti commented May 22, 2021

@GSoftwareDevelopment this issue is solved and ready to close with with MP 1.6.5?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants