Tasm局部变量 [英] Tasm local variables

查看:136
本文介绍了Tasm局部变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