Oricutron and illegal opcode 80

Comments, problems, suggestions about Oric emulators (Euphoric, Mess, Amoric, etc...) it's the right place to ask. And don't hesitate to give your tips and tricks that help using these emulations in the best possible way on your favorite operating system.
User avatar
Symoon
Archivist
Posts: 2301
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France

Oricutron and illegal opcode 80

Post by Symoon »

I noticed something strange in the 1st part of Harrier Attack (loading screen). Apparently, the Atmos version has a bug; on the original tape or transfer bug - I still need to check that but so far I think it was on the original Atmos version of the tape.

Here's the bug, as shown by Oric Explorer:

Code: Select all

$06B2  A9 10      LDA #$10      ..   
$06B4  8D 61 06   STA $0661     .a.
$06B7  A9 07      LDA #$07      .. 
$06B9  09 62      ORA #$62      .b **** => BUG, was 8D 62 06 (STA 0662) on the Oric-1 version ****
$06BB  06 A9      ASL $A9       .. 
$06BD  80         ???           .  
$06BE  8D 63 06   STA $0663     .c.
$06C1  A9 BB      LDA #$BB      .. 
This code is a bit stupid, because it does load and save values in $066* memory... That are already loaded there! Anyway, the bug leads to an illegal opcode $80.

On a real machine: can't see what happens, but the memory locations that are supposed to be set by these instructions remain unaffected, and the loading screen is OK. Of course with illegal opcodes, this might depend on the 6502 version, but I'll let experts investigate here (seems most Orics always react in the same way?)
Bug_real_Atmos.jpg

On Euphoric: nothing seems to happen, the loading screen is perfectly loaded. What happens is that Euphoric executes the illegal opcode, in a way that does not affect the expected result. I'm not sure what happens, here's the step by step sequence from the debugger. Note that apparently illegal opcodes are executed in some way, though not displayed in the CODE area. Here, "???" followed by STA $0663, becomes 80 8D 63 (unknown effect), followed by 06 A9 (ASL $A9). Anyway, the loading screen is OK.
Bug_Euphoric.png

On Oricutron: the illegal opcode is announced as DOP #$80 (what's that?), but when executed step by step, it seems skipped (or interpreted as NOP), thus executing the following STA $0663. So here, the memory values are affected, and the loading screen is shifted.
Bug_Oricutron.png

I'm not willing to start a debate on "how should emaultaors interpret illegal opcodes", but just wanted to point this difference, as it made me belive there was a bug in Novalight ;)
(EDIT: there's a mess with attachements and preview function. Re-uploading files).
User avatar
Symoon
Archivist
Posts: 2301
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France

Re: Oricutron and illegal opcode 80

Post by Symoon »

BTW here's the Harrier Attack version (couldn't attach more than 3 files with my previous message)
harriera.tap
(11.53 KiB) Downloaded 375 times
christian
Pilot Officer
Posts: 96
Joined: Sun Nov 24, 2013 9:58 pm

Re: Oricutron and illegal opcode 80

Post by christian »

Opcode $80 is a NOP immediate and use 2 bytes, so the next instruction is $06BF RRA ($06,X).

Oricutron display the right code and mnemonics but the emulation is wrong because it does not skip the byte $8D (immediate argument).
I think 6502.c lacks a READ_IMM; line 1951 right before the break;

RRA: (ROR - ADC) Performs a ROR on the data, and then ADCs the result into the A register
User avatar
Steve M
Squad Leader
Posts: 787
Joined: Fri Mar 24, 2006 3:33 am
Location: Cumbria, UK
Contact:

Re: Oricutron and illegal opcode 80

Post by Steve M »

This one seems to work.
Attachments
Harrier.tap
(11.45 KiB) Downloaded 352 times
User avatar
Symoon
Archivist
Posts: 2301
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France

Re: Oricutron and illegal opcode 80

Post by Symoon »

