Logo Search packages:      
Sourcecode: cbmlink version File versions  Download package

static unsigned resolve_addr ( const char *  addr,
char **  endp 
) [static]

Resolve an address

Parameters:
addr a character string specifying the address
endp (output) pointer to the first non-number in addr
Returns:
the resolved address

Definition at line 111 of file cbmlink.c.

References B128, B256, hostinfo::host, P500, and save().

Referenced by drive_memory_load(), drive_memory_save(), load_file(), main(), and save_file().

{
  unsigned a;
  const char* s = addr;
  if (*s == '@') s++;
  a = strtoul (s, endp, 0);
  if (!*s || (endp && *endp && **endp && **endp != ',')) {
    fprintf (stderr, "malformed address: %s\n", addr);
    exit (1);
  }

  if (s != addr) {
    unsigned char buf[2];
    if (save (comm, 
            hostinfo->host == P500 ||
            hostinfo->host == B128 ||
            hostinfo->host == B256
            ? 0x0f
            : 0, a, a + 2, buf))
      exit (2);
    a = (unsigned) buf[0] | (unsigned) buf[1] << 8;
  }

  return a;
}


Generated by  Doxygen 1.6.0   Back to index