如何在32位汇编中进行编译?

时间:2019-10-21 18:25:23

标签: c windows gcc assembly x86

嘿,我在c代码中使用32汇编函数。我用nasm和gcc编译它。

nasm -f coff array1.asm
gcc -o array1 array1.o array1c.c

我总是会收到错误:

A
array1c.c:9:1: warning: ‘cdecl’ attribute ignored [-Wattributes]
 int PRE_CDECL asm_main( void ) POST_CDECL;
 ^~~
array1c.c:10:1: warning: ‘cdecl’ attribute ignored [-Wattributes]
 void PRE_CDECL dump_line( void ) POST_CDECL;
 ^~~~
/usr/bin/ld: i386-Architektur der Eingabedatei »array1.o« ist inkompatibel zur Ausgabe i386:x86-64
collect2: error: ld returned 1 exit status

那是我的代码:

/*
 * Driver file for array1.asm file
 */

#include <stdio.h>

#include "cdecl.h"

int PRE_CDECL asm_main( void ) POST_CDECL;
void PRE_CDECL dump_line( void ) POST_CDECL;

int main()
{
  int ret_status;
  ret_status = asm_main();
  return ret_status;
}

/*
 * function dump_line
 * dumps all chars left in current line from input buffer
 */
void dump_line()
{
  int ch;

  while( (ch = getchar()) != EOF && ch != '\n')
    /* null body*/ ;
}

1 个答案:

答案 0 :(得分:2)

您应使用db.student .Join(db.EnrolledYear, s => s.ID, u => u.studentID, (s, u) => new { s, u }) .Join(db.studyYear, x => x.u.studyYearID, g => g.ID, (x, g) => new { x.s, x.u, g }) .Select(x => new { Year = x.g.year, StudentFName = x.s.FirstName, StudentLName = x.s.LastName, }); 将代码编译为32位,如下所示:

gcc -m32