summaryrefslogtreecommitdiff
path: root/memory.c
blob: 75b041fa3a4bf17b4f0745dbfb6cdbc6b4634fb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
 *
 * This file is part of nios2sim-ng.
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License. See the file "COPYING" in the main directory of this archive
 * for more details.
 */

#include <stdio.h>
#include <stdlib.h>

#include "nios2sim-ng.h"
#include "nios2.h"
#include "memory.h"

uint8_t memory_get_byte(struct memory *mem, int32_t offset)
{
	uint8_t *base = (uint8_t *) mem->base;
	return base[offset];
}

void memory_dump(struct memory *mem, uint32_t offset, size_t count)
{
	size_t i;

	for (i = 0; i < count; i++) {
		if ((i + 1) % 4 == 1)
			info("%08x:  ", (unsigned int) (offset + i));
		info(" %08x", mem->base[offset / 4 + i]);
		if ((i + 1) % 4 == 0)
			info("\n");
	}
}