EarthBound/ASM/Memory And String Util Routines

From Data Crystal
< EarthBound
Revision as of 18:16, 30 May 2023 by Esorth (talk | contribs) (Start creating page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This is a sub-page of EarthBound/ASM.

$C08ED2-$C08EEC: 16-bit memcpy

memcpy(a, $0e..$10, x)

Copy memory similarly to the C memcpy function. Memory is copied in 16-bit words, ignoring the final byte if an odd length is requested. Implemented using trivial repeated LDA and STA calls.

Note: Unclear why EarthBound uses this routine instead of using the typically faster MVN or MVP CPU instructions.

Inputs

  • x: Num bytes to copy. Because routine only copies in 16-bit words, only copies x - 1 if x % 2 == 1
  • accumulator: Destination immediate pointer
  • $0e..$10: Source long pointer

$C08EED-$C08EFB: 8-bit memcpy

memcpy($0e..$10, $12..$15, a)

$C08EFC-$C08F14: 16-bit memset

memset(a, $0e, x)

$C08F15-$C08F21: 8-bit memset

memset($0e..$10, a, x)

$C08F22-$C08F2E: strlen

strlen($0e..$10)

$C08F2F-$C08F41: strcmp(ish)

strcmpish($0e..$10, $12..$14)

$C08F42-$C08F67: Copy CPU state to memory

$C08F68-$C08F8A: Load CPU state from memory

So very stubbly.
This page is rather stubbly and could use some expansion.
Are you a bad enough dude to rescue this article?