Jump to content
IGNORED

Adding to the x Register


Recommended Posts

Is there a easy way to add to the x register ?. Lets say that the equate "DC" contains value 10

 

LDX #10

STX DC

 

then i want to add 10 more to this DC equate, how can i go about this.

 

LDX DC+ 10# - i tried that one but it didnt work when using atasm to compile.

 

 

Im still a beginner but i guess it should be easy to learn how this is done.

Link to comment
Share on other sites

There's no add or subtract for X and Y, only A.

There's INX, DEX which adds or subtracts 1.

 

Generally you use A if you want to do maths or bitwise operations.

LDX DC + 10# isn't a legal instruction. LDX DC + 10 would be legal but it loads X with whatever is 10 bytes after DC. e.g. if DC is $4000 then X gets loaded from $400A.

 

In the example you gave, if you want to add 10 to what's in DC, you'd do something like:

 

 

  LDA DC
  CLC
  ADC #10
  STA DC
Link to comment
Share on other sites

Is there a easy way to add to the x register ?

 

You always can use undocumented code:

 

to add value to X register:

 

LAX DC

SBX #$100-10

 

to substract value from X register:

 

LAX DC

SBX #10

 

no need to clear or set C.

  • Like 2
Link to comment
Share on other sites

 

You always can use undocumented code:

 

to add value to X register:

 

LAX DC

SBX #$100-10

 

to substract value from X register:

 

LAX DC

SBX #10

 

no need to clear or set C.

Yes, you can do that, but it means that those of us who have 65802 and 65816 processors aren't able to run it.

Link to comment
Share on other sites

Atari never shipped a computer with more than 128K of memory, either.

 

Undocumented instructions have a lot of caveats. Besides compatibility with the 65816, they are also neither consistently documented nor supported by assemblers and debuggers. For a beginner I would definitely recommend avoiding such instructions.

  • Like 3
Link to comment
Share on other sites

I say use them only if you're writing something to show how fast it can be (i.e. inner loop of 1337 democode). Otherwise, reorder your code to have the value in A when you need to manipulate it. LUTs can be used for some things you do frequently with limited possible outcomes.

Link to comment
Share on other sites

 

computer with 6809 aren't able to run it also.
but... Atari computer does not have these processors.

 

6809 is not compatible with 6502 code at all. Some people do have them in their Ataris, but they don't run any Atari software at all, so that is a non-issue for us here.

 

I have a 65802 in my Atari 800 Incognito, it was a direct plug in replacement for the 6502. If I add only one jumper wire to the CPU card in my 800, I can directly plug in a 65816.

 

The 802's and 816's are compatible with documented 6502 instructions, and run 99% of Atari software perfectly. The added benefit is that they both provide useful extra instructions and addressing modes that the 6502 is missing, and in the case of the 816, it allows much more RAM to be directly addressed by the CPU.

 

The new Rapidus board from Lotharek, and the XL14 from Bob Woolley (bob1200xl) are two examples of the new, fast accelerators being produced for our beloved Ataris, and I hope everyone buys one. We must also never forget about the Sweet 16 from FTe. The Sweet 16 was a beautiful little blue board, hardly bigger than the DIP40 Sally it replaced. The 816 was on top, and a GAL logic chip on the bottom of the board.

 

Note to anyone who is trying to repair one: Due to a mistake in design, the legs on the GAL had to be bent over backwards, and the chip was mounted to the underside of the board upside down. It worked out well to confuse those who would try to copy it, but that was not the original intention. It was a real pain in the ass to build because of that. (Just a little bit of history there.)

  • Like 1
Link to comment
Share on other sites

We must also never forget about the Sweet 16 from FTe. The Sweet 16 was a beautiful little blue board, hardly bigger than the DIP40 Sally it replaced. The 816 was on top, and a GAL logic chip on the bottom of the board.

 

Note to anyone who is trying to repair one: Due to a mistake in design, the legs on the GAL had to be bent over backwards, and the chip was mounted to the underside of the board upside down. It worked out well to confuse those who would try to copy it, but that was not the original intention. It was a real pain in the ass to build because of that. (Just a little bit of history there.)

 

...and the gold pins are really, really soft, and don't hold up well to moving the board between systems :(

  • Like 1
Link to comment
Share on other sites

in c64 land undocumented opcodes are "standard" and on Atari don't? as XXL posted they are "illegal" opcodes which are stable... neverless I would not recommend them for beginners either but why not? for the 0,1% with an 65816? (if they are 0,1% machines... maybe 0,01%...)

 

