Getting the integer quotient and remainder of a division problem simultaneously.

714 views
Skip to first unread message

Compu chan

unread,
Jan 11, 2018, 4:18:31 PM1/11/18
to speedcrunch
When I googled speedCrunch forums this is what I found, so I hope this is where I ask questions about functionality.

I know functions can only provide a single output. Is there any other way of getting two outputs simultaneously.

I'm an x86 assembly programmer, and I often use speedcrunch to step thrugh calculations to verify results. The result of a division in this architecture is returned as an integer quotient and a remainder.

In speedCrunch I have to do the following commands to check a division result:

To get quotient - hex(int(0x7345/0x654))
To get remainder - hex(mod(0x7345;0x654))

Any way to get both of those results in a single command?
Message has been deleted

Compu chan

unread,
Jan 11, 2018, 5:03:21 PM1/11/18
to speedcrunch
I just realized there was an idiv function, so "hex(int(0x7345/0x654))" can be re-written as "hex(idiv(0x7345;0x654))".

Also, I made it a little easier on myself by defining a couple of functions:

hdiv(x;y) = hex(int(x/y))
hmod(x;y) = hex(mod(x;y))

It would still be nice to do it in one command, or one action. 
Not a big fan of keyboard macro software, so that solution isn't preferable to me.
Thanks.


Helder Correia

unread,
Jan 11, 2018, 6:49:13 PM1/11/18
to speed...@googlegroups.com
Jan 11, 2018, 10:02 PM by codyw1...@gmail.com:
hdiv(x;y) = hex(int(x/y))
hmod(x;y) = hex(mod(x;y))
It would still be nice to do it in one command, or one action. 
This is just aa hack, but it achieves your goal - enable "Settings > Behavior > Enable Complex Numbers" and type:

divmod(x; y) = hex(int(x / y)) + hex(mod(x; y))j


divmod(0x7345; 0x654)

= 0x12+0x15Dj


Reply all
Reply to author
Forward
0 new messages