StringGetDigits 函数
StringGetDigits 函数分析以零结尾的字符串,并返回其中找到的数字。
参数: AX:字符串指针。
返回值: AX:从字符串中得到的整数。
标志状态: 函数不改变标志状态。
程序源代码
Intel 8086 汇编程序示例,演示使用 StringGetDigits 函数从字符串中提取数字。
title .model small .stack 100h data segment public string db "I have 154 rubles\0" fmtout db "He said he has only %d rubles!\0" data ends code segment public ; 代码段开始 assume ds:data, cs:code include Handyfar.inc ; 包含函数文件 main proc ; main 过程开始 call SetDataSegment ; 调用过程 SetDataSegment lea ax, ds:[string] ; 将变量 string 的地址装入寄存器 ds:ax call StringGetDigits ; 调用过程 StringGetDigits(ax:string) := AX push ax ; 第2步:将寄存器 ax 的值保存到栈中 lea ax, ds:[fmtout] ; 第1步:将格式字符串 fmtout 的地址装入寄存器 ds:ax call PrintFormatString ; 调用过程 PrintFormatString(ax:fmtout, ax) add sp, 2 ; 平衡栈 xor al, al ; 清零寄存器 al call ExitProcess ; 调用过程 ExitProcess main endp ; main 过程结束 code ends ; 代码段结束 end main ; 文件结束。入口点指定为过程 main
He said he has only 154 rubles!
示例取自教材 "HANDYFAR - MASM (Dovgopolov Evgeny Sergeevich)".