This program computes the remainder of the division x / 5
The ramainder (denote it by y) can be computed according to the formula: y = x - 5 * [x/5], where [x/5] if the floor function.
[0] LOD x ; load [x] into ACC [2] DIV #5 ; ACC = [x/5] [4] MUL #5 ; ACC = 5*[x/5] [6] STO t1 ; store 5*[x/5] in t1 (temporary location) [8] LOD x ; ACC = x [10] SUB t1 ; ACC = rem [12] STO y ; save the remainder in y [14] HLT ;stop |