我从来没有发布到堆栈溢出,我不确定我是否正确发布。
我是使用MASM的新手,我正在开发一个项目,在Windows8操作系统上使用VisualStudio 2012创建Hex游戏。我们计划用C ++添加一个UI接口,所以我们调用过程,但不确定为什么每次调用一个过程时我都会得到这个未定义的错误符号。
另外,当在proc(即TotalSearch)中访问我们的邻接数组时,我们是否传入一个指向邻接数组本身的指针或传递我们声明的指针?
例如,TotalSearch Proc代码标题现在是:
TotalSearch PROC PUBLIC, AP:PTR DWORD, AI:SDWORD
其中AP是adjptr,它是邻接数组的指针 所以它是使用:
调用的INVOKE TotalSearch, adjptr, arrayindex
是否应该以这种方式调用,所以我们传入的是数组的偏移而不是实际的指针本身?如果是这样,如果这些是传入的参数,那么指针是否需要?:
这是数组:
adjacency SDWORD 6 DUP (0)
这应该是电话吗?
INVOKE TotalSearch, adjacency, arrayindex
这些是我每次调用过程时都会遇到的错误:
1>------ Build started: Project: ASM_Project, Configuration: Debug Win32 ------
1> Assembling ShaneMain.asm...
1>ShaneMain.asm(75): error A2006: undefined symbol : ShowBoardColors
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations\masm.targets(49,5): error MSB3721: The command "ml.exe /c /nologo /Zi /Fo"Debug\ShaneMain.obj" /Fl"ASM_Project.lst" /I "c:\Irvine" /W3 /errorReport:prompt /TaShaneMain.asm" exited with code 1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
这是我们的代码。有些行被注释掉,因为我尝试了不同的东西来构建它,但没有一行是成功的。另外,你可以使用声明的常量作为proc中的参数(即redStone)吗?我正在尝试,但不知道我能否,因为它不会建立。
TITLE AssemblyHex (AssemblyHEX.asm)
;.586 ;needed to use INVOKE and work with C/C++
;.model flat, C ;needed to use INVOKE and work with C/C++
;.386
;.model flat,STDCALL
INCLUDE Irvine32.inc
PDWORD TYPEDEF PTR DWORD
;constants declared
visited equ 3; constant to identify visited hex
redStone equ 1 ;constant to identify hex with red stone==>visted red == 4
blueStone equ 2 ;constant to identify hex with blue==>visited blue ==5
emptyH EQU 0 ;constant to identify empty hex ????needed??
;=================================
; DATA
;=================================
.data
;======macro for determining row/column
;===after is called row/column of current hex are put in global variable
_RowColumn MACRO
PUSH EAX
PUSH EDX ;push all registers
CDQ ;zero out edx
mov eax,arrayindex ;move arrayindex to eAX
idiv boardsize ;divide array index by boardsize
mov row,eax
mov column,edx
POP EDX
POP EAX
ENDM
;======macro for determining row/column
bptr PDWORD board
adjptr PDWORD adjacency
ALIGN SDWORD
board SDWORD 121 DUP (0)
adjacency SDWORD 6 DUP (0)
arrayindex SDWORD 0
row SDWORD 0
column SDWORD 0
;redStone DWORD 1 ;variable to identify hex with red stone==>visted red == 4
;blueStone DWORD 2 ;variable to identify hex with blue==>visited blue ==5
redprompt BYTE "Choose an unoccupied hex to place a red stone: ", 0
blueprompt BYTE "Choose an unoccupied hex to place a blue stone: ", 0
invalidhex BYTE "Invalid hex selection! ", 0
isOnBoard DWORD 0 ;variable for if index is on the board 1==yes 0==no
hexState DWORD 0 ;variable for hex state 0==empty, visited==3, red==1, blue==2
boardsize DWORD 11 ;constant to identify board size
totalHexes DWORD 121 ;constant to identify total hexes
;---------------------------------
;=================================
; MAIN
;=================================
.code
main PROC
;=================================
START:
PUSH EAX
PUSH EBX
PUSH ECX
PUSH EDX
PUSH ESI
INVOKE TotalSearch, adjptr, arrayindex
POP ESI
POP EDX
POP ECX
POP EBX
POP EAX
jmp start
EXIT
main ENDP
;=================================
; TotalSearch
;=================================
; Starts at current arrayindex and visits every hex on the board (traverses entire graph).
;
; Arguments: adjptr(AP), arrayindex(AI)
; Registers used:
; Calls:
;=================================
;TotalSearch(adjptr, arrayindex)
TotalSearch PROC PUBLIC, AP:PTR DWORD, AI:SDWORD
; Start at current arrayindex.
; Label current hex as discovered.
PUSH EAX
PUSH EDX
PUSH ESI
INVOKE GetHexState, adjptr, arrayindex
POP ESI
POP EDX
POP EAX
PUSH EAX
PUSH ECX
PUSH ESI
ADD eAx, 3
INVOKE SetHexState, bptr, arrayindex
POP ESI
POP ECX
POP EAX
MOV eSi, OFFSET adjacency
MOV eCx, LENGTHOF adjacency
MOV eBx, TYPE adjacency
CALL DumpMem
CALL Crlf
PUSH EAX
PUSH EBX
PUSH ECX
INVOKE ShowBoard, arrayindex, boardsize
POP ECX
POP EBX
POP EAX
CALL Crlf
; Loop: for all neighbors of current hex, do
; if hex is not discovered, then
; send that hex index to arrayindex and call TotalSearch
MOV eSi, AP
MOV eCx, 6
TOP:
MOV eAx, [eSi];=====================?????????????????????????
MOV AI, eAx
; check if discovered
PUSH EAX
PUSH ESI
PUSH EDX
INVOKE GetHexState, adjptr, arrayindex
POP EDX
POP ESI
POP EAX
CMP hexState, 3
JAE NEXT
PUSH EAX
PUSH ESI
PUSH ECX
PUSH EBX
INVOKE TotalSearch,adjptr,arrayindex
POPAD
POP EBX
POP ECX
POP ESI
POP EAX
NEXT:
ADD eSi, 4
LOOP TOP
; If at initial hex and no unvisited neighbors (loop completes), return to main.
RET
TotalSearch ENDP
END main
答案 0 :(得分:0)
问题是您从未定义过程的入口点。您需要添加带有过程名称的标签以标识入口点。例如:
:
ShowBoardColors PROC PUBLIC, AI:SDWORD, BS:SDWORD
; entry point at the beginning of the procedure
ShowBoardColors:
; set array index to 0 and initialize two loop counters in eBx and eCx
mov eax,AI
MOV eax, 0
: