unsigned int a = 0x1eab577e;
unsigned char *b = (unsigned char *) & a;
for (int i=0; i<4; i++) printf ("%x", (unsigned int) b[i]);
What is the output of this code on a Linux x86-64 system? Note that the "%x" format specifier for printf prints an unsigned integer as hexadecimal.
unsigned int a, b;
int c, d;
a = 1 << 31;
b = a * 2;
printf ("%x\n", b);
a = 0x1234;
b = a >> 12;
printf ("%x\n", b);
c = -16;
d = c >> 4;
printf ("%d\n", d);
What is the output of this code on a Linux x86-64 system? Note that the "%d" format specifier for printf prints an integer as a decimal number.
a b c d + a b c d + a b c d + a b c d + a b c d + a b c d + a b c d + a b c d
Give a truth table for the Boolean function of a and b computed by this circuit.
int foo (int a, int b, int c) {
int t = a + b;
int t2 = c - t;
return t2;
}
When compiled into x86_64, it looks like this:
foo:
movl %edx, %eax
addl %esi, %edi
subl %edi, %eax
ret
%edi, %esi, and %edx are parameters a, b, and c, respectively. Note that we are using registers like %eax instead of %rax because the parameters and variables are 32-bit integers, not 64-bit integers.