At last if memory serves, the 6800 doesn't have a division instruction (IIRC that was added in the 6809), so you'll have to implement division on your own (or, if you don't care about speed, just subtract the divisor repeatedly until the result is less than the divisor, and that's your remainder).
To just figure the remainder (without the division) is actually pretty easy in binary:
shift the divisor left until it's larger that the dividend
shift it right one place
If that's smaller than the dividend, subtract it from the dividend
repeat steps 2 and 3 until what's left of the dividend is smaller than the divisor
That's your remainder
For example, let's figure the remainder after dividing 127 by 9. We start by shifting 9 left:
Since 1 is smaller than 9, we have our remainder: 1. In case you want to check that, 9x14=126.
1
globest
On
using easy 68k
#include <iostream>
using namespace std;
int main ()
{
{cout << "THE MULTIPLES OF THREE FROM 1-30 ARE: " <<endl;
int a;
int sum =0;
for (a=1; a<=30; a++)
{if ((a%3) == 0)
{cout <<a << "\n" <<endl;
sum =sum+a;
}}
cout <<"\tSUM = " <<sum<<endl;
}
system ("Pause");
return 0;
}
At last if memory serves, the 6800 doesn't have a division instruction (IIRC that was added in the 6809), so you'll have to implement division on your own (or, if you don't care about speed, just subtract the divisor repeatedly until the result is less than the divisor, and that's your remainder).
To just figure the remainder (without the division) is actually pretty easy in binary:
For example, let's figure the remainder after dividing 127 by 9. We start by shifting 9 left:
shift left until you get:
Repeatedly shift and subtract:
Since 1 is smaller than 9, we have our remainder: 1. In case you want to check that, 9x14=126.