CS2253/Assigments/2/revised-divide.bin

31 lines
804 B
Plaintext
Raw Permalink Normal View History

2023-05-25 18:39:26 -03:00
0011 000 000000000 ;start point x3000
0101 110 110 1 00000 ;clean R6
0101 101 101 1 00000 ;clean R5
;load memory addresses into registers
1010 011 000001101
1010 100 000001101
;NOT the divident to get negative value and then add one
1001 101 100 1 11111 ; NOT(R4) => R5
0001 101 101 1 00001 ; R5+1 => R5;
0000 1 1 1 000000001 ; skip first increment
0001 110 110 1 00001 ;increment divison count
0001 011 011 000 101 ;subtract
0000 0 1 0 111111101 ;if exact division we can skip final loop
0000 0 0 1 111111100 ;loop back 3 instructions to keep dividing
0001 011 011 000 100 ; get the remainder of the division
;store values in memory;
1011 110 000000101
1011 011 000000101
1111 0000 00100101 ;halt
0000 0000 0000 0000
1100 0000 0000 0000
1011 1111 1111 1111
1011 0000 0000 0000
1010 1111 1111 1111