⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mem.c

📁 这个是LINUX下的GDB调度工具的源码
💻 C
字号:
/* memory support for Z8KSIM   Copyright (C) 1987, 1992 Free Software Foundation, Inc.This file is part of Z8KSIMZ8KSIM is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.Z8KSIM is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with Z8KZIM; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */#include "config.h"#include <ansidecl.h>#ifdef HAVE_STDLIB_H#include <stdlib.h>#endif#include "tm.h"#include "mem.h"#include "sim.h"#define INLINEstatic longsitoptr (si)long si;{  return ((si & 0xff000000) >> 8) | (si & 0xffff);}staticunsigned short *get_page_and_offset (context, where, offset_ptr)     sim_state_type *context;     sim_phys_addr_type where;     int *offset_ptr;{  /* Is the page allocated ? */  if (context->memory == 0)    {      /* Must allocate 16MB in order to run Z8001 programs.  */      context->memory  = (unsigned short *)calloc(64*1024*64,4);    }  *offset_ptr = sitoptr(where);  return context->memory;}voidsim_write_byte (context, where, what)     sim_state_type *context;     sim_phys_addr_type where;     int what;{  unsigned int offset;  char *ptr = (char *)get_page_and_offset (context, where, &offset);  ptr[offset] = what;}voidsim_write_short (context, where, what)     sim_state_type *context;     sim_phys_addr_type where;     int what;{  int offset;  char *ptr = (char *)get_page_and_offset (context, where, &offset);  ptr[offset] = what >> 8;  ptr[offset + 1] = what;}voidsim_write_long (context, where, what)     sim_state_type *context;     sim_phys_addr_type where;     int what;{  int offset;  char *ptr = (char *)get_page_and_offset (context, where, &offset);  ptr[offset] = what >> 24;  ptr[offset + 1] = what >> 16;  ptr[offset + 3] = what >> 8;  ptr[offset + 4] = what;}intsim_read_byte (context, where)     sim_state_type *context;     sim_phys_addr_type where;{  int offset;  char *ptr = (char *)get_page_and_offset (context, where, &offset); return ptr[offset];}unsignedsim_read_short (context, where)     sim_state_type *context;     sim_phys_addr_type where;{  int what;  int offset;  char *ptr = (char *)get_page_and_offset (context, where, &offset);  what = (ptr[offset] << 8) | ptr[offset + 1];  return what;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -