StringCopyIfNotEx 函数
StringCopyIfNotEx 函数将源字符串中不满足指定函数条件的字符复制到目标缓冲区。函数会自动将栈对齐 6 个字节。
参数(栈): 1. 源字符串的指针。2. 缓冲区的指针。3. 条件函数的指针。
返回值: 函数不返回值。
标志状态: 函数不改变标志状态。
程序源代码
Intel 8086 汇编程序示例,演示使用 StringCopyIfNotEx 函数复制不满足条件的字符。
title .286C .model small .stack 100h data segment public string db "He1ll3o Wo5rld!\0" buffer db 20 dup(0) fmtout db "Copied elements: [%s].\0" data ends code segment public assume ds:data, cs:code include Handyfar.inc ; 包含函数文件 include Handymac.inc ; 包含宏文件 main proc call SetDataSegment ; 调用过程 SetDataSegment pushs IsDigit ; 第3步:将函数 IsDigit 的地址压入栈顶 pushs es:[buffer] ; 第2步:将变量 buffer 的地址压入栈顶 pushs ds:[string] ; 第1步:将变量 string 的地址压入栈顶 call StringCopyIfNotEx ; 调用过程 StringCopyIfNotEx(string, buffer, IsDigit) pushs ds:[buffer] ; 第2步:将变量 buffer 的地址压入栈顶 leaax ds:[fmtout] ; 第1步:将格式字符串 fmtout 的地址装入寄存器 ds:ax call PrintFormatString ; 调用过程 PrintFormatString(ax:fmtout, buffer) add sp, 2 ; 对齐栈 push 0 ; 将字节值(返回代码)压入栈顶 call ExitProcessEx ; 调用过程 ExitProcessEx(0) main endp code ends end main
Copied elements: [Hello World!].
示例取自教材 "HANDYFAR - MASM (Dovgopolov Evgeny Sergeevich)".