The StringGetDigits function
The StringGetDigits function analyses a null-terminated string and returns the digits found in the string.
Parameters: AX: Pointer to the string.
Return value: AX: The integer number obtained from the string.
Flag state: The function does not modify the flags.
Program source code
An example program for the Intel 8086 assembler demonstrating the use of the StringGetDigits function to extract numbers from a string.
title .model small .stack 100h data segment public string db "I have 154 rubles\0" fmtout db "He said that he has only %d rubles!\0" data ends code segment public ; Start of the code segment assume ds:data, cs:code include Handyfar.inc ; Include the file with functions main proc ; Start of the main procedure call SetDataSegment ; Call the SetDataSegment procedure lea ax, ds:[string] ; Load the address of the variable string into the ds:ax register call StringGetDigits ; Call the StringGetDigits procedure (ax:string) := AX push ax ; 2nd: save the ax register value on the stack lea ax, ds:[fmtout] ; 1st: Load the address of the fmtout format string into the ds:ax register call PrintFormatString ; Call the PrintFormatString procedure (ax:fmtout, ax) add sp, 2 ; Align the stack xor al, al ; Clear the al register call ExitProcess ; Call the ExitProcess procedure main endp ; End of the main procedure code ends ; End of the code segment end main ; End of file. The main procedure is the entry point
He said that he has only 154 rubles!
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".