Original Post

Here’s an idea: whenever you do something even mildly noteworthy with Virtual Boy, feel free to share it!
___________

What I did just now: I implemented an algorithm where [font=Courier New]SETF[/font] was the best instruction to use!

The problem was that I needed to multiply two numbers stored in 24.8 fixed-point format, and the output should also be 24.8 fixed-point rounded to nearest. My implementation honest-to-goodness uses [font=Courier New]SETF[/font], and I’ll be darned if it’s not the most efficient way to do the task at hand.

Let’s say the function satisfies the following prototype:

u32 MulFixed_24_8(u32 a, u32 b);

The corresponding implementation would be this:

MULU r6, r7
SHL  24, r30
SHR  8, r7
SETF C, r10
OR   r30, r7
ADD  r7, r10
JMP  [r31]

I’m leaving out comments on purpose. Take a moment to pick apart what’s going on, and if you need any tips lemme know!

0 Replies

No replies yet.

 

Write a reply

You must be logged in to reply to this topic.