ArrayAbsolute 函数
ArrayAbsolute 函数将数组的每个元素转换为其绝对值。
参数: AX:数组指针;BX:数组长度。
返回值: 函数不返回值。
标志状态: 函数不改变标志状态。
程序源代码
Intel 8086 汇编程序示例,演示使用 ArrayAbsolute 函数将数组元素转换为绝对值。
title .model small .stack 100h data segment public array dw 4, -1, -4, 3 fmtout db "[%d] \0" data ends code segment public ; 代码段开始 assume ds:data, cs:code include Handyfar.inc ; 包含函数文件 include Handymac.inc ; 包含宏文件 main proc ; main 过程开始 call SetDataSegment ; 调用过程 SetDataSegment mov bx, 4 ; 将数值 4 复制到寄存器 bx lea ax, ds:[array] ; 将变量 array 的地址装入寄存器 ds:ax call ArrayAbsolute ; 调用过程 ArrayAbsolute(ds:ax, 4) mov cx, 4 ; 将数值 4 复制到寄存器 cx lea si, ds:[array] ; 将变量 array 的地址装入寄存器 ds:si PrintArrayLoop: push word ptr[si] ; 第2步:将寄存器 si 的值保存到栈中 lea ax, ds:[fmtout] ; 第1步:将格式字符串 fmtout 的地址装入寄存器 ds:ax call PrintFormatString ; 调用过程 PrintFormatString(ax:fmtout, si) add sp, 2 ; 对齐栈 incw si ; 调用宏 incw。将 si 增加 2 loop PrintArrayLoop ; 当 CX≠0 时执行循环 xor al, al ; 清零寄存器 al call ExitProcess ; 调用过程 ExitProcess main endp ; main 过程结束 code ends ; 代码段结束 end main ; 文件结束。入口点指定为过程 main
[4] [1] [4] [3]
示例取自教材 "HANDYFAR - MASM (Dovgopolov Evgeny Sergeevich)".