Suppose you know that when a function with prototype int decode3 (long x, long y
ID: 3597670 • Letter: S
Question
Suppose you know that when a function with prototype int decode3 (long x, long y, long z) is compiled into assembly code, the body of the code is as follows movq %rsi, %rax subq %rdx, %rsi sara 15,%rax salq 31,%rax orq %rsi,%rax ret Parameters x, y, and z are passed in registers %rdi, %rsi, and %rax. The code stores the return value in register %rax Write C code for decode3 that will have an effect equivalent to our assembly code. You can test your solution by compiling your code with the -S switch. Your compiler may not generate identical code, but it should be functionally equivalent (and it ought to at least compile). Using the -0s flag will probably help you get similar code.Explanation / Answer
#include #include #include void main(){ charstring[50],tmp[50]; int spcnt[50],i,j,c; clrscr(); printf("Enter a string : "); gets(string); //encode logicfor(i=0;string[i];i++){ string[i]=string[i]+3; } textcolor(GREEN); printf(" "); cprintf("Encoded string is as follow : %s",string); //decompressed logicfor(i=0;string[i];i++){ string[i]=string[i]-3; } textcolor(GREEN); printf(" "); cprintf("De-Encoded string is as follow : %s",string); getch(); }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.