Question about disassembly exit

I have a very simple testing procedure:

void test()
{

  int a = 15;
  int b = 17;
  int c, d;


  c = a + b;
  d = a | c;
  printf("%d", d);
}

I create an object file and then I parse the object file to see the instruction word for ADD and OR operations as follows:

 sparc-elf-objdump -d test.o 

As a result, the disassemble is as follows:

test.o:     file format elf32-sparc

Disassembly of section .text:

00000000 <test>:
   0:   11 00 00 00     sethi  %hi(0), %o0
   4:   90 12 20 00     mov  %o0, %o0   ! 0 <test>
   8:   92 10 20 2f     mov  0x2f, %o1
   c:   82 13 c0 00     mov  %o7, %g1
  10:   40 00 00 00     call  10 <test+0x10>
  14:   9e 10 40 00     mov  %g1, %o7
  18:   01 00 00 00     nop 

As you can see, they are neither an ADD statement nor an OR statement to look up. It seems so? Pretty confusing ...

Thanks a lot jim

+3
source share
2 answers

The compiler has disabled your code - only d is required, and its value can be calculated at compile time.

+4
source

Your instruction

 c = 15 + 17 = 32

In binary

 100000 | 001111= 101111= 0x2f

In line 8 you will see the number above.

   8:   92 10 20 2f     mov  0x2f, %o1

, , , .

+2

Source: https://habr.com/ru/post/1795770/


All Articles