00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "hwsreg.h"
00027 #include "global.h"
00028
00029 #include <iostream>
00030 using namespace std;
00031
00032 HWSreg_bool::operator int() {
00033 return C + (Z << 1) + (N << 2) + (V << 3) + (S << 4) + (H << 5) + (T << 6) + (I << 7);
00034 }
00035
00036 HWSreg_bool::HWSreg_bool(const int i) {
00037 C = i &0x01;
00038 Z = (i & 0x02) > 1;
00039 N = (i & 0x04) > 2;
00040 V = (i & 0x08) > 3;
00041 S = (i & 0x10) > 4;
00042 H = (i & 0x20) > 5;
00043 T = (i & 0x40) > 6;
00044 I = (i & 0x80) > 7;
00045 }
00046
00047 HWSreg_bool::HWSreg_bool() {
00048 C = Z = N = V = S = H = T = I = 0;
00049 }
00050
00051 HWSreg::operator string() {
00052 string s("SREG=[");
00053 if(I) s += "I"; else s += "-";
00054 if(T) s += "T"; else s += "-";
00055 if(H) s += "H"; else s += "-";
00056 if(S) s += "S"; else s += "-";
00057 if(V) s += "V"; else s += "-";
00058 if(N) s += "N"; else s += "-";
00059 if(Z) s += "Z"; else s += "-";
00060 if(C) s += "C"; else s += "-";
00061 s += "] ";
00062 return s;
00063 }
00064
00065 HWSreg HWSreg::operator =(const int i) {
00066 C = i & 0x01;
00067 Z = (i & 0x02) > 1;
00068 N = (i & 0x04) > 2;
00069 V = (i & 0x08) > 3;
00070 S = (i & 0x10) > 4;
00071 H = (i & 0x20) > 5;
00072 T = (i & 0x40) > 6;
00073 I = (i & 0x80) > 7;
00074 return *this;
00075 }
00076
00077 unsigned char RWSreg::get() const {
00078 return (*status);
00079 }
00080
00081 void RWSreg::set(unsigned char val) {
00082 *status = val;
00083 }
00084
00085