StringGetDigitsEx 函数
StringGetDigitsEx 函数分析字符串并返回在字符串中找到的数字。字符串指针通过栈传递。函数会自动将栈对齐 2 个字节。
参数(栈): 1. 字符串的指针。
返回值: AX:字符串中的整数。
标志状态: 函数不改变标志状态。
程序源代码
Intel 8086 汇编程序示例,演示使用 StringGetDigitsEx 函数从字符串中提取数字。
title .286C .model small .stack 100h data segment public string db "I have 154 rubles\0" fmtout db "He said he only has %d rubles!\0" data ends code segment public assume ds:data, cs:code include Handyfar.inc ; 包含函数文件 include Handymac.inc ; 包含宏文件 main proc call SetDataSegment ; 调用过程 SetDataSegment pushs ds:[string] ; 将变量 string 的地址压入栈顶 call StringGetDigitsEx ; 调用过程 StringGetDigitsEx(string) := AX push ax ; 第2步:将寄存器 ax 的值压入栈顶 leaax ds:[fmtout] ; 第1步:将格式字符串 fmtout 的地址装入寄存器 ds:ax call PrintFormatString ; 调用过程 PrintFormatString(ax:fmtout, ax) add sp, 2 ; 对齐栈 push 0 ; 将字节值(返回代码)压入栈顶 call ExitProcessEx ; 调用过程 ExitProcessEx(0) main endp code ends end main
He said he only has 154 rubles!
示例取自教材 "HANDYFAR - MASM (Dovgopolov Evgeny Sergeevich)".