URL
https://opencores.org/ocsvn/zipcpu/zipcpu/trunk
Subversion Repositories zipcpu
[/] [zipcpu/] [trunk/] [sw/] [lib/] [divu.S] - Rev 45
Go to most recent revision | Compare with Previous | Blame | View Log
;;;;divu: ; Given R0,R1, computer R0 = R0/R1 and R1 = R0%R1TST -1,R1; BNZ divu_valid_divideCLR.Z R0 ; Should be a divide by zero error / trapRETN.Zdivu_valid_divide:SUB 1,SPSTO R3,1(SP);LDI 1,R2 ; Here's where we record the bit we are working onCLR R3 ; Here's where we build our result; Our original loop rejoin point, before a touch of unrollingCMP R1,R0BRC divu_prep_next_bitTST -1,R1BLT divu_top_bit_setdivu_rotate_up_r1:LSL 1,R2LSL 1,R1/*CMP R1,R0BRC divu_prep_next_bitTST -1,R1BGT divu_rotate_up_r1*/BLT divu_top_bit_setCMP R1,R0BRC divu_prep_next_bit;LSL 1,R2LSL 1,R1BLT divu_top_bit_setCMP R1,R0BRC divu_prep_next_bit;LSL 1,R2LSL 1,R1BLT divu_top_bit_setCMP R1,R0BRC divu_prep_next_bit;LSL 1,R2LSL 1,R1BLT divu_top_bit_setCMP R1,R0BRC divu_prep_next_bitBRA divu_rotate_up_r1divu_top_bit_set:CMP R1,R0BRC divu_prep_next_bitSUB R1,R0OR R2,R3divu_prep_next_bit:LSR 1,R1LSR 1,R2BZ divu_record_result;divu_next_loop:CMP R1,R0 ;SUB.GE R1,R0 ; We also switch to signed arithmetic, sinceOR.GE R2,R3 ; after the first bit, we are signedLSR 1,R1LSR 1,R2BZ divu_record_result;CMP R1,R0SUB.GE R1,R0OR.GE R2,R3LSR 1,R1LSR 1,R2BZ divu_record_result;CMP R1,R0SUB.GE R1,R0OR.GE R2,R3LSR 1,R1LSR 1,R2BZ divu_record_result;CMP R1,R0SUB.GE R1,R0OR.GE R2,R3LSR 1,R1LSR 1,R2BNZ divu_next_loopdivu_record_result:MOV R0,R1MOV R3,R0LOD 1(SP),R3ADD 1,SPRETN
Go to most recent revision | Compare with Previous | Blame | View Log
