Compilation based learning --- floating-point operations

((43 .65 / 22 ) + (76.34 * 3.1))  /  ( (12.34 * 6 ) - (140.2 / 94.21) )

 

 1 .section .data
 2 value1:
 3     .float 43.65
 4 value2:
 5     .int 22
 6 value3:
 7     .float 76.34
 8 value4:
 9     .float 3.1
10 value5:
11     .float 12.34
12 value6:
13     .int 6
14 value7:
15     .float 140.2
16 value8: 
17     .float 94.21
18 output:
19     .asciz "The result is %f \n"
20 .section .text
21 .globl _start
22 _start:
23 nop
24     finit
25     flds value1
26     flds value2
27     flds value3
28     flds value4
29     fmul %st(1), %st(0)
30     fmul %st(2), %st(0)
31     flds value5
32     fmul value6
33     flds value7
34     flds value8
35     fdivrp
36     fsubr %st(1), %st(0)
37     fdivr %st(2), %st(0)
38     subl  $8, %esp
39     pushl $output
40     call  printf
41     add $12, %esp
42     pushl $0
43     call exit

 

as -o yunsuan.o yunsuan.s
yunsuan.s: Assembler messages:
yunsuan.s:40: 错误: invalid instruction suffix for `push'
yunsuan.s:43: 错误: invalid instruction suffix for `push'

The reason is that the error in the 64-bit system and 32-bit systems for the treatment of certain commands as assembler instructions supported not the same result.

In the file .s, the instructions comprising: pushl% ebp, the instruction in the 64-bit system can not compile

The workaround: In callee.s, the head of the code to add .code32

Guess you like

Origin www.cnblogs.com/mysky007/p/11247740.html