GAS LISTING ac.s page 1 1 .file "add2.s" 2 .version "01.01" 3 gcc2_compiled.: 4 .globl buff 5 .data 6 .align 32 7 .type buff,@object 8 .size buff,80 9 buff: 10 0000 35 .ascii "5" 11 0001 20706C75 .ascii " plus " 11 7320 12 buff1: 13 0007 35 .ascii "5" 14 0008 20706C75 .ascii " plus " 14 7320 15 buff2: 16 000e 34 .ascii "4" 17 000f 20657175 .ascii " equals " 17 616C7320 18 buff3: 19 0017 39 .ascii "9" 20 0018 0A00 .string "\n" 21 001a 00000000 .zero 62 21 00000000 21 00000000 21 00000000 21 00000000 22 .section .rodata 23 .text 24 .align 4 25 .globl main 26 .type main,@function 27 main: 28 0000 55 pushl %ebp # Save the old frame pointer 29 0001 89E5 movl %esp, %ebp # Start a new fram here 30 0003 6A19 pushl $25 # Setup buffer size 31 0005 68000000 pushl $buff # buffer start address and 31 00 32 000a 6A01 pushl $1 # file descriptor for standard out 33 000c E8FCFFFF call write # and use low-level write service 33 FF 34 0011 83C40C addl $12, %esp # Reset stack pointer 35 0014 8B450C movl 12(%ebp),%eax # Get the pointer to the start of argv 36 0017 8B5004 movl 4(%eax),%edx # Get the ptr to the second argument 37 001a 8B12 movl (%edx), %edx # Get the 1st ASCII number (and three other bytes) 38 # movsbl (%edx), %edx # Get the 1st ASCII number 39 001c 88150000 movb %dl, buff # Put an ASCII 1 in the buffer 39 0000 40 0022 832D0000 sub $'0', buff # and make it binary 40 000030 41 0029 C6050700 movb $'4', buff1 # Put an ASCII 1 in the buffer 41 000034 42 0030 832D0700 sub $'0', buff1 # and make it binary 42 000030 43 0037 C6050E00 movb $50, buff2 # Put an ASCII 2 in the buffer 43 000032 44 003e 80050E00 addb $-48, buff2 # and make it binary 44 0000D0 45 0045 31C0 xor %eax, %eax # Clear all 32 bits of the acumulator 46 0047 02050000 addb buff, %eax # Add the first binary number 46 0000 47 004d 02050700 addb buff1, %eax # Add the first binary number 47 0000 48 0053 02050E00 addb buff2, %eax # Add the second binary number 48 0000 49 0059 80050000 addb $'0', buff # Make first number ASCII 49 000030 50 0060 80050700 addb $'0', buff1 # Make first number ASCII 50 000030 51 0067 80050E00 addb $'0', buff2 # Make second number ASCII 51 000030 52 006e 0430 addb $'0', %eax # Make the result ASCII 53 0070 88051700 movb %eax, buff3 # Save result in the buffer 53 0000 54 0076 6A1A pushl $26 # Do 55 0078 68000000 pushl $buff # write 55 00 56 007d 6A01 pushl $1 # system 57 007f E8FCFFFF call write # service 57 FF 58 0084 83C40C addl $12,%esp # and reset stack pointer 59 .L1: 60 0087 C9 leave 61 0088 C3 ret 62 .Lfe1: 63 .size main,.Lfe1-main 64 .ident "GCC: (GNU) egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)" GAS LISTING ac.s page 3 DEFINED SYMBOLS *ABS*:00000000 add2.s ac.s:3 .text:00000000 gcc2_compiled. ac.s:9 .data:00000000 buff ac.s:12 .data:00000007 buff1 ac.s:15 .data:0000000e buff2 ac.s:18 .data:00000017 buff3 ac.s:27 .text:00000000 main UNDEFINED SYMBOLS write