Have you ever wondered just how difficult it is to do division using nothing but NOT,AND,OR,XOR? Well, so do I. It turns out I also need ADD,SUB, and CMP. Also, Shift command. Still, these are easily within the domain of any assembly language programming.
- FOR I=1 TO 8
- IF A-E>=0 THEN A=A-E:C=C+D
- NEXT I
- FOR I=0 TO 8
- VSYNC 1:I=BTRIG():NEXT
- GOTO @DIV2
A contains the number to be divided. B contains the number that divides. This computes C=A/B and A=A%B. A pretty nifty code that fits single screen challenge. Notice, that you can also do it this way (untested) on line 6:
- A=A-E:IF A<0 THEN A=A+E ELSE C=C+D
This way, due to the calculation in Assembly language where the register holds the resulting value of the calculation.