You are not logged in.
Lost Password?


Register To Post



 Bottom   Previous Topic   Next Topic

#1
System Register 31 and its Hidden Secrets
Posted on: 2018/4/19 5:01
VUE(xpert)
Joined 2012/12/4
418 Posts
CoderLong Time User (6 Years)
The "system registers" on the VB's CPU represent features of the architecture not directly pertinent to the program being executed. The status register is found in here, as are some other things like exception processing and the hardware breakpoint.

Let's see, it was... three and a half years ago now... I discovered the presence of three more system registers by typing in undocumented register numbers just to see what would happen. Indexes 29, 30 and 31 do not correspond to any system registers in the V810 documentation, but they do respond to probing on Virtual Boy.

At the time, it appeared that system register 31 was just a solitary flag. My tests were quite simple: write 0xFFFFFFFF to a system register, then read the value back to see if it can be written. System register 31 told me 0x00000001, and when I wrote a zero, it gave me a zero back. That looks like a 1-bit register to me. I don't blame my past self for jumping to that conclusion.

While researching for the emulator initiative, I decided to test multiple values on all of the system registers just in case, and 31 was behaving unexpectedly. Not only was it not a 1-bit register, but it has an actual function!

System register 31's secret powers are...

Drum roll please...

Wait for it...

It calculates the absolute value of the number you write to it. Like, you write a 32-bit two's-complement number and when you read from it, you get that number's absolute value. Yeah, that's all. Nothing fancy, but certainly interesting!

Turns out that 0xFFFFFFFF is the two's complement representation of -1, so writing that value to system register 31 gives me a positive 1 in return. And writing a zero, well, gives back a zero. It tricked me and went under the radar for years after I thought I'd conquered it. O-:<
Top

#2
Re: System Register 31 and its Hidden Secrets
Posted on: 2018/4/19 7:02
PVB Elite
Joined 2013/6/17
Canada
1168 Posts
Top10 Poster10+ Game RatingsLong Time User (6 Years)
Wow, nice find! It's crazy there's stuff beyond the documented stuff that you can do with the CPU. Especially finding out about it 23ish years after the console released!
Top

#3
Re: System Register 31 and its Hidden Secrets
Posted on: 2018/4/19 7:09
Nintendoid!
Joined 2012/11/9
Venezuela
128 Posts
Highscore Top10Highscore Top ScoreHighscore Top ScoreHighscore Top ScoreHighscore Top ScoreHighscore Top ScoreLong Time User (7 Years) 90+ Game Ratings
Quote:

Guy Perfect wrote:
The "system registers" on the VB's CPU represent features of the architecture not directly pertinent to the program being executed. The status register is found in here, as are some other things like exception processing and the hardware breakpoint.

Let's see, it was... three and a half years ago now... I discovered the presence of three more system registers by typing in undocumented register numbers just to see what would happen. Indexes 29, 30 and 31 do not correspond to any system registers in the V810 documentation, but they do respond to probing on Virtual Boy.

At the time, it appeared that system register 31 was just a solitary flag. My tests were quite simple: write 0xFFFFFFFF to a system register, then read the value back to see if it can be written. System register 31 told me 0x00000001, and when I wrote a zero, it gave me a zero back. That looks like a 1-bit register to me. I don't blame my past self for jumping to that conclusion.

While researching for the emulator initiative, I decided to test multiple values on all of the system registers just in case, and 31 was behaving unexpectedly. Not only was it not a 1-bit register, but it has an actual function!

System register 31's secret powers are...

Drum roll please...

Wait for it...

It calculates the absolute value of the number you write to it. Like, you write a 32-bit two's-complement number and when you read from it, you get that number's absolute value. Yeah, that's all. Nothing fancy, but certainly interesting!

Turns out that 0xFFFFFFFF is the two's complement representation of -1, so writing that value to system register 31 gives me a positive 1 in return. And writing a zero, well, gives back a zero. It tricked me and went under the radar for years after I thought I'd conquered it. O-:<

Quote:

speedyink wrote:
Wow, nice find! It's crazy there's stuff beyond the documented stuff that you can do with the CPU. Especially finding out about it 23ish years after the console released!

I guess we're still duscovering secrets on old systems years after their release...
Top

#4
Re: System Register 31 and its Hidden Secrets
Posted on: 2018/4/19 17:24
Nintendoid!
Joined 2006/3/15
Ecuador
234 Posts
PVBCC 3rdCoderLong Time User (13 Years)
Hi Guy:

I tried to implement a custom abs function based on your findings, but I guess the compiler that I'm using doesn't have support for the system registers 26-31.

Given that I don't want to bother ElmerPCFX and I don't want to go through the whole process of trying to compile the compiler again, I would like to know if there is any way to write the hex op code for the stsr and ldsr instructions in my C code without having to hack the ROM directly.

jorgeche

Attach file:



png  error.png (113.51 KB)
230_5ad8b4ae335d3.png 1284X684 px
Top

#5
Re: System Register 31 and its Hidden Secrets
Posted on: 2018/4/19 23:08
VUE(xpert)
Joined 2012/12/4
418 Posts
CoderLong Time User (6 Years)
You should be able to specify the register with the number 31, rather than the symbol "sr31".
Top

#6
Re: System Register 31 and its Hidden Secrets
Posted on: 2018/4/19 23:28
PVB Elite
Joined 2011/3/10
USA
914 Posts
Top10 PosterLong Time User (8 Years) 30+ Game Ratings
this was a cool find!
Top

#7
Re: System Register 31 and its Hidden Secrets
Posted on: 2018/4/21 14:10
PVB Elite
Joined 2008/12/28
Slovenia
630 Posts
Highscore Top ScoreHighscore Top ScoreCoderContributor10+ Game RatingsLong Time User (10 Years) App CoderPVBCC 2010 EntryPVBCC 2013 Entry
Interesting! Did you test all 2^32 values?

Unfortunately, given that LDSR and STSR take 8 cycles each, the fastest way to get the absolute value of an integer is still the routine on page 23 of V810 Programming.
Top

#8
Re: System Register 31 and its Hidden Secrets
Posted on: 2018/4/21 21:26
VUE(xpert)
Joined 2012/12/4
418 Posts
CoderLong Time User (6 Years)
Quote:

HorvatM wrote:
Interesting! Did you test all 2^32 values?

I did not, but I checked enough test cases to be confident that its operation is what it appears to be.

If you want to write up a program to test every value, I'd be happy to run it on the hardware. For science.
Top

 Top   Previous Topic   Next Topic


Register To Post