Next Generation Emulation banner

801 - 820 of 862 Posts

·
PCSX2 Coder
Joined
·
10,122 Posts
Sorry for the double post

@tykel, something that has been annoying me, most operations are done as unsigned operations, however the new 1.3 spec ones use signed operations in order to pass the 1.3 spec test. Shouldn't we just make these unsigned as well as it doesn't make sense from a hardware or programming perspective.

Edit: I have also released a new version of my emulator (1.7), quite a few changes, but I pretty much rewrote the recompiler to support 7 X86 registers in Register Caching instead of one as it represents more closely how it is done than before and hopefully better performance. I changed a bunch of other stuff too, but this was the vast majority of the changes.
 

·
Sober coder
Joined
·
465 Posts
Discussion Starter #802
Sorry for the double post

@tykel, something that has been annoying me, most operations are done as unsigned operations, however the new 1.3 spec ones use signed operations in order to pass the 1.3 spec test. Shouldn't we just make these unsigned as well as it doesn't make sense from a hardware or programming perspective.
My understanding is that values are treated as signed unless it indicates they are unsigned (or that they are addresses/pointers for instance). I'm open to discuss this.

I'll be looking into your recompiler, implementing a JIT is something I still have never got around to doing! :)
 

·
PCSX2 Coder
Joined
·
10,122 Posts
My understanding is that values are treated as signed unless it indicates they are unsigned (or that they are addresses/pointers for instance). I'm open to discuss this.

I'll be looking into your recompiler, implementing a JIT is something I still have never got around to doing! :)
I see, it seems my entire emulator, except the 1.3 spec stuff (For the test) are treated completely as unsigned, all with the exception of Immediate values, although they were unsigned for ages :p The biggest problem is that the specification doesn't specify any of this, nor are there any "U" suffixes to say that values are treated as unsigned. It would be good to standardise this, from a hardware perspective, generally unless it was a specific command (suffixed as said above) it would be treated as signed, however if you do this now with chip16, it breaks lots of the roms :p

Good luck with the recompiler! If you need any help let me know! (btw that was me adding you on facebook :p )
 

·
Registered
Joined
·
59 Posts
I have questions about:
SHL RX, N
SHR RX, N

Is the N-flag mirroring the bit that is shifted out if the 16-bit register or is it suppose to just used as a Negative-flag and shows the state of the top-bit after shifting. If the N-bit isn't used as out-shift-bit, shouldn't the overflow at least be used as this. Or must the user save the out-shift-bit before shifting? I'm working on a nice Chip16 Library and also a good use of it! :)
 

·
PCSX2 Coder
Joined
·
10,122 Posts
I'm confused what you mean? the N bit is how many places to shift for example if you shift this

1111000011110000
say N = 3, in SHR this will become
0001111000011110

in SHL it will become

1000011110000000

in SAR it will be come

1111111000011110

SAL will be the same as the SHL result (the LSB never gets copied)
 

·
Registered
Joined
·
59 Posts
I'm confused what you mean? the N bit is how many places to shift for example if you shift this

1111000011110000
say N = 3, in SHR this will become
0001111000011110

in SHL it will become

1000011110000000

in SAR it will be come

1111111000011110

SAL will be the same as the SHL result (the LSB never gets copied)
Sorry for being unclear. I understand that the N that is listed in the instruction here really is the number of bits it will shift, but in the spec, both N-flag and Z-flag is also changed. What do they tell us? And is there a flag telling us what the last bit shifted out was?
 

·
PCSX2 Coder
Joined
·
10,122 Posts
oh, no you just test the bits of the results, if the top bit is 1, set the N flag, if the whole result is 0, set the zero flag (of course if you set zero you can skip the negative check or visa versa, depending which way you call them)
 

·
Registered
Joined
·
59 Posts
oh, no you just test the bits of the results, if the top bit is 1, set the N flag, if the whole result is 0, set the zero flag (of course if you set zero you can skip the negative check or visa versa, depending which way you call them)
OK thanks! Then the current nChip16 is correct is this matter and I need to save the bit BEFORE shifting if I need to keep track of what shifted out. Thanks! In this matter, it woul be possible to use f.e. the O-bit (overflow) to indicate the shifted out bit. But nevermind, as long as this is 100% clear to everyone then I'm satisfied! On to my library!
 

·
Registered
Joined
·
59 Posts
Why do you need to remember the bit you shifted out? What do you require it for?
It's a secret! :) But in this case, to get more than 16 usuable bits. I've seen several CPU's that handles these just to support relatively fast access to arithmetics more than the machine's native number of bits.
 

