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

📄 os_iacxl10_2004_3_16.cpp

📁 自己编写的ARM处理器的指令集仿真
💻 CPP
字号:
#include "armia_IAcxl10_2004_3_16.h"#include <iostream.h>#include <string.h>#include <fcntl.h>#include <errno.h>    UNL ARMISS_stru::Read_Word(UNL addr){       return *( (UNL*)memptr.memptr + addr/4 );}UNL ARMISS_stru::Read_Byte(UNL addr){       UNL temp;       temp = Read_Word(addr);       temp = temp >> ( ( addr % 4 ) * 8 ) ;       temp = temp & 0xff;       return temp;}void ARMISS_stru::Write_Word(UNL addr,UNL data){              *( (UNL*)memptr.memptr + addr/4 ) = data;}void ARMISS_stru::Write_Byte(UNL addr,UNL data){               memptr.memptr[addr] =(char) data;        }void ARMISS_stru::SWIWrite(UNL f, UNL ptr, UNL len){       int   i,res;       char* local = new char[len];               for( i = 0; i < len; i++ )          local[i] = Read_Byte( ptr + i );          res      = write(f, local, len);       delete local;       r_gen[0] = res == -1 ? -1 : len - res;              //cout<<"done swiwrite"<<endl;}void ARMISS_stru::SWIOpen (UNL name, UNL flags){  char dummy[2000];  int i;  for (i = 0; (dummy[i] = Read_Byte ( name + i)); i++)    ;      /* Filename ":tt" is special: it denotes stdin/out */  if (strcmp (dummy, ":tt") == 0)    {      if (flags == 0)	/* opening tty "r" */	  r_gen[0] = 0;	/* stdin */      else	  r_gen[0] = 1;	/* stdout */    }  else    {      r_gen[0] = (int) open (dummy, flags, 0666);     }}       void ARMISS_stru::SWIRead(UNL f, UNL ptr, UNL len){     int    res;     int    i;     char*  local= new char[len];     res = read(f,local,len);     if( res > 0 )     for(i=0 ; i<res;i++)       Write_Byte( ptr+i,local[i]);     delete local;           r_gen[0] = (res == -1)? -1: len - res;         }    void ARMISS_stru::WriteCommandLineTo( UNL addr ){    UNL   temp;    char* cptr = commandline;         printf("in writecommandlineto(),cptr=%s,addr=0x%x\n",cptr,addr);    if( cptr == 0 )         cptr = "\0";    temp = (UNL) (*cptr);         while( temp != 0 )     {          //if( addr == 0x182e0 ) cout<<(char)temp<<endl;       //printf("temp=%c\n",temp);          Write_Byte( addr++,temp);          cptr++;          temp = UNL(*cptr);     }          Write_Byte( addr,temp);         }    

⌨️ 快捷键说明

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