====== CPUMEM ======
class library is included before the main function like this:\\
#include "cpumem.h"
\\
CPUMEM::CPUMEM() is the constructor and automatically creates memory of the correct size, 64k (65536 elements, 0-65535), and type 1 byte (8-bits) for the 8085. The constructor is called automatically as the object is being instantiated.\\
An object of the type CPUMEM is instatiated like this:\\
\\
//Instantiates an object of type CPUMEM
CPUMEM cpumemory;
\\
CPUMEM::~CPUMEM() is the destructor and automatically deallocates the memory which was created when an object of type CPUMEM when an object of this type goes out of scope.\\
\\
unsigned char& CPUMEM::operator[](unsigned short int address) is a depricated member function. It uses overloaded operators to make the code that calls this method look like an array. **Do NOT use it.**\\
\\
unsigned char CPUMEM::read(unsigned short int address) is the member function that is used to read the 8-bit (unsigned char) value at a specific address.\\
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::write(unsigned short int address, unsigned char value) is the member function that is used to write an 8-bit value to a specific address.\\
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, 0xff);
\\
**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 "or.h"
int main()
{
bool a, b;
a = true, b = false;
printf("--------------------\n");
printf("TRUE is: %d\n", true);
printf("FALSE is: %d\n", false);
printf("--------------------\n\n");
OR myOrGate;
printf(" a b | x \n");
printf("-----+---\n");
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;
////switch(temp)
////{
//// 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, b);
printf(" %d %d | %d\n", a, b, myOrGate.get());
}
printf("---------\n");
return(0);
}
\\
Makefile
CXX = g++ $(CXXFLAGS) $(INC)
CXXFLAGS = -Wall
INC = -I ../../include/
SRC = or.cc
OBJ = $(SRC:.cc=.o)
all: $(SRC) $(OBJ)
debug: CXX += -DDEBUG -g
debug: DEBUG = debug
debug: $(SRC) $(OBJ)
.cc.o:
ifneq ($(MAKECMDGOALS),debug)
@printf "[B] %-20s ... " "$<"
@$(CXX) -c $< && echo "OK" || echo "FAIL"
else
$(CXX) -c $<
endif
clean:
rm -f *.o $(OBJ) core