·
Sober coder
Joined
·
465 Posts
Discussion Starter #812
It's a secret! :) But in this case, to get more than 16 usuable bits. I've seen several CPU's that handles these just to support relatively fast access to arithmetics more than the machine's native number of bits.
Are you making a proprietary extension to Chip16 then? ;)
I see, it seems my entire emulator, except the 1.3 spec stuff (For the test) are treated completely as unsigned, all with the exception of Immediate values, although they were unsigned for ages :p The biggest problem is that the specification doesn't specify any of this, nor are there any "U" suffixes to say that values are treated as unsigned. It would be good to standardise this, from a hardware perspective, generally unless it was a specific command (suffixed as said above) it would be treated as signed, however if you do this now with chip16, it breaks lots of the roms :p
In terms of the binary operations, shouldn't the resulting bit string be the same regardless of whether it is signed or not, and only change the decimal representation? (E.g. 1000 0000 can be either -127 or 128 depending on whether we treat as a int8_t or uint8_t)
I guess it wouldn't hurt to make this more explicit in the spec, agreed. Could add to each instruction whether the operands are interpreted as signed or unsigned.
 

·
PCSX2 Coder
Joined
·
10,122 Posts
Well as an example

say we have 2 ( 0000 0000 0000 0010 )
and -12 ( 1000 0000 0000 1100 )

now is that -12 or 32780. your results are different depending which it is

2 - -12 = 14
2 - 32780 = 32758 (when wrapped to 16 bit)

obviously the second one should be wrong, but these are the answers the current implementation expects.
 

·
Sober coder
Joined
·
465 Posts
Discussion Starter #814
Well as an example

say we have 2 ( 0000 0000 0000 0010 )
and -12 ( 1000 0000 0000 1100 )

now is that -12 or 32780. your results are different depending which it is

2 - -12 = 14
2 - 32780 = 32758 (when wrapped to 16 bit)

obviously the second one should be wrong, but these are the answers the current implementation expects.
2 == 0000 0000 0000 0010 in both unsigned and signed since the top bit is 0, we agree thus far.

12 == 0000 0000 0000 1100 in both unsigned and signed, similarly;
-12 signed == ~12 + 1 == 1111 1111 1111 0011 + 0..1 == 1111 1111 1111 0100 == 65524 unsigned

2 - -12 = 14
14 == 0000 0000 0000 1110

2 - 65524 == 0 - 65522 == 65536 - 65522 == 14 also, we use the fact 65536 == 0x10000 when we "borrow" an extra bit

I uploaded a quick C program which reinterprets a signed variable's memory as unsigned and performs the operations above, it will show you these results.



However, I still think making when signed and unsigned variables are used more explicit is a good idea. Coming up in spec 1.3b? :p
 

Attachments

·
PCSX2 Coder
Joined
·
10,122 Posts
That works fine in straight C but try doing it in x86, it doesn't work so well :p if i replace my DIV instructions with iDIV (And extend the sign accordingly to EDX) it stops working.
 

·
PCSX2 Coder
Joined
·
10,122 Posts
Sorry for the double post but as you can see I had little choice :p

To celebrate the near 1 year anniversary of somebody last posting in this thread, I have released version 1.81 of my emu. It has improved texture filtering and I have upgraded SDL to version 2.0 which gets rid of that horrible stutter when VSync is enabled, along with fixing a couple of bugs, enjoy!

https://github.com/refractionpcsx2/refchip16/releases/tag/1.81
 

·
Registered
Joined
·
188 Posts
Sorry for the double post but as you can see I had little choice :p

To celebrate the near 1 year anniversary of somebody last posting in this thread, I have released version 1.81 of my emu. It has improved texture filtering and I have upgraded SDL to version 2.0 which gets rid of that horrible stutter when VSync is enabled, along with fixing a couple of bugs, enjoy!

https://github.com/refractionpcsx2/refchip16/releases/tag/1.81
Looks good mate, will give it a spin :)
Thanks for keeping the thread alive! lol
Paul
 

·
Premium Member
Joined
·
5,155 Posts
Screenshot from 2016-10-20 04-18-11.png

Long overdue and not completely finished but I guess it'll work as a proof of concept...
I included both a compiled program and the source.
 

Attachments

·
Sober coder
Joined
·
465 Posts
Discussion Starter #819
Quite a necro-post here, but I keep writing some toy programs for Chip16 in my spare time.

Currently working on this: https://github.com/tykel/plat.c16/
It's a platform game as the name suggests, with the following notable features implemented:
- Pretty good collisions (can't find any bugs in playing anymore, anyway)
- RLE-compressed levels
- Randomly generated backgrounds tilemaps
- Smooth scrolling
- Fade to/from black using palette shifting.

I also made a little support tool which converts text files into binary levels.
 

·
PCSX2 Coder
Joined
·
10,122 Posts
Awesome! looking forward to seeing it :) Compiling it sounds like too much hassle so I'll wait for a ROM :) Looking great though! Thanks for keeping this alive :)
 
801 - 820 of 862 Posts
Top