Intenté ejecutar:
gcc -o main main.c squrt.S -lm -no-pie
Esto funcionó en una computadora diferente, pero esta vez no conocía una sola instrucción:
squrt.S: Assembler messages:
squrt.S:7: Error: unknown pseudo-op: `.intel_syntax'
squrt.S:12: Error: junk at end of line, first unrecognized character is `#'
squrt.S:17: Error: bad instruction `movq rax,xmm0#Bits from xmm0 to rax'
squrt.S:18: Error: bad instruction `shl rax,1'
squrt.S:19: Error: bad instruction `shr rax,53#Exponent of the argument'
squrt.S:20: Error: ARM register expected -- `cmp rax,2047#checks if x is real'
squrt.S:21: Error: bad instruction `je end'
squrt.S:22: Error: ARM register expected -- `mov rcx,1#sgn(x)'
squrt.S:23: Error: ARM register expected -- `mov rax,0'
squrt.S:24: Error: bad instruction `cvtsi2sd xmm1,rax'
squrt.S:25: Error: bad instruction `comisd xmm0,xmm1#vergleicht die double xmm0,xmm1 und setzt das Statusregister entsprechend'
squrt.S:26: Error: bad instruction `jae notNegative#Sprung wenn double x in xmm0>=0.0'
squrt.S:27: Error: ARM register expected -- `mov rcx,-1#x<0,deswegen sgn(x)=-1'
squrt.S:28: Error: bad instruction `cvtsi2sd xmm1,rcx'
squrt.S:29: Error: bad instruction `mulsd xmm0,xmm1'
squrt.S:31: Error: bad instruction `movsd xmm2,[power]'
squrt.S:32: Error: bad instruction `comisd xmm0,xmm2'
squrt.S:33: Error: bad instruction `jbe nichtriesig'
squrt.S:34: Error: bad instruction `call ln#|x|>2^28'
squrt.S:35: Error: bad instruction `movsd xmm1,[ln2]'
squrt.S:36: Error: bad instruction `addsd xmm0,xmm1'
squrt.S:37: Error: bad instruction `cvtsi2sd xmm1,rcx'
squrt.S:38: Error: bad instruction `mulsd xmm0,xmm1'
squrt.S:39: Error: bad instruction `ret #arsinh(x):=sgn(x)(ln(x)+ln(2))'
squrt.S:41: Error: bad instruction `movsd xmm1,xmm0'
squrt.S:42: Error: bad instruction `mulsd xmm0,xmm0'
squrt.S:43: Error: ARM register expected -- `mov rax,1'
squrt.S:44: Error: bad instruction `cvtsi2sd xmm2,rax'
squrt.S:45: Error: bad instruction `addsd xmm0,xmm2'
squrt.S:46: Error: bad instruction `call .Lsqrt'
squrt.S:47: Error: bad instruction `addsd xmm0,xmm1'
squrt.S:48: Error: bad instruction `call ln'
squrt.S:49: Error: bad instruction `cvtsi2sd xmm1,rcx'
squrt.S:50: Error: bad instruction `mulsd xmm0,xmm1'
squrt.S:52: Error: bad instruction `ret'
squrt.S:65: Error: bad instruction `movq rdx,xmm0'
squrt.S:66: Error: bad instruction `shr rdx,52#Mantisse wegschieben'
squrt.S:68: Error: ARM register expected -- `sub rdx,1022#e+1'
squrt.S:70: Error: bad instruction `movq rax,xmm0'
squrt.S:71: Error: bad instruction `shl rax,12#setze Vorzeichen'
squrt.S:72: Error: bad instruction `shr rax,12#und Exponenten auf 0'
squrt.S:73: Error: ARM register expected -- `mov rdi,1022'
squrt.S:74: Error: bad instruction `shl rdi,52#verschiebe(-1+1023)in die oberen 12 bit von rdi(oder genauer gesagt 11 Bit,das 12. wird nicht verändert)'
squrt.S:75: Error: ARM register expected -- `add rax,rdi#neuer Exponent mit alter Mantisse m durch Addition'
squrt.S:76: Error: bad instruction `movq xmm0,rax#enthält m*0,5'
squrt.S:77: Error: ARM register expected -- `mov rax,1'
squrt.S:78: Error: bad instruction `cvtsi2sd xmm3,rax#xmm3=1'
squrt.S:79: Error: bad instruction `movsd xmm4,xmm3'
squrt.S:80: Error: bad instruction `addsd xmm4,xmm3#2'
squrt.S:81: Error: bad instruction `movsd xmm1,xmm3#1=2k+1,da k am Anfang 0 ist'
squrt.S:82: Error: bad instruction `movsd xmm5,xmm0#x'
squrt.S:83: Error: bad instruction `movsd xmm6,xmm0#x'
squrt.S:84: Error: bad instruction `subsd xmm5,xmm3#x-1'
squrt.S:85: Error: bad instruction `addsd xmm6,xmm3#x+1'
squrt.S:86: Error: bad instruction `divsd xmm5,xmm6#((x-1)/(x+1))^(2k+1),wobei k noch 0'
squrt.S:87: Error: bad instruction `movsd xmm7,xmm5'
squrt.S:88: Error: bad instruction `mulsd xmm7,xmm7#(x-1)/(x+1)^2'
squrt.S:89: Error: ARM register expected -- `mov rax,0'
squrt.S:90: Error: bad instruction `movq xmm0,rax#0'
squrt.S:91: Error: ARM register expected -- `mov rsi,5'
squrt.S:93: Error: bad instruction `movsd xmm2,xmm4#2'
squrt.S:94: Error: bad instruction `divsd xmm2,xmm1#2/(2k+1)'
squrt.S:95: Error: bad instruction `mulsd xmm2,xmm5#2/(2k+1))*(((x-1)/(x+1))^(2k+1))'
squrt.S:96: Error: bad instruction `addsd xmm0,xmm2'
squrt.S:97: Error: bad instruction `addsd xmm1,xmm4'
squrt.S:98: Error: bad instruction `mulsd xmm5,xmm7'
squrt.S:99: Error: bad instruction `dec rsi'
squrt.S:100: Error: bad instruction `jg lnLoop'
squrt.S:102: Error: bad instruction `movsd xmm1,[ln2]'
squrt.S:103: Error: bad instruction `cvtsi2sd xmm2,rdx'
squrt.S:104: Error: bad instruction `mulsd xmm1,xmm2'
squrt.S:105: Error: bad instruction `addsd xmm0,xmm1#(ln(x)+(exponent+1)*ln(2))'
squrt.S:106: Error: bad instruction `ret'
squrt.S:109: Error: bad instruction `movsd xmm13,xmm0'
squrt.S:110: Error: bad instruction `movq rax,xmm0'
squrt.S:111: Error: bad instruction `shl rax,1'
squrt.S:112: Error: bad instruction `shr rax,53'
squrt.S:113: Error: ARM register expected -- `sub rax,1023'
squrt.S:114: Error: ARM register expected -- `add rax,1'
squrt.S:115: Error: bad instruction `sar rax,1'
squrt.S:116: Error: ARM register expected -- `add rax,1023'
squrt.S:117: Error: bad instruction `shl rax,52'
squrt.S:118: Error: bad instruction `movq xmm0,rax'
squrt.S:119: Error: bad instruction `movsd xmm15,xmm0'
squrt.S:120: Error: bad instruction `movsd xmm0,xmm13'
squrt.S:122: Error: ARM register expected -- `mov rax,2'
squrt.S:123: Error: bad instruction `cvtsi2sd xmm14,rax#2'
squrt.S:124: Error: ARM register expected -- `mov rax,8#Anzahl Wiederholungen-1'
squrt.S:126: Error: bad instruction `movsd xmm13,xmm0'
squrt.S:127: Error: bad instruction `divsd xmm13,xmm15'
squrt.S:128: Error: bad instruction `addsd xmm13,xmm15'
squrt.S:129: Error: bad instruction `divsd xmm13,xmm14'
squrt.S:130: Error: bad instruction `movsd xmm15,xmm13'
squrt.S:131: Error: bad instruction `dec rax'
squrt.S:132: Error: bad instruction `jle sqrtEnd'
squrt.S:133: Error: bad instruction `jmp sqrtLoop'
squrt.S:135: Error: bad instruction `movsd xmm0,xmm13'
squrt.S:136: Error: bad instruction `ret'
make: *** [Makefile:2: main] Fehler 1
¿Hay algún paquete que tengo que instalar?
Respuesta1
El lenguaje "ensamblador" depende de la arquitectura, ya que su objetivo es escribir directamente instrucciones de la CPU, y cada tipo de CPU tiene otras diferentes. Todo su programa está escrito en código ensamblador amd64/Intel x86_64, pero Raspbian no se ejecuta en ellos: se ejecuta en dispositivos ARM, por lo que el estándar gcc
que viene también espera el ensamblaje ARM.
(Eche un vistazo lscpu
y gcc -dumpmachine
descubra qué tipo de CPU tiene).
Si desea que el programa se ejecute en CPU ARM, debe reescribirlo todo. (Probablemente) no existe ningún paquete gcc que pueda compilar un ensamblado x86 para ejecutarlo en ARM, aunque haypodríaSeamos traductores para ayudarle a reescribir.
Si desea que el programa se ejecute en CPU AMD64/x86_64, pero solo lo compile en Raspbian, debe instalar un compilador cruzado. (Podría estar en gcc-x86-64-linux-gnu + binutils-x86-64-linux-gnu).