(people should complain more about PAL software not running on NTSC... or as I played yesterday hours with my 800... why there is less 800 (48k) modern software ;)) but do we really want to go back to 1979 - 48k RAM)....

 

ps. I know philosophy discussion here... just wanted to give my 2 cents regarding the "evil opcodes".

Edited by Heaven/TQA
Link to comment
Share on other sites

Atari never shipped a computer with more than 128K of memory, either.

Atari managed to add the Cartridge Port with Page Flipping. So you just could use any cart with RAM/ROM sizes, as far as the pageflipping and the budget works. But I miss the "CPU exchange socket" . And btw. A 128K Atari has more than 128K inside, because Pageflipping works fine.

 

Undocumented instructions have a lot of caveats. Besides compatibility with the 65816, they are also neither consistently documented nor supported by assemblers and debuggers. For a beginner I would definitely recommend avoiding such instructions.

Yeah, and an advanced coder buys faster Hardware to write faster programs?

  • Like 1
Link to comment
Share on other sites

The 802's and 816's are compatible with documented 6502 instructions, and run 99% of Atari software perfectly. The added benefit is that they both provide useful extra instructions and addressing modes that the 6502 is missing, and in the case of the 816, it allows much more RAM to be directly addressed by the CPU.

Added benefit? But then the software will not run on stock Atari with the new instructions or addressing modes... I can say that the undocumented 6502 instructions are added benefit too and software which is using them will run on stock Atari.

The new Rapidus board from Lotharek, and the XL14 from Bob Woolley (bob1200xl) are two examples of the new, fast accelerators being produced for our beloved Ataris, and I hope everyone buys one.

 

I hope not. Or I don't care if someone buys it but I hope that the software for it will not be at the expense of software for stock Atari.

  • Like 2
Link to comment
Share on other sites

what is the benefit in replace 8-bit cpu in atari? new programs for that computer do not work on standard Atari... why should I change my beloved Atari into 16 bit?

or even better question: why should I write programs in "safe" mode to work on that transform hardware?


maybe we shouldn't use 6502C decimal mode because of lack of compatibility with 65816?



btw. MADS


allows to compile undocumented instructions

Edited by xxl
  • Like 1
Link to comment
Share on other sites

 

what is the benefit in replace 8-bit cpu in atari? new programs for that computer do not work on standard Atari... why should I change my beloved Atari into 16 bit?
or even better question: why should I write programs in "safe" mode to work on that transform hardware?
maybe we shouldn't use 6502C decimal mode because of lack of compatibility with 65816?
btw. MADS
allows to compile undocumented instructions

 

the real issue is when your 6502C dies from lightning strike, act of god, whatever it takes, and YOU CAN'T FIND ANOTHER. one day we'll be out of 6502C's and you'll have to convert to a 65C02, which doesn't support undocumented instructions.

Link to comment
Share on other sites

 

what is the benefit in replace 8-bit cpu in atari? new programs for that computer do not work on standard Atari... why should I change my beloved Atari into 16 bit?
or even better question: why should I write programs in "safe" mode to work on that transform hardware?
maybe we shouldn't use 6502C decimal mode because of lack of compatibility with 65816?
btw. MADS
allows to compile undocumented instructions

 

First of all, there are many benefits, look up the 65816: http://en.wikipedia.org/wiki/WDC_65816/65802

 

You are not changing your beloved Atari into a 16 bit, you are only enhancing its capabilities. The way you wrote that makes it sound as if we're changing it into an ST.

 

Safe Mode, really? We're not talking about Windows here. All I am asking you (and everyone) to do is respect the documented opcodes so everyone can use your software.

 

the decimal mode problem was a bug which was fixed.

Link to comment
Share on other sites

All I am asking you (and everyone) to do is respect the documented opcodes so everyone can use your software.

What about respecting the Atari's real specs?

When a coder wants to push a stock machine to the limits, you should also respect that.

And, well, what would stop you to do the needed changes for the Atari with your strange setup?

Link to comment
Share on other sites

the real issue is when your 6502C dies from lightning strike, act of god, whatever it takes, and YOU CAN'T FIND ANOTHER. one day we'll be out of 6502C's and you'll have to convert to a 65C02, which doesn't support undocumented instructions.

Nah - by that time, anyone can (and most likely will have) rolled their own via FPGA so no issues :)

  • Like 1
Link to comment
Share on other sites

just another 2 cents regarding LAX/SAX/SBX... from my latest projects I can tell that these instructions enabled 1-2 more FPS... which is a lot getting from slideshow to something playable... so why should I leave them out?

Then it would be cool to have an option which simply patches the illegal opcodes in and out (while leaving space for the longer option). The patch code could be pretty small.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...