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

define instruction from easy 6502 not working #7

Open
lerugray opened this issue Nov 21, 2017 · 17 comments
Open

define instruction from easy 6502 not working #7

lerugray opened this issue Nov 21, 2017 · 17 comments

Comments

@lerugray
Copy link

Assembler doesn't recognize the same instruction from the tutorial

@BigEd
Copy link
Collaborator

BigEd commented Nov 22, 2017

Which assembler are you trying to use? Each assembler does have unique choices for how to express a program, and easy6502 is no exception!

@lerugray
Copy link
Author

lerugray commented Nov 26, 2017 via email

@BigEd
Copy link
Collaborator

BigEd commented Nov 26, 2017

Do you mean http://www.6502asm.com/ ? If so, it has no define, so from the examples we see the tactic is to use a label:

* = $hhhh
name

@BigEd
Copy link
Collaborator

BigEd commented Nov 26, 2017

Oops sorry I have just realised that I was confused between easy6502 and 6502js. Let me look into this. We do know the two assemblers have diverged. My own fork of 6502js is different again.

@lerugray
Copy link
Author

lerugray commented Nov 26, 2017 via email

@lerugray
Copy link
Author

lerugray commented Nov 27, 2017 via email

@BigEd
Copy link
Collaborator

BigEd commented Nov 27, 2017

Just started looking at this. I see you can use the same kind of workaround, abusing the label mechanism to define a symbol:

* = 255
mask:

* = $600
start:
nop
lda mask
nop

@lerugray
Copy link
Author

lerugray commented Nov 27, 2017 via email

@BigEd
Copy link
Collaborator

BigEd commented Nov 27, 2017

Here's a slight expansion of the example:

* = 127
mask:

* = $fe
sysRandom:

* = $600
start:
nop
lda mask
and sysRandom
nop

and the disassembler says we got this:

Address  Hexdump   Dissassembly
-------------------------------
$0600    ea        NOP 
$0601    a5 7f     LDA $7f
$0603    25 fe     AND $fe
$0605    ea        NOP 

So, it's a little ugly, and it takes two lines to make each define, but I think it works generally.

@BigEd
Copy link
Collaborator

BigEd commented Nov 27, 2017

(However, I notice the tactic fails for immediate values. I should have written
lda #mask
but that turns out not to work at all.)

@lerugray
Copy link
Author

lerugray commented Nov 27, 2017 via email

@lerugray
Copy link
Author

lerugray commented Nov 27, 2017 via email

@BigEd
Copy link
Collaborator

BigEd commented Nov 27, 2017

I think we'd need to bring the whole 'define' mechanism in from easy6502 to 6502js.

Meantime, could you work using a local copy of easy6502 instead of using 6502js? I tend to try out small snippets just using the first emulation window - the snake is way down the file and needn't distract you.

@lerugray
Copy link
Author

lerugray commented Nov 27, 2017 via email

@lerugray
Copy link
Author

lerugray commented Nov 27, 2017 via email

@BigEd
Copy link
Collaborator

BigEd commented Nov 27, 2017

Reserving some bytes... I think the effect will be to set the label and then for the next label to take a slightly higher value. So perhaps just use dummy code sequences instead:

* = $80
onebyte:
nop
twobytes:
nop
nop
twomorebytes:
lda 0
eightbytes:
jmp dummy
jmp dummy
lda 0

@codemaster138
Copy link

I made a fork of the emulator here and fixed the issue partially. the following would now work :

define white $01
define topleft $0200
lda #white
sta topleft

I haven't yet managed to make it work in indexing modes though, so

sta $0200,#value

would not assemble, assuming value is a constant defined by the define keyword

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