creating Xcode project and adjusting extern variables.

This commit is contained in:
Thiago Auler dos Santos 2017-11-16 00:28:59 -02:00
parent 6651b76f61
commit 680f44ed30
6 changed files with 364 additions and 68 deletions

View File

@ -0,0 +1,280 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 48;
objects = {
/* Begin PBXBuildFile section */
AFF1A1EE1FBD2A9C0069B921 /* 6502.c in Sources */ = {isa = PBXBuildFile; fileRef = AFF1A1E91FBD2A9B0069B921 /* 6502.c */; };
AFF1A1EF1FBD2A9C0069B921 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = AFF1A1EA1FBD2A9B0069B921 /* main.c */; };
AFF1A1F01FBD2A9C0069B921 /* memory.c in Sources */ = {isa = PBXBuildFile; fileRef = AFF1A1EB1FBD2A9C0069B921 /* memory.c */; };
AFF1A1F11FBD2A9C0069B921 /* opcodes.c in Sources */ = {isa = PBXBuildFile; fileRef = AFF1A1ED1FBD2A9C0069B921 /* opcodes.c */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
AFF1A1DD1FBD2A490069B921 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
AFF1A1DF1FBD2A490069B921 /* apple1 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = apple1; sourceTree = BUILT_PRODUCTS_DIR; };
AFF1A1E91FBD2A9B0069B921 /* 6502.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = 6502.c; path = src/6502.c; sourceTree = "<group>"; };
AFF1A1EA1FBD2A9B0069B921 /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = main.c; path = src/main.c; sourceTree = "<group>"; };
AFF1A1EB1FBD2A9C0069B921 /* memory.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = memory.c; path = src/memory.c; sourceTree = "<group>"; };
AFF1A1EC1FBD2A9C0069B921 /* inc */ = {isa = PBXFileReference; lastKnownFileType = folder; name = inc; path = src/inc; sourceTree = "<group>"; };
AFF1A1ED1FBD2A9C0069B921 /* opcodes.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = opcodes.c; path = src/opcodes.c; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
AFF1A1DC1FBD2A490069B921 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
AFF1A1D61FBD2A490069B921 = {
isa = PBXGroup;
children = (
AFF1A1E91FBD2A9B0069B921 /* 6502.c */,
AFF1A1EC1FBD2A9C0069B921 /* inc */,
AFF1A1EA1FBD2A9B0069B921 /* main.c */,
AFF1A1EB1FBD2A9C0069B921 /* memory.c */,
AFF1A1ED1FBD2A9C0069B921 /* opcodes.c */,
AFF1A1E01FBD2A490069B921 /* Products */,
);
sourceTree = "<group>";
};
AFF1A1E01FBD2A490069B921 /* Products */ = {
isa = PBXGroup;
children = (
AFF1A1DF1FBD2A490069B921 /* apple1 */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
AFF1A1DE1FBD2A490069B921 /* apple1 */ = {
isa = PBXNativeTarget;
buildConfigurationList = AFF1A1E61FBD2A490069B921 /* Build configuration list for PBXNativeTarget "apple1" */;
buildPhases = (
AFF1A1DB1FBD2A490069B921 /* Sources */,
AFF1A1DC1FBD2A490069B921 /* Frameworks */,
AFF1A1DD1FBD2A490069B921 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = apple1;
productName = apple1;
productReference = AFF1A1DF1FBD2A490069B921 /* apple1 */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
AFF1A1D71FBD2A490069B921 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0910;
ORGANIZATIONNAME = "Thiago Auler dos Santos";
TargetAttributes = {
AFF1A1DE1FBD2A490069B921 = {
CreatedOnToolsVersion = 9.1;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = AFF1A1DA1FBD2A490069B921 /* Build configuration list for PBXProject "apple1" */;
compatibilityVersion = "Xcode 8.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = AFF1A1D61FBD2A490069B921;
productRefGroup = AFF1A1E01FBD2A490069B921 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
AFF1A1DE1FBD2A490069B921 /* apple1 */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
AFF1A1DB1FBD2A490069B921 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
AFF1A1EE1FBD2A9C0069B921 /* 6502.c in Sources */,
AFF1A1F11FBD2A9C0069B921 /* opcodes.c in Sources */,
AFF1A1F01FBD2A9C0069B921 /* memory.c in Sources */,
AFF1A1EF1FBD2A9C0069B921 /* main.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
AFF1A1E41FBD2A490069B921 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
AFF1A1E51FBD2A490069B921 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
};
name = Release;
};
AFF1A1E71FBD2A490069B921 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = MKA3BYM4R9;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
AFF1A1E81FBD2A490069B921 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = MKA3BYM4R9;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
AFF1A1DA1FBD2A490069B921 /* Build configuration list for PBXProject "apple1" */ = {
isa = XCConfigurationList;
buildConfigurations = (
AFF1A1E41FBD2A490069B921 /* Debug */,
AFF1A1E51FBD2A490069B921 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
AFF1A1E61FBD2A490069B921 /* Build configuration list for PBXNativeTarget "apple1" */ = {
isa = XCConfigurationList;
buildConfigurations = (
AFF1A1E71FBD2A490069B921 /* Debug */,
AFF1A1E81FBD2A490069B921 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = AFF1A1D71FBD2A490069B921 /* Project object */;
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:apple1.xcodeproj">
</FileRef>
</Workspace>

View File

@ -1,7 +1,7 @@
#ifndef _APPLE_I_6502_H_ #ifndef _APPLE_I_6502_H_
#define _APPLE_I_6502_H_ #define _APPLE_I_6502_H_
void init(); void init(void);
void run(); void run(void);
#endif #endif

View File

@ -2,7 +2,6 @@
#define _APPLE_I_MEMORY_H_ #define _APPLE_I_MEMORY_H_
#include "types.h" #include "types.h"
db read_byte(dw address); db read_byte(dw address);
dw read_word(dw address); dw read_word(dw address);
void write_mem(dw address, db data); void write_mem(dw address, db data);

View File

@ -3,13 +3,13 @@
#include "types.h" #include "types.h"
dw pc; // program counter extern dw pc; // program counter
db ac; // accumulator extern db ac; // accumulator
db x; // x register extern db x; // x register
db y; // y register extern db y; // y register
db sp; // stack pointer extern db sp; // stack pointer
db sr; // status register extern db sr; // status register
db ir; // instruction register extern db ir; // instruction register
enum opcodes_table enum opcodes_table
{ /// aaa00 aaa01 aaa10 { /// aaa00 aaa01 aaa10
@ -51,65 +51,65 @@ typedef enum opcodes_table oct;
typedef enum opcodes_list ocl; typedef enum opcodes_list ocl;
typedef enum address_mode am; typedef enum address_mode am;
am address_mode; extern am address_mode;
void adc(); // add memory to accumulator with carry void adc(void); // add memory to accumulator with carry
void and(); // and memory with accumulator void and(void); // and memory with accumulator
void asl(); // shift left one bit (memory or accumulator) void asl(void); // shift left one bit (memory or accumulator)
void bcc(); // branch on carry clear void bcc(void); // branch on carry clear
void bcs(); // branch on carry set void bcs(void); // branch on carry set
void beq(); // branch on result zero void beq(void); // branch on result zero
void bit(); // test bits in memory with accumulator void bit(void); // test bits in memory with accumulator
void bmi(); // branch on result minus void bmi(void); // branch on result minus
void bne(); // branch on result not zero void bne(void); // branch on result not zero
void bpl(); // branch on result plus void bpl(void); // branch on result plus
void brk(); // force break void brk(void); // force break
void bvc(); // branch on overflow clear void bvc(void); // branch on overflow clear
void bvs(); // branch on overflow set void bvs(void); // branch on overflow set
void clc(); // clear carry flag void clc(void); // clear carry flag
void cld(); // clear decimal mode void cld(void); // clear decimal mode
void cli(); // clear interrupt disable bit void cli(void); // clear interrupt disable bit
void clv(); // clear overflow flag void clv(void); // clear overflow flag
void cmp(); // compare memory with accumulator void cmp(void); // compare memory with accumulator
void cpx(); // compare memory and index x void cpx(void); // compare memory and index x
void cpy(); // compare memory and index y void cpy(void); // compare memory and index y
void dec(); // decrement memory by one void dec(void); // decrement memory by one
void dex(); // decrement index x by one void dex(void); // decrement index x by one
void dey(); // decrement index y by one void dey(void); // decrement index y by one
void eor(); // exclusive-or memory with accumulator void eor(void); // exclusive-or memory with accumulator
void inc(); // increment memory by one void inc(void); // increment memory by one
void inx(); // increment index x by one void inx(void); // increment index x by one
void iny(); // increment index y by one void iny(void); // increment index y by one
void jmp(); // jump to new location (indirect) void jmp(void); // jump to new location (indirect)
void jpa(); // jump to new location (absolute) void jpa(void); // jump to new location (absolute)
void jsr(); // jump to new location saving return address void jsr(void); // jump to new location saving return address
void lda(); // load accumulator with memory void lda(void); // load accumulator with memory
void ldx(); // load index x with memory void ldx(void); // load index x with memory
void ldy(); // load index y with memory void ldy(void); // load index y with memory
void lsr(); // shift one bit right (memory or accumulator) void lsr(void); // shift one bit right (memory or accumulator)
void nop(); // no operation void nop(void); // no operation
void ora(); // or memory with accumulator void ora(void); // or memory with accumulator
void pha(); // push accumulator on stack void pha(void); // push accumulator on stack
void php(); // push processor status on stack void php(void); // push processor status on stack
void pla(); // pull accumulator from stack void pla(void); // pull accumulator from stack
void plp(); // pull processor status from stack void plp(void); // pull processor status from stack
void rol(); // rotate on bit left (memory or accumulator) void rol(void); // rotate on bit left (memory or accumulator)
void ror(); // rotate on bit right (memory or accumulator) void ror(void); // rotate on bit right (memory or accumulator)
void rti(); // return from interrupt void rti(void); // return from interrupt
void rts(); // return from subroutine void rts(void); // return from subroutine
void sbc(); // subtract memory from accumulator with borrow void sbc(void); // subtract memory from accumulator with borrow
void sec(); // set carry flag void sec(void); // set carry flag
void sed(); // set decimal flag void sed(void); // set decimal flag
void sei(); // set interrupt disable status void sei(void); // set interrupt disable status
void sta(); // store accumulator in memory void sta(void); // store accumulator in memory
void stx(); // store index x in memory void stx(void); // store index x in memory
void sty(); // store index y in memory void sty(void); // store index y in memory
void tax(); // transfer accumulator to index x void tax(void); // transfer accumulator to index x
void tay(); // transfer accumulator to index y void tay(void); // transfer accumulator to index y
void tsx(); // transfer stack pointer to index x void tsx(void); // transfer stack pointer to index x
void txa(); // transfer index x to accumulator void txa(void); // transfer index x to accumulator
void txs(); // transfer index x to stack pointer void txs(void); // transfer index x to stack pointer
void tya(); // transfer index y to accumulator void tya(void); // transfer index y to accumulator
#define N_IS_SET (sr & 0b10000000) // negative #define N_IS_SET (sr & 0b10000000) // negative
#define N_SET sr = sr | 0b10000000 #define N_SET sr = sr | 0b10000000

View File

@ -1,6 +1,16 @@
#include "inc/opcodes.h" #include "inc/opcodes.h"
#include "inc/memory.h" #include "inc/memory.h"
dw pc; // program counter
db ac; // accumulator
db x; // x register
db y; // y register
db sp; // stack pointer
db sr; // status register
db ir; // instruction register
am address_mode;
dw address; dw address;
db operand; db operand;