18bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org/* 28bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * Written by Wilco Dijkstra, 1996. The following email exchange establishes the 38bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * license. 48bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * 58bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * From: Wilco Dijkstra <Wilco.Dijkstra@ntlworld.com> 68bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * Date: Fri, Jun 24, 2011 at 3:20 AM 78bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * Subject: Re: sqrt routine 88bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * To: Kevin Ma <kma@google.com> 98bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * Hi Kevin, 108bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * Thanks for asking. Those routines are public domain (originally posted to 118bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * comp.sys.arm a long time ago), so you can use them freely for any purpose. 128bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * Cheers, 138bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * Wilco 148bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * 158bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * ----- Original Message ----- 168bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * From: "Kevin Ma" <kma@google.com> 178bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * To: <Wilco.Dijkstra@ntlworld.com> 188bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * Sent: Thursday, June 23, 2011 11:44 PM 198bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * Subject: Fwd: sqrt routine 208bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * Hi Wilco, 218bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * I saw your sqrt routine from several web sites, including 228bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * http://www.finesse.demon.co.uk/steven/sqrt.html. 238bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * Just wonder if there's any copyright information with your Successive 248bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * approximation routines, or if I can freely use it for any purpose. 258bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * Thanks. 268bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * Kevin 278bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org */ 288bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 298bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org// Minor modifications in code style for WebRTC, 2012. 308bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org// Code optimizations for MIPS, 2013. 318bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 328bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" 338bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 348bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org/* 358bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * Algorithm: 368bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * Successive approximation of the equation (root + delta) ^ 2 = N 378bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * until delta < 1. If delta < 1 we have the integer part of SQRT (N). 388bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * Use delta = 2^i for i = 15 .. 0. 398bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * 408bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * Output precision is 16 bits. Note for large input values (close to 418bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * 0x7FFFFFFF), bit 15 (the highest bit of the low 16-bit half word) 428bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * contains the MSB information (a non-sign value). Do with caution 438bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * if you need to cast the output to int16_t type. 448bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * 458bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org * If the input value is negative, it returns 0. 468bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org */ 478bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 488bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 498bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.orgint32_t WebRtcSpl_SqrtFloor(int32_t value) 508bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org{ 518bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org int32_t root = 0, tmp1, tmp2, tmp3, tmp4; 528bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 538bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org __asm __volatile( 548bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org ".set push \n\t" 558bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org ".set noreorder \n\t" 568bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 578bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "lui %[tmp1], 0x4000 \n\t" 588bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "slt %[tmp2], %[value], %[tmp1] \n\t" 598bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "sub %[tmp3], %[value], %[tmp1] \n\t" 608bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "lui %[tmp1], 0x1 \n\t" 618bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "or %[tmp4], %[root], %[tmp1] \n\t" 628bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[value], %[tmp3], %[tmp2] \n\t" 638bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[root], %[tmp4], %[tmp2] \n\t" 648bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 658bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addiu %[tmp1], $0, 0x4000 \n\t" 668bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addu %[tmp1], %[tmp1], %[root] \n\t" 678bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "sll %[tmp1], 14 \n\t" 688bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "slt %[tmp2], %[value], %[tmp1] \n\t" 698bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "subu %[tmp3], %[value], %[tmp1] \n\t" 708bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "ori %[tmp4], %[root], 0x8000 \n\t" 718bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[value], %[tmp3], %[tmp2] \n\t" 728bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[root], %[tmp4], %[tmp2] \n\t" 738bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 748bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addiu %[tmp1], $0, 0x2000 \n\t" 758bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addu %[tmp1], %[tmp1], %[root] \n\t" 768bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "sll %[tmp1], 13 \n\t" 778bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "slt %[tmp2], %[value], %[tmp1] \n\t" 788bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "subu %[tmp3], %[value], %[tmp1] \n\t" 798bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "ori %[tmp4], %[root], 0x4000 \n\t" 808bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[value], %[tmp3], %[tmp2] \n\t" 818bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[root], %[tmp4], %[tmp2] \n\t" 828bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 838bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addiu %[tmp1], $0, 0x1000 \n\t" 848bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addu %[tmp1], %[tmp1], %[root] \n\t" 858bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "sll %[tmp1], 12 \n\t" 868bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "slt %[tmp2], %[value], %[tmp1] \n\t" 878bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "subu %[tmp3], %[value], %[tmp1] \n\t" 888bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "ori %[tmp4], %[root], 0x2000 \n\t" 898bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[value], %[tmp3], %[tmp2] \n\t" 908bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[root], %[tmp4], %[tmp2] \n\t" 918bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 928bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addiu %[tmp1], $0, 0x800 \n\t" 938bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addu %[tmp1], %[tmp1], %[root] \n\t" 948bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "sll %[tmp1], 11 \n\t" 958bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "slt %[tmp2], %[value], %[tmp1] \n\t" 968bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "subu %[tmp3], %[value], %[tmp1] \n\t" 978bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "ori %[tmp4], %[root], 0x1000 \n\t" 988bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[value], %[tmp3], %[tmp2] \n\t" 998bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[root], %[tmp4], %[tmp2] \n\t" 1008bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 1018bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addiu %[tmp1], $0, 0x400 \n\t" 1028bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addu %[tmp1], %[tmp1], %[root] \n\t" 1038bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "sll %[tmp1], 10 \n\t" 1048bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "slt %[tmp2], %[value], %[tmp1] \n\t" 1058bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "subu %[tmp3], %[value], %[tmp1] \n\t" 1068bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "ori %[tmp4], %[root], 0x800 \n\t" 1078bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[value], %[tmp3], %[tmp2] \n\t" 1088bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[root], %[tmp4], %[tmp2] \n\t" 1098bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 1108bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addiu %[tmp1], $0, 0x200 \n\t" 1118bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addu %[tmp1], %[tmp1], %[root] \n\t" 1128bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "sll %[tmp1], 9 \n\t" 1138bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "slt %[tmp2], %[value], %[tmp1] \n\t" 1148bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "subu %[tmp3], %[value], %[tmp1] \n\t" 1158bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "ori %[tmp4], %[root], 0x400 \n\t" 1168bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[value], %[tmp3], %[tmp2] \n\t" 1178bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[root], %[tmp4], %[tmp2] \n\t" 1188bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 1198bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addiu %[tmp1], $0, 0x100 \n\t" 1208bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addu %[tmp1], %[tmp1], %[root] \n\t" 1218bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "sll %[tmp1], 8 \n\t" 1228bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "slt %[tmp2], %[value], %[tmp1] \n\t" 1238bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "subu %[tmp3], %[value], %[tmp1] \n\t" 1248bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "ori %[tmp4], %[root], 0x200 \n\t" 1258bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[value], %[tmp3], %[tmp2] \n\t" 1268bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[root], %[tmp4], %[tmp2] \n\t" 1278bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 1288bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addiu %[tmp1], $0, 0x80 \n\t" 1298bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addu %[tmp1], %[tmp1], %[root] \n\t" 1308bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "sll %[tmp1], 7 \n\t" 1318bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "slt %[tmp2], %[value], %[tmp1] \n\t" 1328bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "subu %[tmp3], %[value], %[tmp1] \n\t" 1338bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "ori %[tmp4], %[root], 0x100 \n\t" 1348bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[value], %[tmp3], %[tmp2] \n\t" 1358bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[root], %[tmp4], %[tmp2] \n\t" 1368bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 1378bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addiu %[tmp1], $0, 0x40 \n\t" 1388bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addu %[tmp1], %[tmp1], %[root] \n\t" 1398bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "sll %[tmp1], 6 \n\t" 1408bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "slt %[tmp2], %[value], %[tmp1] \n\t" 1418bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "subu %[tmp3], %[value], %[tmp1] \n\t" 1428bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "ori %[tmp4], %[root], 0x80 \n\t" 1438bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[value], %[tmp3], %[tmp2] \n\t" 1448bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[root], %[tmp4], %[tmp2] \n\t" 1458bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 1468bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addiu %[tmp1], $0, 0x20 \n\t" 1478bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addu %[tmp1], %[tmp1], %[root] \n\t" 1488bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "sll %[tmp1], 5 \n\t" 1498bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "slt %[tmp2], %[value], %[tmp1] \n\t" 1508bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "subu %[tmp3], %[value], %[tmp1] \n\t" 1518bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "ori %[tmp4], %[root], 0x40 \n\t" 1528bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[value], %[tmp3], %[tmp2] \n\t" 1538bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[root], %[tmp4], %[tmp2] \n\t" 1548bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 1558bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addiu %[tmp1], $0, 0x10 \n\t" 1568bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addu %[tmp1], %[tmp1], %[root] \n\t" 1578bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "sll %[tmp1], 4 \n\t" 1588bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "slt %[tmp2], %[value], %[tmp1] \n\t" 1598bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "subu %[tmp3], %[value], %[tmp1] \n\t" 1608bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "ori %[tmp4], %[root], 0x20 \n\t" 1618bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[value], %[tmp3], %[tmp2] \n\t" 1628bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[root], %[tmp4], %[tmp2] \n\t" 1638bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 1648bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addiu %[tmp1], $0, 0x8 \n\t" 1658bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addu %[tmp1], %[tmp1], %[root] \n\t" 1668bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "sll %[tmp1], 3 \n\t" 1678bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "slt %[tmp2], %[value], %[tmp1] \n\t" 1688bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "subu %[tmp3], %[value], %[tmp1] \n\t" 1698bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "ori %[tmp4], %[root], 0x10 \n\t" 1708bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[value], %[tmp3], %[tmp2] \n\t" 1718bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[root], %[tmp4], %[tmp2] \n\t" 1728bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 1738bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addiu %[tmp1], $0, 0x4 \n\t" 1748bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addu %[tmp1], %[tmp1], %[root] \n\t" 1758bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "sll %[tmp1], 2 \n\t" 1768bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "slt %[tmp2], %[value], %[tmp1] \n\t" 1778bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "subu %[tmp3], %[value], %[tmp1] \n\t" 1788bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "ori %[tmp4], %[root], 0x8 \n\t" 1798bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[value], %[tmp3], %[tmp2] \n\t" 1808bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[root], %[tmp4], %[tmp2] \n\t" 1818bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 1828bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addiu %[tmp1], $0, 0x2 \n\t" 1838bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addu %[tmp1], %[tmp1], %[root] \n\t" 1848bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "sll %[tmp1], 1 \n\t" 1858bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "slt %[tmp2], %[value], %[tmp1] \n\t" 1868bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "subu %[tmp3], %[value], %[tmp1] \n\t" 1878bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "ori %[tmp4], %[root], 0x4 \n\t" 1888bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[value], %[tmp3], %[tmp2] \n\t" 1898bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[root], %[tmp4], %[tmp2] \n\t" 1908bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 1918bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addiu %[tmp1], $0, 0x1 \n\t" 1928bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "addu %[tmp1], %[tmp1], %[root] \n\t" 1938bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "slt %[tmp2], %[value], %[tmp1] \n\t" 1948bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "ori %[tmp4], %[root], 0x2 \n\t" 1958bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org "movz %[root], %[tmp4], %[tmp2] \n\t" 1968bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 1978bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org ".set pop \n\t" 1988bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 1998bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org : [root] "+r" (root), [value] "+r" (value), 2008bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org [tmp1] "=&r" (tmp1), [tmp2] "=&r" (tmp2), 2018bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org [tmp3] "=&r" (tmp3), [tmp4] "=&r" (tmp4) 2028bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org : 2038bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org ); 2048bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 2058bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org return root >> 1; 2068bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org} 2078bf755d5c5dd03b3335b22cd687749e140b4aa40andrew@webrtc.org 208