what is wrong with "stz" on earth?

Programming the 6502 microprocessor and its relatives in assembly and other languages.
Post Reply
chenxiaohua1111
Posts: 3
Joined: 27 Dec 2004

what is wrong with "stz" on earth?

Post by chenxiaohua1111 »

I am confused when i use "stz" to clear memory that located in zero page in w65c02s instruction sets.
first I defined
year equ e4h
then .......
stz year
the confusion appeared.after compiled,the instruction opcode is "9c e5 00" rather than "64 e5"that i think reasonable.So when the program runs to this step stop will inevitably happen and notify "Error instruction (opcode)at address ....".But even the exactly same intruction sometimes is compiled normally and other times abnormally.
certainly,if using "lda ...,sta ..."replace it ,compiling process is ok,I don't understand why this happened.
User avatar
BitWise
In Memoriam
Posts: 996
Joined: 02 Mar 2004
Location: Berkshire, UK
Contact:

Post by BitWise »

Which assembler and emulator are you using? We might be able to help if you give us some more information.
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
Mats
Posts: 111
Joined: 24 Aug 2003

Post by Mats »

STZ in zero page is $64, otherwise $9c. I.e. both

64 e5

and

9c e5 00

are fine!

The only difference is that the first version saves one byte and is slightly faster.
User avatar
BitWise
In Memoriam
Posts: 996
Joined: 02 Mar 2004
Location: Berkshire, UK
Contact:

Post by BitWise »

The original message hints at two different problems.

1. Even though the 'year' constant is in the $00-$FF range the poster indicates that his assembler is generating an absolute rather than zero-page instruction.
Quote:
the confusion appeared.after compiled,the instruction opcode is "9c e5 00" rather than "64 e5"
This suggests assembler in use is in error or some other factor not visible in the short code sample is misdirecting the assembler.

2. The code appears to be being executed in some kind of emulator that does not support 65C02 opcodes. If this is the case then the poster should stick to the 6502 opcode set and configure his assembler to reject extended instructions.
Quote:
So when the program runs to this step stop will inevitably happen and notify "Error instruction (opcode)at address ....".
More information about the assembler and emulator in use might help determine what is going on here.
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
chenxiaohua1111
Posts: 3
Joined: 27 Dec 2004

maybe it is a problem of assembler

Post by chenxiaohua1111 »

firstly thank you all.
basically,I know the difference of "64.." and "9c..." that generated from "STZ", and then that is my point I don't understand. "STZ YEAR" there should be correspondant to "64.."not "9c.."and so I think it is my assembler's fault.
The assembler i am making use, i think, may be not familiar to you.The IC , manufactured in taiwan, just use 6502 core and then use their own assembler.So I am not very confident to the assembler.
Post Reply