Steve M wrote: Wed May 08, 2019 12:46 pm This one seems to work.
ALC progam aside, it's byte for byte the same as the one I posted :mrgreen:
The loading screen is shifted with Oricutron, and then correct once loaded (you may not have noticed since it's loaded quite fast).
Bug_Oricutron_screen.png
Bug_Oricutron_screen.png (1.61 KiB) Viewed 11347 times
Anyway it's interesting, because if this file is from a different source, it confirms that the bug is on the original tape, hence Durell had a very unreliable masters for their tapes duplication (there were also strange things in Scuba Dive IIRC).
User avatar
Symoon
Archivist
Posts: 2301
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France

Re: Oricutron and illegal opcode 80

Post by Symoon »

christian wrote: Wed May 08, 2019 12:42 pm Opcode $80 is a NOP immediate and use 2 bytes, so the next instruction is $06BF RRA ($06,X).

Oricutron display the right code and mnemonics but the emulation is wrong because it does not skip the byte $8D (immediate argument).
I think 6502.c lacks a READ_IMM; line 1951 right before the break;

RRA: (ROR - ADC) Performs a ROR on the data, and then ADCs the result into the A register
Thanks a lot for those explanations! And for bug hunt ;) (though not really bugs when working with illegal opcodes!)
Is there a reliable source on illegal opcodes behaviour on Oric? I've seen multiple sites but there were differences in each of them. Maybe due to different 6502 versions?
christian
Pilot Officer
Posts: 96
Joined: Sun Nov 24, 2013 9:58 pm

Re: Oricutron and illegal opcode 80

Post by christian »

Here is a wiki page with some links: http://visual6502.org/wiki/index.php?ti ... ed_Opcodes

And this one explains how all illegal opcodes are handled by the CPU: https://www.pagetable.com/?p=39
christian
Pilot Officer
Posts: 96
Joined: Sun Nov 24, 2013 9:58 pm

Re: Oricutron and illegal opcode 80

Post by christian »

I tried with a quick fix of Oricutron for opcode $80 and the loading of the screen is correct (no more shift).
I think other illegal opcodes ($xC) are not handled properly, these are also NOP opcodes but 3 bytes long.
User avatar
Chema
Game master
Posts: 3013
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Oricutron and illegal opcode 80

Post by Chema »

Good find!

Imho any emulator should behave as the machine would do. These illegal instructions behave the same on all Orics and could well be used by a real program as this one.

Iirc only some variants of 6502 not used in Orics, behaved differently. At least it should be made an option in emulators.
christian
Pilot Officer
Posts: 96
Joined: Sun Nov 24, 2013 9:58 pm

Re: Oricutron and illegal opcode 80

Post by christian »

Pull request and merge done :)
User avatar
Symoon
Archivist
Posts: 2301
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France

Re: Oricutron and illegal opcode 80

Post by Symoon »

Cool, thanks !
Stupid question but where are we supposed to download Oricutron nowadays?

I'm asking because I don't know how to use GIT, and I don't seem to find your updates here:
https://github.com/pete-gordon/oricutron

Maybe something I don't understand about the way it works.

EDIT: OK, I understand, your "pull request" was in the "closed" list. Thanks once again!
christian
Pilot Officer
Posts: 96
Joined: Sun Nov 24, 2013 9:58 pm

Re: Oricutron and illegal opcode 80

Post by christian »

@Symoon: since there is no new binary release in the Github repository, you have to download the sources and compile on your PC.
An other possibility is to download the developer builds from iss's web site here

I can make the binary but only for Linux targets.
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Oricutron and illegal opcode 80

Post by Dbug »

I know I'm going to feel annoying like a scratched vinyl, scratched vinyl, scratched vinyl, scratched vinyl... but I really, really, really want the people working on Oricutron to come up with a scheme for version number and change list.

It's specially important for when reporting bugs and asking for features.

The OSDK is still using version 1.2, and I will update to a version x.y when I get a win32 version with a meaningful version number and a change history that describe what the changes between 1.2 and x.y are.
User avatar
Symoon
Archivist
Posts: 2301
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France

Re: Oricutron and illegal opcode 80

Post by Symoon »

christian wrote: Fri May 10, 2019 5:46 pm @Symoon: since there is no new binary release in the Github repository, you have to download the sources and compile on your PC.
Thanks for the info!
BTW, is there any special reason for that? (maybe that making releases is not a very interesting work? Or the original author doesn't have time to? But having to install a compiler to have a new executable version is not reallly user-friendly for non-developers ;) )
User avatar
iss
Wing Commander
Posts: 1637
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: Oricutron and illegal opcode 80

Post by iss »

About the official releases maybe it's better to continue the discussion in Oricutron's topic - all rights and decisions belong to the author Xeron!

Else, my developer builds are fresh updated ;).
Post Reply