2

纯粹出于好奇——为什么不能将变量命名为“c”?例如...

.386
.model  flat, stdcall
option  casemap:none

include windows.inc
include kernel32.inc
include user32.inc

includelib user32.lib
includelib kernel32.lib

Main        proto

.data

hOutput dd 0
hInput dd 0

bReadWritten dd 0
szText db "Program calculates the roots of the quadratic expression ax^2+bx+c",10,"Enter a",0 

a dd 0
b dd 0 
c dd 0

delta dd 0

szInput db 128 dup(0)



.data?

.code
start:

Invoke Main
Invoke ExitProcess,0

Main proc
    invoke GetStdHandle, STD_OUTPUT_HANDLE
    mov hOutput, eax

    invoke GetStdHandle,STD_INPUT_HANDLE
    mov hInput, eax

    invoke lstrlen, addr szText
    invoke WriteFile, hOutput, addr szText, eax, ADDR bReadWritten, NULL

    invoke ReadFile, hInput, a, eax,addr bReadWritten, NULL 
    invoke ReadFile, hInput, b, eax,addr bReadWritten, NULL 
    invoke ReadFile, hInput, c, eax,addr bReadWritten, NULL 

    invoke Sleep,10000

    ret
Main endp   


end start

...这会导致组装时错误

C:\3-rd 方程序\winASM\WinAsm\Projects\quadratic equation\EXE.asm(24) : 错误 A2008: 语法错误: c
C:\3-rd 方程序\winASM\WinAsm\Projects\quadratic equation\ EXE.asm(52):错误 A2008:语法错误:c

当我重命名它时,一切都组装并运行良好。

4

1 回答 1

2

尝试将变量命名为PASCALFORTRAN、或。我相信,你会得到同样的错误。如果您碰巧使用以上述语言编写的程序,它们都是指定过程调用约定的关键字。关键字的有效用法如下BASICSYSCALLSTDCALLCfuncname PROTO C arguments...

于 2012-06-15T17:47:08.750 回答