No aggregate types such as arrays or structures just

Info icon This preview shows pages 45–52. Sign up to view the full content.

No aggregate types such as arrays or structures Just contiguously allocated bytes in memory
Image of page 45

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Carnegie Mellon 46 Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third Edition Assembly Characteristics: Operations Transfer data between memory and register Load data from memory into register Store register data into memory Perform arithmetic function on register or memory data Transfer control Unconditional jumps to/from procedures Conditional branches Indirect branch
Image of page 46
Carnegie Mellon 47 Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third Edition Code for sumstore 0x0400595: 0x53 0x48 0x89 0xd3 0xe8 0xf2 0xff 0xff 0xff 0x48 0x89 0x03 0x5b 0xc3 Object Code Assembler Translates .s into .o Binary encoding of each instruction Nearly-complete image of executable code Missing linkages between code in different files Linker Resolves references between files Combines with static run-time libraries E.g., code for malloc , printf Some libraries are dynamically linked Linking occurs when program begins execution Total of 14 bytes Each instruction 1, 3, or 5 bytes Starts at address 0x0400595
Image of page 47

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Carnegie Mellon 48 Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third Edition Machine Instruction Example C Code Store value t where designated by dest Assembly Move 8-byte value to memory Quad words in x86-64 parlance Operands: t : Register %rax dest : Register %rbx *dest : Memory M[ %rbx] Object Code 3-byte instruction Stored at address 0x40059e *dest = t; movq %rax, (%rbx) 0x40059e: 48 89 03
Image of page 48
Carnegie Mellon 49 Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third Edition Disassembled Disassembling Object Code Disassembler objdump d sum Useful tool for examining object code Analyzes bit pattern of series of instructions Produces approximate rendition of assembly code Can be run on either a.out (complete executable) or .o file 0000000000400595 <sumstore>: 400595: 53 push %rbx 400596: 48 89 d3 mov %rdx,%rbx 400599: e8 f2 ff ff ff callq 400590 <plus> 40059e: 48 89 03 mov %rax,(%rbx) 4005a1: 5b pop %rbx 4005a2: c3 retq
Image of page 49

Info icon This preview has intentionally blurred sections. Sign up to view the full version.