User Tools

Site Tools


base:use_shy_as_sty_x_or_shx_as_stx_y

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
base:use_shy_as_sty_x_or_shx_as_stx_y [2017-11-17 09:15]
cruzer
base:use_shy_as_sty_x_or_shx_as_stx_y [2017-11-17 21:48] (current)
cruzer
Line 25: Line 25:
 However, there'​s a little catch. The value is and'ed with the high byte of the address before it's stored. And to make it even more confusing, it's actually the high byte + 1. So if you store it in $fe00, the value is and'ed with $ff, and therefore unaffected. But since you don't always use all the 8 bits, other addresses might work as well. E.g. if your values are C64 colors, which are between $00 and $0f, the upper 4 bits don't matter. So in that case all pages ending in $e will work, i.e. $0e00, $1e00, etc. However, there'​s a little catch. The value is and'ed with the high byte of the address before it's stored. And to make it even more confusing, it's actually the high byte + 1. So if you store it in $fe00, the value is and'ed with $ff, and therefore unaffected. But since you don't always use all the 8 bits, other addresses might work as well. E.g. if your values are C64 colors, which are between $00 and $0f, the upper 4 bits don't matter. So in that case all pages ending in $e will work, i.e. $0e00, $1e00, etc.
  
-The opcodes are classified as unstable, but this only affects the and'​ing. So sometimes the original X/Y value is stored, and sometimes it's and'ed first. But if you use value/​address combinations where the and'​ing doesn'​t matter, the result is always the same.+===== Instabilities ===== 
 + 
 +The opcodes are classified as unstable, but this only affects ​the behavior. So it doesn'​t risk crashing the computer like e.g. lax immediate. 
 + 
 +The first instability is that the and'​ing ​doesn'​t always take place. So sometimes the original X/Y value is stored, and sometimes it's and'ed first. But if you use value/​address combinations where the and'​ing doesn'​t matter, the result is always the same
 + 
 +Another instability comes when you cross a page boundary like this: 
 + 
 +<​code>​ 
 +ldy #$14 
 +ldx #$01 
 +shy $0eff,x 
 +</​code>​ 
 + 
 +Normally you would expect the value to end up in $0f00, but for reasons unknown, the page changes to the value stored ((H + 1) & y), which in this case is ($0e + 1) & $14 = $04. So the value ends up in $0400.
  
base/use_shy_as_sty_x_or_shx_as_stx_y.txt · Last modified: 2017-11-17 21:48 by cruzer