Skip to content
Joachim Stolberg edited this page Jan 4, 2023 · 11 revisions

memcpy

The function copies n words from memory area src to memory area dest.

memcpy(dest, src, n)
  • dest Pointer/address to the destination, where the data is to be copied.
  • src Pointer/address to the source of data to be copied.
  • n The number of words to be copied.

Example:

import "sys/stdio.asm"
import "sys/mem.asm"

var src = "Hello world!";
var dest[8];

foo() {
  memcpy(dest, src, 7);  // the complete string fits into 7 words of memory
  putstr(dest);
  return;
}

memset

Fill block of memory

memset(ptr, value, num)
  • ptr Pointer to the block of memory to fill.
  • val Value to be set.
  • num Number of words to be set to the value.