-
Notifications
You must be signed in to change notification settings - Fork 22
/
i8080_hal.c
71 lines (61 loc) · 1.98 KB
/
i8080_hal.c
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Intel 8080 (KR580VM80A) microprocessor core model
//
// Copyright (C) 2012 Alexander Demin <[email protected]>
//
// Credits
//
// Viacheslav Slavinsky, Vector-06C FPGA Replica
// http://code.google.com/p/vector06cc/
//
// Dmitry Tselikov, Bashrikia-2M and Radio-86RK on Altera DE1
// http://bashkiria-2m.narod.ru/fpga.html
//
// Ian Bartholomew, 8080/8085 CPU Exerciser
// http://www.idb.me.uk/sunhillow/8080.html
//
// Frank Cringle, The origianal exerciser for the Z80.
//
// Thanks to zx.pk.ru and nedopc.org/forum communities.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "i8080_hal.h"
unsigned char memory[0x10000];
int i8080_hal_memory_read_word(int addr) {
return
(i8080_hal_memory_read_byte(addr + 1) << 8) |
i8080_hal_memory_read_byte(addr);
}
void i8080_hal_memory_write_word(int addr, int word) {
i8080_hal_memory_write_byte(addr, word & 0xff);
i8080_hal_memory_write_byte(addr + 1, (word >> 8) & 0xff);
}
int i8080_hal_memory_read_byte(int addr) {
return memory[addr & 0xffff];
}
void i8080_hal_memory_write_byte(int addr, int byte) {
memory[addr & 0xffff] = byte;
}
int i8080_hal_io_input(int port) {
return 0;
}
void i8080_hal_io_output(int port, int value) {
// Nothing.
}
void i8080_hal_iff(int on) {
// Northing.
}
unsigned char* i8080_hal_memory(void) {
return &memory[0];
}