包含Irvine32.inc报错的问题

之前学汇编使用了作者提供的Irvine32库,但总是报错如下:

1
2
3
4
1>c:\Irvine\SmallWin.inc(11): error A2071: initializer magnitude too large for specified size
1>c:\Irvine\SmallWin.inc(11): warning A4011: multiple .MODEL directives found : .MODEL ignored
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\masm.targets(50,5): error MSB3721: 命令“ml.exe /c /nologo /Sg /WX /Zi /Fo"Debug\Chapter5.obj" /Fl".lst" /I "c:\Irvine" /W3 /errorReport:prompt /Ta"..\..\..\Users\Eastwind\Do
cuments\《汇编语言-基于x86处理器》资料\Test\Chapter5.asm"”已退出,返回代码为 1。

这个错误的出现是因为在程序中出现了这样的语句:

1
2
3
4
.386
.model flat, stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD

貌似Irvine32.inc已经包含以上语句了,如果再包含,会出现重复。所以删掉它就好了。


另附可用的包含Irvine32.inc的代码如下(书上例程),其功能是改变控制台窗口颜色,并可以以十进制方式输入4个32位数字,显示它的Dec,Hex,Bin:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
include Irvine32.inc

.data
COUNT = 4
BlueTextOnGray = blue + (lightGray * 16)
DefaultColor = lightGray + (black * 16)
arrayD SDWORD 12345678h,1A4B2000h,3434h,7AB9h
prompt BYTE "Enter a 32-bit signed integer: ",0
.code
main PROC
mov eax,BlueTextOnGray
call SetTextColor
call Clrscr

mov esi,OFFSET arrayD
mov ebx,TYPE arrayD
mov ecx,LENGTHOF arrayD
call DumpMem

call Crlf
mov ecx,COUNT

L1: mov edx,OFFSET prompt
call WriteString
call ReadInt
call Crlf

call WriteInt
call Crlf
call WriteHex
call Crlf
call WriteBin
call Crlf
call Crlf
loop L1

call WaitMsg
mov eax,DefaultColor
call SetTextColor
call Clrscr

exit

main ENDP
END main

运行结果如下图:
这里写图片描述


注:书是《汇编语言-基于x86处理器》

0%