The StringCopy function
The StringCopy function copies the contents of a null-terminated (\0) string into a prepared buffer.
Parameters: DS:AX - pointer to the source string; ES:BX - pointer to the destination buffer.
Return value: The function does not return a value.
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 StringCopy function to copy a string into a buffer.
title .model small .stack 100h data segment public string db "Hello, World of 8086 Assembler!\0" buffer db ($-string) - 1 dup(0) fmtout db "Copied string: %s\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 bx, es:[buffer] ; Load the address of the variable buffer into the es:bx register lea ax, ds:[string] ; Load the address of the variable string into the ds:ax register call StringCopy ; Call the StringCopy procedure (ds:ax, es:bx) lea ax, ds:[buffer] ; Load the address of the variable buffer into the ds:ax register push ax ; 2nd: save the ax register value on the stack lea ax, ds:[fmtout] ; 1st: Load the address of the format string fmtout into the ds:ax register call PrintFormatString ; Call the PrintFormatString procedure (ax:fmtout, buffer) 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
Copied string: Hello, World of 8086 Assembler!
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".