This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
notes:asm:cpumem [2011/02/17 02:15] – jr018429 | notes:asm:cpumem [2011/05/18 23:30] (current) – jr018429 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== CPUMEM ====== | ||
+ | class library is included before the main function like this:\\ | ||
+ | < | ||
+ | #include " | ||
+ | </ | ||
+ | \\ | ||
+ | CPUMEM:: | ||
+ | An object of the type CPUMEM is instatiated like this:\\ | ||
+ | \\ | ||
+ | < | ||
+ | // | ||
+ | CPUMEM cpumemory; | ||
+ | </ | ||
+ | \\ | ||
+ | CPUMEM:: | ||
+ | \\ | ||
+ | unsigned char& CPUMEM:: | ||
+ | \\ | ||
+ | unsigned char CPUMEM:: | ||
+ | The **read** member function is used like this:\\ | ||
+ | < | ||
+ | //reads 8-bit data from last memory address, 0xffff, or 65535 | ||
+ | unsigned char value = cpumemory.read(0xffff); | ||
+ | </ | ||
+ | \\ | ||
+ | void CPUMEM:: | ||
+ | The **write** member function is used like this:\\ | ||
+ | < | ||
+ | //writes the value 0xff, or 255, to the last memory address 0xffff, or 65535 | ||
+ | cpumemory.write(0xffff, | ||
+ | </ | ||
+ | \\ | ||
+ | **or.h**\\ | ||
+ | < | ||
+ | #ifndef _OR_H | ||
+ | #define _OR_H | ||
+ | class OR | ||
+ | { | ||
+ | public: | ||
+ | OR(); | ||
+ | void set(); | ||
+ | void set(bool); | ||
+ | void set(bool, bool); | ||
+ | bool get(); | ||
+ | |||
+ | private: | ||
+ | bool input1; | ||
+ | bool input2; | ||
+ | }; | ||
+ | #endif | ||
+ | </ | ||
+ | \\ | ||
+ | **ortest.cc**\\ | ||
+ | #include < | ||
+ | #include " | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | bool a, b; | ||
+ | a = true, b = false; | ||
+ | |||
+ | printf(" | ||
+ | printf(" | ||
+ | printf(" | ||
+ | printf(" | ||
+ | |||
+ | OR myOrGate; | ||
+ | |||
+ | printf(" | ||
+ | printf(" | ||
+ | |||
+ | for(int temp = 0; temp <=3; temp++) | ||
+ | { | ||
+ | a = temp & 0x02; | ||
+ | b = temp & 0x01; | ||
+ | //if(temp & 0x02) a = true; | ||
+ | //else a = false; | ||
+ | //if(temp & 0x01) b = true; | ||
+ | //else b = false; | ||
+ | //// | ||
+ | ////{ | ||
+ | //// case 0: | ||
+ | //// a = false; | ||
+ | //// b = false; | ||
+ | //// break; | ||
+ | //// case 1: | ||
+ | //// a = false; | ||
+ | //// b = true; | ||
+ | //// break; | ||
+ | //// case 2: | ||
+ | //// a = true; | ||
+ | //// b = false; | ||
+ | //// break; | ||
+ | //// case 3: | ||
+ | //// a = true; | ||
+ | //// b = true; | ||
+ | //// break; | ||
+ | ////} | ||
+ | myOrGate.set(a, | ||
+ | printf(" | ||
+ | } | ||
+ | printf(" | ||
+ | return(0); | ||
+ | } | ||
+ | </ | ||
+ | \\ | ||
+ | Makefile | ||
+ | < | ||
+ | CXX = g++ $(CXXFLAGS) $(INC) | ||
+ | CXXFLAGS = -Wall | ||
+ | INC = -I ../ | ||
+ | SRC = or.cc | ||
+ | OBJ = $(SRC: | ||
+ | all: $(SRC) $(OBJ) | ||
+ | debug: CXX += -DDEBUG -g | ||
+ | debug: DEBUG = debug | ||
+ | debug: $(SRC) $(OBJ) | ||
+ | |||
+ | .cc.o: | ||
+ | ifneq ($(MAKECMDGOALS), | ||
+ | @printf " | ||
+ | @$(CXX) -c $< && echo " | ||
+ | else | ||
+ | $(CXX) -c $< | ||
+ | endif | ||
+ | |||
+ | |||
+ | clean: | ||
+ | rm -f *.o $(OBJ) core | ||
+ | </ |