Linux AT&T 汇编错误:Error: invalid instruction suffix for `push'

本文介绍在64位Linux系统下使用AT&T语法编写32位汇编程序时遇到的错误:“Error:invalid instructionsuffixfor`push'”,并提供了解决方案:在代码开头添加.code32。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在 Linux 使用 AT&T 语法写汇编程序时

程序中有一条命令为:pushl %eax

使用 as 编译时出现错误:Error: invalid instruction suffix for `push'


原因是 64 位系统和 32 位系统的差别引起的


解决方法为:

在代码开头添加 .code32 即可

tianhangsong@ubuntu:~/NachOS-4.1/code/build.linux$ make depend g++ -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -M ../lib/bitmap.cc ../lib/debug.cc ../lib/hash.cc ../lib/libtest.cc ../lib/list.cc ../lib/sysdep.cc ../machine/interrupt.cc ../machine/stats.cc ../machine/timer.cc ../machine/console.cc ../machine/machine.cc ../machine/mipssim.cc ../machine/translate.cc ../machine/network.cc ../machine/disk.cc ../threads/alarm.cc ../threads/kernel.cc ../threads/main.cc ../threads/scheduler.cc ../threads/synch.cc ../threads/synchlist.cc ../threads/thread.cc ../userprog/addrspace.cc ../userprog/exception.cc ../userprog/synchconsole.cc ../filesys/directory.cc ../filesys/filehdr.cc ../filesys/filesys.cc ../filesys/pbitmap.cc ../filesys/openfile.cc ../filesys/synchdisk.cc ../network/post.cc > makedep ed - Makefile.dep < eddep rm eddep makedep tianhangsong@ubuntu:~/NachOS-4.1/code/build.linux$ make g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../lib/bitmap.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../lib/debug.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../lib/libtest.cc ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] "7", "8", "9", "10", "11", "12", "13", "14"}; ^ ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../lib/sysdep.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../machine/interrupt.cc ../machine/interrupt.cc:29:45: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] static char *intLevelNames[] = { "off", "on"}; ^ ../machine/interrupt.cc:29:45: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/interrupt.cc:32:18: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] "network recv"}; ^ ../machine/interrupt.cc:32:18: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/interrupt.cc:32:18: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/interrupt.cc:32:18: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/interrupt.cc:32:18: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/interrupt.cc:32:18: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../machine/stats.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../machine/timer.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../machine/console.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../machine/machine.cc ../machine/machine.cc:19:27: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] "illegal instruction" }; ^ ../machine/machine.cc:19:27: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/machine.cc:19:27: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/machine.cc:19:27: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/machine.cc:19:27: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/machine.cc:19:27: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/machine.cc:19:27: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/machine.cc:19:27: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../machine/mipssim.cc In file included from ../machine/mipssim.cc:22:0: ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] }; ^ ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ../machine/mipssim.cc: In member function ‘void Machine::OneInstruction(Instruction*)’: ../machine/mipssim.cc:139:56: warning: array subscript has type ‘char’ [-Wchar-subscripts] struct OpString *str = &opStrings[instr->opCode]; ^ ../machine/mipssim.cc:158:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] sum = registers[instr->rs] + registers[instr->rt]; ^ ../machine/mipssim.cc:158:50: warning: array subscript has type ‘char’ [-Wchar-subscripts] sum = registers[instr->rs] + registers[instr->rt]; ^ ../machine/mipssim.cc:159:28: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (!((registers[instr->rs] ^ registers[instr->rt]) & SIGN_BIT) && ^ ../machine/mipssim.cc:159:51: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (!((registers[instr->rs] ^ registers[instr->rt]) & SIGN_BIT) && ^ ../machine/mipssim.cc:160:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] ((registers[instr->rs] ^ sum) & SIGN_BIT)) { ^ ../machine/mipssim.cc:164:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = sum; ^ ../machine/mipssim.cc:168:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] sum = registers[instr->rs] + instr->extra; ^ ../machine/mipssim.cc:169:28: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (!((registers[instr->rs] ^ instr->extra) & SIGN_BIT) && ^ ../machine/mipssim.cc:174:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = sum; ^ ../machine/mipssim.cc:178:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = registers[instr->rs] + instr->extra; ^ ../machine/mipssim.cc:178:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = registers[instr->rs] + instr->extra; ^ ../machine/mipssim.cc:182:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] + registers[instr->rt]; ^ ../machine/mipssim.cc:182:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] + registers[instr->rt]; ^ ../machine/mipssim.cc:182:67: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] + registers[instr->rt]; ^ ../machine/mipssim.cc:186:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] & registers[instr->rt]; ^ ../machine/mipssim.cc:186:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] & registers[instr->rt]; ^ ../machine/mipssim.cc:186:67: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] & registers[instr->rt]; ^ ../machine/mipssim.cc:190:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = registers[instr->rs] & (instr->extra & 0xffff); ^ ../machine/mipssim.cc:190:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = registers[instr->rs] & (instr->extra & 0xffff); ^ ../machine/mipssim.cc:194:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rs] == registers[instr->rt]) ^ ../machine/mipssim.cc:194:49: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rs] == registers[instr->rt]) ^ ../machine/mipssim.cc:201:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (!(registers[instr->rs] & SIGN_BIT)) ^ ../machine/mipssim.cc:206:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rs] > 0) ^ ../machine/mipssim.cc:211:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rs] <= 0) ^ ../machine/mipssim.cc:218:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rs] & SIGN_BIT) ^ ../machine/mipssim.cc:223:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rs] != registers[instr->rt]) ^ ../machine/mipssim.cc:223:49: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rs] != registers[instr->rt]) ^ ../machine/mipssim.cc:228:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rt] == 0) { ^ ../machine/mipssim.cc:232:45: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[LoReg] = registers[instr->rs] / registers[instr->rt]; ^ ../machine/mipssim.cc:232:68: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[LoReg] = registers[instr->rs] / registers[instr->rt]; ^ ../machine/mipssim.cc:233:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[HiReg] = registers[instr->rs] % registers[instr->rt]; ^ ../machine/mipssim.cc:233:67: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[HiReg] = registers[instr->rs] % registers[instr->rt]; ^ ../machine/mipssim.cc:238:43: warning: array subscript has type ‘char’ [-Wchar-subscripts] rs = (unsigned int) registers[instr->rs]; ^ ../machine/mipssim.cc:239:43: warning: array subscript has type ‘char’ [-Wchar-subscripts] rt = (unsigned int) registers[instr->rt]; ^ ../machine/mipssim.cc:258:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[NextPCReg] + 4; ^ ../machine/mipssim.cc:260:31: warning: array subscript has type ‘char’ [-Wchar-subscripts] pcAfter = registers[instr->rs]; ^ ../machine/mipssim.cc:265:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] tmp = registers[instr->rs] + instr->extra; ^ ../machine/mipssim.cc:279:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] tmp = registers[instr->rs] + instr->extra; ^ ../machine/mipssim.cc:297:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = instr->extra << 16; ^ ../machine/mipssim.cc:301:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] tmp = registers[instr->rs] + instr->extra; ^ ../machine/mipssim.cc:313:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] tmp = registers[instr->rs] + instr->extra; ^ ../machine/mipssim.cc:341:41: warning: array subscript has type ‘char’ [-Wchar-subscripts] nextLoadValue = registers[instr->rt]; ^ ../machine/mipssim.cc:365:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] tmp = registers[instr->rs] + instr->extra; ^ ../machine/mipssim.cc:393:41: warning: array subscript has type ‘char’ [-Wchar-subscripts] nextLoadValue = registers[instr->rt]; ^ ../machine/mipssim.cc:421:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[HiReg]; ^ ../machine/mipssim.cc:425:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[LoReg]; ^ ../machine/mipssim.cc:429:40: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[HiReg] = registers[instr->rs]; ^ ../machine/mipssim.cc:433:40: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[LoReg] = registers[instr->rs]; ^ ../machine/mipssim.cc:437:26: warning: array subscript has type ‘char’ [-Wchar-subscripts] Mult(registers[instr->rs], registers[instr->rt], TRUE, ^ ../machine/mipssim.cc:437:48: warning: array subscript has type ‘char’ [-Wchar-subscripts] Mult(registers[instr->rs], registers[instr->rt], TRUE, ^ ../machine/mipssim.cc:442:26: warning: array subscript has type ‘char’ [-Wchar-subscripts] Mult(registers[instr->rs], registers[instr->rt], FALSE, ^ ../machine/mipssim.cc:442:48: warning: array subscript has type ‘char’ [-Wchar-subscripts] Mult(registers[instr->rs], registers[instr->rt], FALSE, ^ ../machine/mipssim.cc:447:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = ~(registers[instr->rs] | registers[instr->rt]); ^ ../machine/mipssim.cc:447:46: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = ~(registers[instr->rs] | registers[instr->rt]); ^ ../machine/mipssim.cc:447:69: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = ~(registers[instr->rs] | registers[instr->rt]); ^ ../machine/mipssim.cc:451:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] | registers[instr->rt]; ^ ../machine/mipssim.cc:451:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] | registers[instr->rt]; ^ ../machine/mipssim.cc:451:67: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] | registers[instr->rt]; ^ ../machine/mipssim.cc:455:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = registers[instr->rs] | (instr->extra & 0xffff); ^ ../machine/mipssim.cc:455:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = registers[instr->rs] | (instr->extra & 0xffff); ^ ../machine/mipssim.cc:460:23: warning: array subscript has type ‘char’ [-Wchar-subscripts] (registers[instr->rs] + instr->extra), 1, registers[instr->rt])) ^ ../machine/mipssim.cc:460:64: warning: array subscript has type ‘char’ [-Wchar-subscripts] (registers[instr->rs] + instr->extra), 1, registers[instr->rt])) ^ ../machine/mipssim.cc:466:23: warning: array subscript has type ‘char’ [-Wchar-subscripts] (registers[instr->rs] + instr->extra), 2, registers[instr->rt])) ^ ../machine/mipssim.cc:466:64: warning: array subscript has type ‘char’ [-Wchar-subscripts] (registers[instr->rs] + instr->extra), 2, registers[instr->rt])) ^ ../machine/mipssim.cc:471:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rt] << instr->extra; ^ ../machine/mipssim.cc:471:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rt] << instr->extra; ^ ../machine/mipssim.cc:475:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rt] << ^ ../machine/mipssim.cc:475:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rt] << ^ ../machine/mipssim.cc:476:26: warning: array subscript has type ‘char’ [-Wchar-subscripts] (registers[instr->rs] & 0x1f); ^ ../machine/mipssim.cc:480:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rs] < registers[instr->rt]) ^ ../machine/mipssim.cc:480:48: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rs] < registers[instr->rt]) ^ ../machine/mipssim.cc:481:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = 1; ^ ../machine/mipssim.cc:483:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = 0; ^ ../machine/mipssim.cc:487:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rs] < instr->extra) ^ ../machine/mipssim.cc:488:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = 1; ^ ../machine/mipssim.cc:490:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = 0; ^ ../machine/mipssim.cc:494:26: warning: array subscript has type ‘char’ [-Wchar-subscripts] rs = registers[instr->rs]; ^ ../machine/mipssim.cc:497:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = 1; ^ ../machine/mipssim.cc:499:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = 0; ^ ../machine/mipssim.cc:503:26: warning: array subscript has type ‘char’ [-Wchar-subscripts] rs = registers[instr->rs]; ^ ../machine/mipssim.cc:504:26: warning: array subscript has type ‘char’ [-Wchar-subscripts] rt = registers[instr->rt]; ^ ../machine/mipssim.cc:506:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = 1; ^ ../machine/mipssim.cc:508:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = 0; ^ ../machine/mipssim.cc:512:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rt] >> instr->extra; ^ ../machine/mipssim.cc:512:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rt] >> instr->extra; ^ ../machine/mipssim.cc:516:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rt] >> ^ ../machine/mipssim.cc:516:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rt] >> ^ ../machine/mipssim.cc:517:26: warning: array subscript has type ‘char’ [-Wchar-subscripts] (registers[instr->rs] & 0x1f); ^ ../machine/mipssim.cc:521:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] tmp = registers[instr->rt]; ^ ../machine/mipssim.cc:523:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = tmp; ^ ../machine/mipssim.cc:527:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] tmp = registers[instr->rt]; ^ ../machine/mipssim.cc:528:30: warning: array subscript has type ‘char’ [-Wchar-subscripts] tmp >>= (registers[instr->rs] & 0x1f); ^ ../machine/mipssim.cc:529:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = tmp; ^ ../machine/mipssim.cc:533:28: warning: array subscript has type ‘char’ [-Wchar-subscripts] diff = registers[instr->rs] - registers[instr->rt]; ^ ../machine/mipssim.cc:533:51: warning: array subscript has type ‘char’ [-Wchar-subscripts] diff = registers[instr->rs] - registers[instr->rt]; ^ ../machine/mipssim.cc:534:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (((registers[instr->rs] ^ registers[instr->rt]) & SIGN_BIT) && ^ ../machine/mipssim.cc:534:50: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (((registers[instr->rs] ^ registers[instr->rt]) & SIGN_BIT) && ^ ../machine/mipssim.cc:535:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] ((registers[instr->rs] ^ diff) & SIGN_BIT)) { ^ ../machine/mipssim.cc:539:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = diff; ^ ../machine/mipssim.cc:543:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] - registers[instr->rt]; ^ ../machine/mipssim.cc:543:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] - registers[instr->rt]; ^ ../machine/mipssim.cc:543:67: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] - registers[instr->rt]; ^ ../machine/mipssim.cc:548:23: warning: array subscript has type ‘char’ [-Wchar-subscripts] (registers[instr->rs] + instr->extra), 4, registers[instr->rt])) ^ ../machine/mipssim.cc:548:64: warning: array subscript has type ‘char’ [-Wchar-subscripts] (registers[instr->rs] + instr->extra), 4, registers[instr->rt])) ^ ../machine/mipssim.cc:553:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] tmp = registers[instr->rs] + instr->extra; ^ ../machine/mipssim.cc:585:33: warning: array subscript has type ‘char’ [-Wchar-subscripts] value = registers[instr->rt]; ^ ../machine/mipssim.cc:588:58: warning: array subscript has type ‘char’ [-Wchar-subscripts] value = (value & 0xff000000) | ((registers[instr->rt] >> 8) & ^ ../machine/mipssim.cc:592:58: warning: array subscript has type ‘char’ [-Wchar-subscripts] value = (value & 0xffff0000) | ((registers[instr->rt] >> 16) & ^ ../machine/mipssim.cc:596:58: warning: array subscript has type ‘char’ [-Wchar-subscripts] value = (value & 0xffffff00) | ((registers[instr->rt] >> 24) & ^ ../machine/mipssim.cc:612:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] tmp = registers[instr->rs] + instr->extra; ^ ../machine/mipssim.cc:644:55: warning: array subscript has type ‘char’ [-Wchar-subscripts] value = (value & 0xffffff) | (registers[instr->rt] << 24); ^ ../machine/mipssim.cc:647:53: warning: array subscript has type ‘char’ [-Wchar-subscripts] value = (value & 0xffff) | (registers[instr->rt] << 16); ^ ../machine/mipssim.cc:650:51: warning: array subscript has type ‘char’ [-Wchar-subscripts] value = (value & 0xff) | (registers[instr->rt] << 8); ^ ../machine/mipssim.cc:653:33: warning: array subscript has type ‘char’ [-Wchar-subscripts] value = registers[instr->rt]; ^ ../machine/mipssim.cc:675:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] ^ registers[instr->rt]; ^ ../machine/mipssim.cc:675:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] ^ registers[instr->rt]; ^ ../machine/mipssim.cc:675:67: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] ^ registers[instr->rt]; ^ ../machine/mipssim.cc:679:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = registers[instr->rs] ^ (instr->extra & 0xffff); ^ ../machine/mipssim.cc:679:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = registers[instr->rs] ^ (instr->extra & 0xffff); ^ g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../machine/translate.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../machine/network.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../machine/disk.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../threads/alarm.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../threads/kernel.cc ../threads/kernel.cc: In member function ‘void Kernel::Initialize()’: ../threads/kernel.cc:93:38: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] currentThread = new Thread("main"); ^ ../threads/kernel.cc: In member function ‘void Kernel::ThreadSelfTest()’: ../threads/kernel.cc:152:39: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] semaphore = new Semaphore("test", 0); ^ ../threads/kernel.cc: In member function ‘void Kernel::NetworkTest()’: ../threads/kernel.cc:208:22: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] char *data = "Hello there!"; ^ ../threads/kernel.cc:209:21: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] char *ack = "Got it!"; ^ In file included from ../threads/synchlist.h:49:0, from ../threads/kernel.cc:14: ../threads/synchlist.cc: In instantiation of ‘SynchList<T>::SynchList() [with T = int]’: ../threads/kernel.cc:158:20: required from here ../threads/synchlist.cc:26:10: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] lock = new Lock("list lock"); ^ ../threads/synchlist.cc:27:15: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] listEmpty = new Condition("list empty cond"); ^ ../threads/synchlist.cc: In instantiation of ‘void SynchList<T>::SelfTest(T) [with T = int]’: ../threads/kernel.cc:159:25: required from here ../threads/synchlist.cc:120:39: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] Thread *helper = new Thread("ping"); ^ g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../threads/main.cc ../threads/main.cc:59:8: warning: extra tokens at end of #endif directive [enabled by default] #endif TUT ^ In file included from ../threads/main.cc:41:0: ../lib/copyright.h:23:26: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] static char *copyright = "Copyright (c) 1992-1993 The Regents of the University of California. All rights reserved."; ^ ../threads/main.cc: In function ‘int main(int, char**)’: ../threads/main.cc:182:22: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] char *debugArg = ""; ^ g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../threads/scheduler.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../threads/synch.cc ../threads/synch.cc: In member function ‘void Semaphore::SelfTest()’: ../threads/synch.cc:138:39: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] Thread *helper = new Thread("ping"); ^ ../threads/synch.cc:141:35: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] ping = new Semaphore("ping", 0); ^ ../threads/synch.cc: In constructor ‘Lock::Lock(char*)’: ../threads/synch.cc:161:40: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] semaphore = new Semaphore("lock", 1); // initially, unlocked ^ ../threads/synch.cc: In member function ‘void Condition::Wait(Lock*)’: ../threads/synch.cc:250:43: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] waiter = new Semaphore("condition", 0); ^ g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../threads/thread.cc ../threads/thread.cc: In member function ‘void Thread::SelfTest()’: ../threads/thread.cc:430:43: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] Thread *t = new Thread("forked thread"); ^ g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../userprog/addrspace.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../userprog/exception.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../userprog/synchconsole.cc ../userprog/synchconsole.cc: In constructor ‘SynchConsoleInput::SynchConsoleInput(char*)’: ../userprog/synchconsole.cc:23:33: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] lock = new Lock("console in"); ^ ../userprog/synchconsole.cc:24:44: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] waitFor = new Semaphore("console in", 0); ^ ../userprog/synchconsole.cc: In constructor ‘SynchConsoleOutput::SynchConsoleOutput(char*)’: ../userprog/synchconsole.cc:79:34: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] lock = new Lock("console out"); ^ ../userprog/synchconsole.cc:80:45: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] waitFor = new Semaphore("console out", 0); ^ g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../filesys/directory.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../filesys/filehdr.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../filesys/filesys.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../filesys/pbitmap.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../filesys/openfile.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../filesys/synchdisk.cc ../filesys/synchdisk.cc: In constructor ‘SynchDisk::SynchDisk()’: ../filesys/synchdisk.cc:30:46: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] semaphore = new Semaphore("synch disk", 0); ^ ../filesys/synchdisk.cc:31:38: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] lock = new Lock("synch disk lock"); ^ g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../network/post.cc ../network/post.cc: In constructor ‘PostOfficeInput::PostOfficeInput(int)’: ../network/post.cc:155:60: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] messageAvailable = new Semaphore("message available", 0); ^ ../network/post.cc:162:43: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] Thread *t = new Thread("postal worker"); ^ ../network/post.cc: In constructor ‘PostOfficeOutput::PostOfficeOutput(double)’: ../network/post.cc:268:50: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] messageSent = new Semaphore("message sent", 0); ^ ../network/post.cc:269:44: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] sendLock = new Lock("message send lock"); ^ In file included from ../threads/synchlist.h:49:0, from ../network/post.h:34, from ../network/post.cc:20: ../threads/synchlist.cc: In instantiation of ‘SynchList<T>::SynchList() [with T = Mail*]’: ../network/post.cc:52:38: required from here ../threads/synchlist.cc:26:10: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] lock = new Lock("list lock"); ^ ../threads/synchlist.cc:27:15: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] listEmpty = new Condition("list empty cond"); ^ /lib/cpp -P -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -Dx86 -DLINUX ../threads/switch.s > swtch.s as -o switch.o swtch.s swtch.s: Assembler messages: swtch.s:7: 错误invalid instruction suffix for `push' swtch.s:9: 错误invalid instruction suffix for `push' swtch.s:10: 错误: operand type mismatch for `call' swtch.s:11: 错误: operand type mismatch for `call' swtch.s:12: 错误: operand type mismatch for `call' swtch.s:14: 错误invalid instruction suffix for `pop' Makefile:342: recipe for target 'switch.o' failed make: *** [switch.o] Error 1
05-12
<think>嗯,用户遇到了汇编语言中的错误A2070,需要解决。首先,我得回忆一下这个错误的原因。根据之前的引用,这个错误通常是因为操作数无效,尤其是在使用MOVD指令时没有指定操作数的大小。比如,引用2和4提到,需要添加dword ptr来修饰内存操作数,比如将movdmm4, [esp+0]改为movd mm4,dwordptr [esp+0]。这可能是因为汇编器无法推断操作数的大小,所以必须显式指定。用户提到错误出现在main.asm的第30行,所以需要具体检查那一行的代码。可能的错误点包括使用内存操作数而没有指定大小,或者寄存器与操作数类型不匹配。例如,MOVD指令要求目标或源操作数是MMX寄存器或内存地址,并且内存地址必须用dwordptr或qwordptr等修饰符明确大小。另外,引用4指出在Visual Studio2005中,汇编器要求显式指定内存操作数的大小,这可能适用于用户的环境。所以解决方案应该是检查第30行的MOVD或其他类似指令,确保内存操作数前有dword ptr或类似的修饰符。可能还需要考虑其他指令是否有同样的问题,比如MOVQ或其他涉及内存操作的指令。用户应该逐一检查所有出现错误的地方,并添加必要的修饰符。此外,确保寄存器类型与指令匹配,比如MMX指令使用正确的寄存器,避免操作数大小不匹配。 总结步骤:1.定位错误行;2.检查内存操作数是否有大小修饰符;3.添加dword ptr等;4.检查其他类似指令;5.重新编译测试。同时,提供示例代码修改,帮助用户理解如何修正。</think>### 错误 A2070: invalid instruction operands 的解决方案 #### 错误原因分析 错误 `A2070: invalid instruction operands` 表示汇编器无法识别指令的操作数类型或格式,常见于以下场景[^2][^4]: 1. **内存操作数未明确指定大小**:例如 `movd mm4, [esp+0]` 未标注 `dword ptr`,导致汇编器无法推断操作数大小。 2. **寄存器与操作数类型不匹配**:例如将 MMX 寄存器与非对齐内存地址结合使用。 3. **指令语法错误**:操作数顺序或类型违反汇编规则(如 `movd` 要求目标为寄存器,源为内存或立即数)。 #### 解决步骤 1. **定位错误行** 检查 `main.asm` 第 30 行代码,确认具体指令和操作数格式。 2. **添加内存操作数大小修饰符** 若涉及内存操作(如 `[esp+0]`),需用 `dword ptr` 或 `qword ptr` 明确操作数大小: ```asm ; 错误示例 movd mm4, [esp+0] ; 修正示例(添加 dword ptr) movd mm4, dword ptr [esp+0] ``` 3. **检查寄存器兼容性** 确保指令支持的寄存器类型,例如: - `movd` 目标需为 MMX/XMM 寄存器,源需为 32 位寄存器或内存地址。 - 避免混合使用不同位宽的寄存器(如 `eax` 与 `mm0`)。 4. **验证指令语法** 参考汇编器手册确认指令格式,例如: ```asm ; 正确语法示例 movd mm0, dword ptr [eax] ; 从内存加载到 MMX 寄存器 movd dword ptr [ebx], mm1 ; 从 MMX 寄存器保存到内存 ``` 5. **扩展检查** 若其他行存在类似错误(如第 1432、1576 行[^1][^3]),需重复上述步骤修正。 #### 示例修正 假设第 30 行代码为: ```asm movd mm0, [ebp-4] ``` 修正后应为: ```asm movd mm0, dword ptr [ebp-4] ``` #### 验证与测试 重新编译代码,观察错误是否消除。若问题持续,检查其他潜在语法错误(如操作数对齐问题)。 --- ###
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值