1 /* memory support for Z8KSIM
2 Copyright (C) 1987, 1992 Free Software Foundation, Inc.
4 This file is part of Z8KSIM
6 Z8KSIM is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 Z8KSIM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Z8KZIM; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
38 return ((si & 0xff000000) >> 8) | (si & 0xffff);
43 get_page_and_offset (context, where, offset_ptr)
44 sim_state_type *context;
45 sim_phys_addr_type where;
48 /* Is the page allocated ? */
50 if (context->memory == 0)
52 /* Must allocate 16MB in order to run Z8001 programs. */
53 context->memory = (unsigned short *)calloc(64*1024*64,4);
56 *offset_ptr = sitoptr(where);
57 return context->memory;
61 sim_write_byte (context, where, what)
62 sim_state_type *context;
63 sim_phys_addr_type where;
67 char *ptr = (char *)get_page_and_offset (context, where, &offset);
73 sim_write_short (context, where, what)
74 sim_state_type *context;
75 sim_phys_addr_type where;
79 char *ptr = (char *)get_page_and_offset (context, where, &offset);
81 ptr[offset] = what >> 8;
82 ptr[offset + 1] = what;
86 sim_write_long (context, where, what)
87 sim_state_type *context;
88 sim_phys_addr_type where;
92 char *ptr = (char *)get_page_and_offset (context, where, &offset);
94 ptr[offset] = what >> 24;
95 ptr[offset + 1] = what >> 16;
96 ptr[offset + 3] = what >> 8;
97 ptr[offset + 4] = what;
101 sim_read_byte (context, where)
102 sim_state_type *context;
103 sim_phys_addr_type where;
106 char *ptr = (char *)get_page_and_offset (context, where, &offset);
112 sim_read_short (context, where)
113 sim_state_type *context;
114 sim_phys_addr_type where;
119 char *ptr = (char *)get_page_and_offset (context, where, &offset);
121 what = (ptr[offset] << 8) | ptr[offset + 1];