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 :)

7 Years
Discussion Span
Last Post by Salem

What have you done so far?

PS: I am a psychic, but even I cannot tell the instruction set of

a pedagogical processor


Thx for your reply mate, ill pm you what i have made so far.

Edited by kinvaras: n/a


Any other experienced coder willing to help me? Time is running out :|
I have the manual for that processor, i just dont wanna make my code public so that other colleague of mine doesnt copy it and we both get a 0...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.