Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Suma dos numeros de 16 bits obteniendo el resultado en 32bits
- // NOTA unsigned short 2 bytes ,unsigned int 4 bytes
- // movzwl copia de word a long completando con ceros ....
- #include <iostream>
- using namespace std;
- unsigned int suma (unsigned short numA ,unsigned short numB){
- unsigned int numRes(0);
- asm(
- "movzwl %[numA],%%eax \n\t"/* move word to long */
- "movzwl %[numB],%%ebx \n\t"
- "add %%ebx,%%eax \n\t"/* suma eax=eax+ebx*/
- "mov %%eax,%[numRes] \n\t"/* numRes=eax */
- :[numRes]"=r"(numRes)
- :[numA] "r"(numA),[numB] "r" (numB)
- );
- return numRes;
- }
- int main (){
- cout <<suma (65535,65535);//131072
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement