gr-sim: add shift and rotate support

This commit is contained in:
Vince Weaver 2018-07-01 23:06:08 -04:00
parent 773e5d9148
commit 337f29a79b
2 changed files with 103 additions and 1 deletions

View File

@ -121,12 +121,109 @@ void lsr(void) {
temp_a=a;
temp_a&=0xff;
temp_a=temp_a>>1;
c=temp_a&0x1;
temp_a=temp_a>>1;
a=(temp_a&0xff);
z=(a==0);
n=!!(a&0x80);
// printf("LSR A=%x\n",a);
}
void asl(void) {
int temp_a;
temp_a=a;
temp_a&=0xff;
c=!!(temp_a&0x80);
temp_a=temp_a<<1;
a=(temp_a&0xff);
z=(a==0);
n=!!(a&0x80);
// printf("ASL A=%x\n",a);
}
void ror(void) {
int temp_a;
int old_c;
old_c=c;
temp_a=a;
temp_a&=0xff;
c=temp_a&0x1;
temp_a=temp_a>>1;
a=(temp_a&0xff);
a|=old_c<<7;
z=(a==0);
n=!!(a&0x80);
// printf("ROR A=%x\n",a);
}
void rol(void) {
int temp_a;
int old_c;
old_c=c;
temp_a=a;
temp_a&=0xff;
c=!!(temp_a&0x80);
temp_a=temp_a<<1;
a=(temp_a&0xff);
a|=old_c;
z=(a==0);
n=!!(a&0x80);
// printf("ROL A=%x\n",a);
}
void ror_mem(int addr) {
int temp_a;
int old_c;
old_c=c;
temp_a=ram[addr];
temp_a&=0xff;
c=temp_a&0x1;
temp_a=temp_a>>1;
ram[addr]=(temp_a&0xff);
ram[addr]|=old_c<<7;
z=(ram[addr]==0);
n=!!(ram[addr]&0x80);
// printf("ROR %x=%x\n",addr,ram[addr]);
}
void rol_mem(int addr) {
int temp_a;
int old_c;
old_c=c;
temp_a=ram[addr];
temp_a&=0xff;
c=!!(temp_a&0x80);
temp_a=temp_a<<1;
ram[addr]=(temp_a&0xff);
ram[addr]|=old_c;
z=(ram[addr]==0);
n=!!(ram[addr]&0x80);
// printf("ROL %x=%x\n",addr,ram[addr]);
}
unsigned char high(int value) {
return (value>>8)&0xff;
}

View File

@ -12,6 +12,11 @@ void cmp(int value);
void pha(void);
void pla(void);
void lsr(void);
void asl(void);
void ror(void);
void rol(void);
void ror_mem(int addr);
void rol_mem(int addr);
unsigned char high(int value);
unsigned char low(int value);