First of all, hi to everyone.
I need help with an assignment, need to translate this C code to assembly. im getting pretty desperate and thats why im turning to outside help...
This code is suposed to calculate sqare roots of 16bit numbers, and is to be implemented on another code as a subroutine. Needs to work on a pedagogical processor. The value to be calculeted comes from the stack pile.
hope i can get some help here!!!
; short sqrt(short num) {
; short op = num;
; short res = 0;
; short one = 1 << 14; // The second-to-top bit is set: 1L<<30 for long
;
; // "one" starts at the highest power of four <= the argument.
; while (one > op)
; one >>= 2;
;
; while (one != 0) {
; if (op >= res + one) {
; op -= res + one;
; res += one << 1;
; }
; res >>= 1;
; one >>= 2;
; }
; return res;
; }
thx for bothering to read :)
cheers