Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > useless opcodes riddle - wtf is up with LAS and TAS?
2014-11-07 23:10
chatGPZ

Registered: Dec 2001
Posts: 11146
useless opcodes riddle - wtf is up with LAS and TAS?

Due to my emulator related activities in the last year(s) i digged more into the so called "illegal" opcodes, and the result is a nice (hopefully) PDF that i'll publish soonish (when some of you lazy bastards are done proofreading =D) - which includes complete state of the art reference to all of these, plus a bunch of real world examples on how to use these (sometimes very weird behaving) instructions... (in large part provided by bitbreaker, thumbs up!) Its about time for a comprehensive document on this topic that is suitable for normal people =)

however, two opcodes seem to be completely useless and so far i cant think of what to use them for in real world code:
- LAS abs,y ($BB) (A,X,SP = addr & SP)
- TAS abs,y ($9B) (SP = A & X ; addr = SP & addrhi+1)

if any of you have used these before, or for whatever reason have an idea on what to do with them - let me know please, this is your chance to earn some karma upgrade points :o)

(and as a sidenote, some not so obvious *short* snippets that are using SLO, RLA, RRA or ISC are welcome too)

let's bust some more myths!
 
... 30 posts hidden. Click here to view all posts....
 
2014-11-12 12:17
Martin Piper

Registered: Nov 2007
Posts: 645
I agree a full optimiser would be a bit of a challenge since an optimiser would really need some useful context about expected register input ranges, scan line and position it's expected to execute on and possibly zero page context to make good suggestions. Although it's possible to tell the assembler expected input ranges and the like by using some source code directives.


However a simple optimiser would be easily doable.

For example if it spots:
ROR $f00d
ADC $f00d

It could automatically suggest RRA $f00d
If there are stability prerequisites like the instruction needing to be in a particular bank or scan line position then it could simply output the code hint to a separate file (or output a warning) and let the coder make the change or ignore it.

It would help where someone doesn't quite remember the extended opcode set yet. :)
2014-11-12 17:03
Frantic

Registered: Mar 2003
Posts: 1629
Not sure if anybody mentioned something like this already, but the only thing I can think of is that you may use "las TABLE,y" to AND the stack pointer with the contents of the Y register (if pointing to a table with values 00..FF sequentially laid out) and storing the result back into the stack pointer. At TABLE you may also have a different sort of table, that would allow you to specify exactly what sort of values you actually want to AND with the stack pointer, so in a way it would be more flexible than a normal AND instruction as well. As a special case you could fill the entire 256 bytes of that table with the same value, to make the AND operation independent of the contents of the Y register and always AND with the same value.

You would also have the result of the operation in both A and X. Good or bad..

As for what contexts this may be useful.. don't ask me! :) So.. perhaps not that much of a contribution to the discussion after all... At least it is the fastest way I can think of of actually ANDing the stack pointer with something, and storing the result back to the stack pointer. Four cycles, if TABLE is page aligned.

Possibly I misunderstood how LAS works altogether. :)
2014-11-12 17:33
soci

Registered: Sep 2003
Posts: 474
Quoting Martin Piper

For example if it spots:
ROR $f00d
ADC $f00d

It could automatically suggest RRA $f00d

Is there a practical use of this opcode, except on a Z80?
2016-09-04 20:29
Rastah Bar

Registered: Oct 2012
Posts: 336
I may have found some use for the TAS opcode. Suppose I want to let the sprite image depend on it's y position on the screen.
For example make it bigger for larger y to create an illusion of depth. Suppose bank 1 is used and screen memory starts at $7800.
Then the sprite image pointers are at $7bf8-$7bff. The trick I'm thinking about uses the and+store operation of TAS, for example
LDY #spritenumber
LAX #yposition
TAS $7BF8,Y	;TAS performs and #$7C, allowing for 32 different sprite images.
PLA
STA $D027,Y	;Assuming I have color data on the stack. Just as an example of using that TAS modifies SP.


What do you think about this?
2016-09-06 14:19
Rastah Bar

Registered: Oct 2012
Posts: 336
There are also other possibilities. To display an animation, LAX #counter can show a new image every 4th value (since bits 0 and 1 of $7c are 0). For each image, 4 values of data can be put on the stack, e.g., sprite color, X position LSB, X position MSB, Y position.

Or can this be done more efficiently without TAS?
2016-09-24 19:30
Rastah Bar

Registered: Oct 2012
Posts: 336
Quoting Color Bar
Suppose bank 1 is used and screen memory starts at $7800.
Then the sprite image pointers are at $7bf8-$7bff. The trick I'm thinking about uses the and+store operation of TAS, for example
LDY #spritenumber
LAX #yposition
TAS $7BF8,Y	;TAS performs and #$7C, allowing for 32 different sprite images.
PLA
STA $D027,Y	;Assuming I have color data on the stack. Just as an example of using that TAS modifies SP.


The use of the stack looks perhaps a bit "constructed", but the sprite image pointer trick may be a good application of SHX, SHY, or even SHA, e.g.:
LDY #spritenumber
LDX #spritecoordinate
SHX $7BF8,Y
Previous - 1 | 2 | 3 | 4 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Sentinel/Excess/TREX
Smasher/F4CG
Guests online: 115
Top Demos
1 Next Level  (9.8)
2 13:37  (9.7)
3 Mojo  (9.7)
4 50 Years of Flex  (9.7)
5 Coma Light 13  (9.7)
6 Edge of Disgrace  (9.6)
7 Comaland 100%  (9.6)
8 Uncensored  (9.6)
9 No Bounds  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.7)
2 It's More Fun to Com..  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Rainbow Connection  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Booze Design  (9.3)
3 Censor Design  (9.3)
4 Crest  (9.3)
5 Performers  (9.3)
Top Musicians
1 Rob Hubbard  (9.7)
2 Stinsen  (9.7)
3 Jeroen Tel  (9.6)
4 Linus  (9.6)
5 MacMagix  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.074 sec.