命令が1rxyの場合、レジスタ4に0x04の値を入れるにはどうすればよいですか?1RXY-レジスタRにメモリアドレスXYの値をロードします
#include <stdio.h>
unsigned char r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,ra,rb,rc,rd,re,rf;
void reg_check(unsigned char reg);
void rxy1(unsigned char reg, unsigned char val);
int main(){
unsigned char memloc1=0x14;
unisgned char memloc2=0x04;
unsigned char temp,reg,val_add;
temp=(x && 0xFF00) >> 8;
if (temp = 0xB){
reg=(memloc1 &0x0F);
val_add=memloc2;
rxy1(reg,val_add);
}
return 0;
}
void reg_check(unsigned char reg){
}
void rxy1(unsigned char reg, unsigned char val){
実際の命令は0x1404で、これはmemloc1とmemloc2の2バイトに分割されます。1rxyの形式によると、これは、レジスタrのメモリ位置xyに値を「配置する」ことを意味します。
したがって、ここでレジスタ4を使用unsigned char r4
するか、他の数値を保持するメモリ位置0x04の値を保持する必要があります。
私の質問は、1"4"04の"r"または1"r" xyを決定し、位置xyに保持されている値をunsigned char変数に配置することによって、レジスタ変数をテストする方法です。r4
たとえば、メモリの場所0x04
が保持されている場合0xFB
。
これが理にかなっていることを願っています。
[編集] 例
#include <stdio.h>
int main(){
unsigned char r0,r2,r3,r4;
unsigned char mem1=0x14; //at lmemory address 00
unsigned char mem2=0x04; //at lmemory address 01
unsigned char reg_val_store=mem1 & 0x0F;
if( ((mem1= & 0xF0) >> 4) == 0x1){
if (reg_val_store == 0x4){
//then put value store at memory address "04" into register 4.
//and just say for example "0xFD" was at memory location "04"
//since register value is 4 from the instruction read in 0x1"4"04
//i want to put 0xFD in the r4 unsigned char variable, how do i do this?
r4=0xFD; // this is of course correct but the instruction read in changes and
// so does the register variable. how do i modify my code for this change?
}
}
return 0;
}