第一种除法算法 Start: place dividend in remainder 对n位商和余数,需要n+1步. 1. Subtract the Divisor register from the 余数 商 除数 Remainder register. and place the result 0000 0111 0000 0010 0000 Lin the Remainder register. Remainder≥0 Test Remainder <o remainder 2a. shift the 2b Restore the original value by adding the Quotient register Divisor register to the Remainder register, to the left setting place the sum in the Remainder register. Also the new rightmost shift the Quotient register to the left, setting bit to 1 the new least significant bit to 0 3. Shift the divisor register right 1 bit n+1 No:<n+repetitions epetition Yes: n+l repetitions (n=4 here 北京大学计算机科学技术系 Done 计算机系统结构教研室
ñ¯M§¯æ*§cù ¯æù;étÐ@ 6KLIWWKH'LYLVRUUHJLVWHUULJKWELW E 5HVWRUHWKHRULJLQDOYDOXH E\DGGLQJWKH 'LYLVRUUHJLVWHUWRWKH5HPDLQGHUUHJLVWHU SODFHWKHVXPLQWKH5HPDLQGHUUHJLVWHU$OVR VKLIWWKH4XRWLHQWUHJLVWHUWRWKHOHIWVHWWLQJ WKHQHZOHDVWVLJQLILFDQWELWWR 'RQH \0ýÇ 6WDUW 3ODFH'LYLGHQGLQ5HPDLQGHU eÍ Q! `-DÈÔUQ9 -D 8D 7HVW 5HPDLQGHU 5HPDLQGHU≥ 5HPDLQGHU 6XEWUDFW WKH'LYLVRUUHJLVWHUIURPWKH 5HPDLQGHUUHJLVWHUDQGSODFHWKHUHVXOW LQWKH5HPDLQGHUUHJLVWHU D 6KLIWWKH 4XRWLHQWUHJLVWHU WRWKHOHIWVHWWLQJ WKHQHZULJKWPRVW ELWWR <HVQUHSHWLWLRQVQ KHUH Q UHSHWLWLRQ" 1RQUHSHWLWLRQV
第一种除法的启示 除数中12的位数总是为0 >64位加法器的12浪费!! =>1/2的除数浪费!! °是否可以用余数左移替代除数右移? 第一步不能在商中产生1(由于开始时余数的高32位为0,或者 被除数太大) =>变换次序到首先移位然后再减,可以减少一次迭代 北京大学计算机科学技术系 计算机系统结构教研室
ñ¯M§¯æ*§cù ¯æù;étÐ@ \0ý´_j e 8D X!D !!t©<X> !X8D> e úùü -DºÏ Ó· 8DÇÏ " e Ô9áÑü{óbÔÊ-DX¬!ÈêÙ 8Dþû !¬6õc jÏ! â a£Ã¹£åÔõÁ·