6502js icon indicating copy to clipboard operation
6502js copied to clipboard

define instruction from easy 6502 not working

Open lerugray opened this issue 7 years ago • 17 comments

Assembler doesn't recognize the same instruction from the tutorial

lerugray avatar Nov 21 '17 20:11 lerugray

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

BigEd avatar Nov 22 '17 13:11 BigEd

I tried downloading the 6502 JS Assembler, it would not recognize the Define instruction as used in the tutorials.

On Wed, Nov 22, 2017 at 8:12 AM, BigEd [email protected] wrote:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/skilldrick/6502js/issues/7#issuecomment-346346210, or mute the thread https://github.com/notifications/unsubscribe-auth/AOZWIeJ0ZT07rFBPYSBXHaAJA9jMlNl3ks5s5B3MgaJpZM4Qmb5Q .

lerugray avatar Nov 26 '17 10:11 lerugray

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 avatar Nov 26 '17 14:11 BigEd

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.

BigEd avatar Nov 26 '17 14:11 BigEd

OK Cool thank you, yeah I was hoping that there was one of these I could download to practice assembly on my own, like building snake from scratch with the embedded screen you guys had in easy 6502

if this is possible, plz lemme know, I know easy6502 had a define instruction for their snake example

On Sun, Nov 26, 2017 at 9:55 AM, BigEd [email protected] wrote:

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.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/skilldrick/6502js/issues/7#issuecomment-347013952, or mute the thread https://github.com/notifications/unsubscribe-auth/AOZWIQqk8gIm7lsgTLIoDC7yWc39vo2Zks5s6XvlgaJpZM4Qmb5Q .

lerugray avatar Nov 26 '17 21:11 lerugray

for example, trying to use the easy 6502 assembler downloaded from easy 6502

in the tutorial, they use (define) as a means of declaring constants/variables. Upon downloading the Assembler though, the define instruction stops working. How would I still define variables/constants?

On Sun, Nov 26, 2017 at 4:11 PM, Raymond Liberto [email protected] wrote:

OK Cool thank you, yeah I was hoping that there was one of these I could download to practice assembly on my own, like building snake from scratch with the embedded screen you guys had in easy 6502

if this is possible, plz lemme know, I know easy6502 had a define instruction for their snake example

On Sun, Nov 26, 2017 at 9:55 AM, BigEd [email protected] wrote:

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.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/skilldrick/6502js/issues/7#issuecomment-347013952, or mute the thread https://github.com/notifications/unsubscribe-auth/AOZWIQqk8gIm7lsgTLIoDC7yWc39vo2Zks5s6XvlgaJpZM4Qmb5Q .

lerugray avatar Nov 27 '17 11:11 lerugray

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

BigEd avatar Nov 27 '17 18:11 BigEd

How would you use this technique in something like a constant? Lets say for example I wanted to set sysRandom = $fe (the RNG on the mock 6502)

*=255 - is this setting mask to 255 decimal? I'm a little confused as to how this example works in practice, thanks for the help

On Mon, Nov 27, 2017 at 1:01 PM, BigEd [email protected] wrote:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/skilldrick/6502js/issues/7#issuecomment-347269642, or mute the thread https://github.com/notifications/unsubscribe-auth/AOZWIY97nMZy4uBFvwi884n2isdjzom6ks5s6vj0gaJpZM4Qmb5Q .

lerugray avatar Nov 27 '17 18:11 lerugray

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 avatar Nov 27 '17 18:11 BigEd

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

BigEd avatar Nov 27 '17 18:11 BigEd

Aghh that's unfortunate, was going to use this idea for costants related to collision, if there's a workaround, kindly let me know, thx!

On Nov 27, 2017 13:33, "BigEd" [email protected] wrote:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/skilldrick/6502js/issues/7#issuecomment-347279621, or mute the thread https://github.com/notifications/unsubscribe-auth/AOZWIZmu_RS1174kTfSBEKHzU4ZPjAEJks5s6wCIgaJpZM4Qmb5Q .

lerugray avatar Nov 27 '17 18:11 lerugray

oh and just for context, I'm trying to build snake/pong in the assembler without using the help of the tutorial, so i assume even if reformatted for the above hack, that code still wouldnt assemble given the #immediatevalue error.

On Mon, Nov 27, 2017 at 1:35 PM, Raymond Liberto [email protected] wrote:

Aghh that's unfortunate, was going to use this idea for costants related to collision, if there's a workaround, kindly let me know, thx!

On Nov 27, 2017 13:33, "BigEd" [email protected] wrote:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/skilldrick/6502js/issues/7#issuecomment-347279621, or mute the thread https://github.com/notifications/unsubscribe-auth/AOZWIZmu_RS1174kTfSBEKHzU4ZPjAEJks5s6wCIgaJpZM4Qmb5Q .

lerugray avatar Nov 27 '17 18:11 lerugray

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.

BigEd avatar Nov 27 '17 18:11 BigEd

Yes that would be perfect, could you link me to the appropriate place to grab the easy 6502 engine? Tha k you so much

On Nov 27, 2017 13:57, "BigEd" [email protected] wrote:

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.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/skilldrick/6502js/issues/7#issuecomment-347287486, or mute the thread https://github.com/notifications/unsubscribe-auth/AOZWIW5Y1MDr5k0k7ZYvBDwur327LbNiks5s6wYAgaJpZM4Qmb5Q .

lerugray avatar Nov 27 '17 18:11 lerugray

Oh wait I see what you mean, yeah that sounds good, please keep me posted as to when you add in define. Also curious, how do I reserve bytes for variables? For the nes, all I usually will do is (nesasm)

ballspeedx: .rs 1

On Nov 27, 2017 13:57, "BigEd" [email protected] wrote:

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.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/skilldrick/6502js/issues/7#issuecomment-347287486, or mute the thread https://github.com/notifications/unsubscribe-auth/AOZWIW5Y1MDr5k0k7ZYvBDwur327LbNiks5s6wYAgaJpZM4Qmb5Q .

lerugray avatar Nov 27 '17 18:11 lerugray

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

BigEd avatar Nov 27 '17 19:11 BigEd

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

codemaster138 avatar Aug 25 '19 22:08 codemaster138