对ics2020框架中寄存器结构体的修改

做PA做到后面经常会有寄存器值出错的问题,无法排除个例,大多数情况下这种错都和之前实现的寄存器结构体有关,以下是我目前正确的寄存器结构体实现方法:

/* TODO: Re-organize the `CPU_state' structure to match the register * encoding scheme in i386 instruction format. For example, if we * access cpu.gpr[3]._16, we will get the `bx' register; if we access * cpu.gpr[1]._8[1], we will get the 'ch' register. Hint: Use `union'. * For more details about the register encoding scheme, see i386 manual. */
typedef struct {
	 union {      
	  	struct{          
	  		rtlreg_t eax;          
	  		rtlreg_t ecx;          
	  		rtlreg_t edx;          
	  		rtlreg_t ebx;          
	  		rtlreg_t esp;          
	  		rtlreg_t ebp;          
	  		rtlreg_t esi;          
	  		rtlreg_t edi;      
	  		};      
	  	union {          
	  		uint32_t _32;          
	  		uint16_t _16;          
	  		uint8_t _8[2];      
	  		}gpr[8];  };  
	  	vaddr_t eip;  
	  	union{      
	  		struct {            
	  			uint32_t CF:1;           
	  			unsigned : 5;           
	  			uint32_t ZF:1;           
	  			uint32_t SF:1;            
	  			unsigned : 1;           
	  			uint32_t IF:1;            
	  			unsigned : 1;            
	  			uint32_t OF:1;           
	  			unsigned : 20;      
	  			};      
	  		rtlreg_t value; 
	  		}eflags;                     
/* Do NOT change the order of the GPRs' definitions. */
 /* In NEMU, rtlreg_t is exactly uint32_t. This makes RTL instructions   * in PA2 able to directly access these registers.   */  /*rtlreg_t eax, ecx, edx, ebx, esp, ebp, esi, edi;*/
 /* vaddr_t eip;*/
} CPU_state;
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值