Tasm局部变量 [英] Tasm local variables
问题描述
使用Tasm 1.4并尝试在过程中创建和操作局部变量:
Using Tasm 1.4 and trying to create and manipulate local variables in procedure:
findMins PROC
local z:word:1 ;outer loop counter
local j:word:1 ;inner loop counter
mov cx, rows ;outer loop total iterations
mov z, 0
RowsLoop:
push cx ; save outer iterations left
mov cx,cols ; inner iterations
mov j, 2
ColsLoop:
//some code
loop ColsLoop
//some code
loop RowsLoop
ret
ENDP
mov j, 2
该指令更改j和z局部变量.我应该如何创建仅在函数内部可见且互不相同的变量,例如,我不想使用操作mov j, 2
更改第二个变量.
mov j, 2
this instruction changes both j and z local variables. How should I create variables that seen only inside function and they are different, e.g I don't want to change the second variable with operation mov j, 2
.
推荐答案
您的函数标头不完整.要强制Turbo汇编器创建结尾和序言,您必须添加一种语言(例如C或PASCAL):findMins PROC C
Your function header is not complete. To force Turbo Assembler to create epilogues and prologues you have to add a language (e.g. C or PASCAL): findMins PROC C
要使变量(和其他符号)成为本地变量,必须在前缀@@
(例如@@z
)之前添加并在程序LOCALS
的开头添加:
To make the variables (and other symbols) local you have to prefix @@
(e.g. @@z
) and to add at the beginning of the program LOCALS
:
LOCALS
.MODEL small
.STACK 1000h
.DATA
rows dw 3
cols dw 7
.CODE
main PROC
MOV ax, @data
MOV ds, ax
call findMins
mov ax, 4C00h
int 21h
main ENDP
findMins PROC C
local @@z:word:1 ;outer loop counter
local @@j:word:1 ;inner loop counter
mov cx, rows ;outer loop total iterations
mov @@z, 0
RowsLoop:
push cx ; save outer iterations left
mov cx,cols ; inner iterations
mov @@j, 2
ColsLoop:
;some code
loop ColsLoop
;some code
loop RowsLoop
ret
ENDP
END main
这篇关于Tasm局部变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!