~ndiddy/a65

d1ae04997c3918518cedc68c63f2ce96505461e6 — Nathan Misner 1 year, 8 months ago 5a811de
fixed a bug with calculating line numbers for errors
6 files changed, 5 insertions(+), 273 deletions(-)

M a65.c
M a65.vcxproj
M a65eval.c
D test.asm
D test.lst
D test65.asm
M a65.c => a65.c +2 -2
@@ 103,14 103,14 @@ int main(int argc, char **argv) {
				fatal_error(ASMOPEN);
			}
			strcpy(filestk[0].filename, *argv);
			filestk[0].linenum = 1;
			filestk[0].linenum = 0;
		}
    }
    if (!filestk[0].fp) fatal_error(NOASM);

    while (++pass < 3) {
		fseek(source = filestk[0].fp,0L,0);  done = off = FALSE;
		filestk[0].linenum = 1;
		filestk[0].linenum = 0;
		errors = filesp = ifsp = pagelen = pc = 0;  title[0] = '\0';
		while (!done) {
			errcode = ' ';

M a65.vcxproj => a65.vcxproj +2 -0
@@ 90,6 90,7 @@
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <ConformanceMode>true</ConformanceMode>
      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>


@@ 118,6 119,7 @@
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <ConformanceMode>true</ConformanceMode>
      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>

M a65eval.c => a65eval.c +1 -0
@@ 453,6 453,7 @@ int newline() {
		if (filesp) {
			fclose(source);
			source = filestk[--filesp].fp;
			filestk[filesp].linenum++;
		}
		else return TRUE;
    }

D test.asm => test.asm +0 -19
@@ 1,19 0,0 @@
	titl	"sneed"

foo	equ	$5
bar	equ	$6
	
	org	$8000
string:
	db	"hello",0,1,2,3,-1,-2,-3
	db	"goodbye"
	dw	1,2,3,4,-1,-2,-3,-4
	jmp	string
	
start
	lda	#'a'
	sta	bar
	jmp	start
	

	end
\ No newline at end of file

D test.lst => test.lst +0 -29
@@ 1,29 0,0 @@
                        	titl	"sneed"
                        
   0005                 foo	equ	$5
   0006                 bar	equ	$6
                        	
   8000                 	org	$8000
   8000                 string:
   8000   68 65 6c 6c   	db	"hello",0,1,2,3,-1,-2,-3
   8004   6f 00 01 02   
   8008   03 ff fe fd   
   800c   67 6f 6f 64   	db	"goodbye"
   8010   62 79 65      
   8013   01 00 02 00   	dw	1,2,3,4,-1,-2,-3,-4
   8017   03 00 04 00   
   801b   ff ff fe ff   
   801f   fd ff fc ff   
   8023   4c 00 80      	jmp	string
                        	
   8026                 start
   8026   a9 61         	lda	#'a'
   8028   85 06         	sta	bar
   802a   4c 26 80      	jmp	start
                        	
                        
   802d                 	end
sneed

0006  bar           0005  foo           8026  start         8000  string    

\ No newline at end of file

D test65.asm => test65.asm +0 -223
@@ 1,223 0,0 @@
;
;		      Test File for 6502 Cross-Assembler
;
; This file just contains all of the 6502 CPU's opcodes in numerical order.
;
ABS	EQU	$1234
IMM	EQU	$56
IND	EQU	$0078
ZP	EQU	$0090

;
; $00 - $0F
;
	BRK
	ORA	(IND, X)
	ORA	ZP
	ASL	ZP
	PHP
	ORA	#IMM
	ASL	A
	ORA	ABS
	ASL	ABS
;
; $10 - $1F
;
	BPL	*
	ORA	(IND), Y
	ORA	ZP, X
	ASL	ZP, X
	CLC
	ORA	ABS, Y
	ORA	ABS, X
	ASL	ABS, X
;
; $20 - $2F
;
	JSR	ABS
	AND	(IND, X)
	BIT	ZP
	AND	ZP
	ROL	ZP
	PLP
	AND	#IMM
	ROL	A
	BIT	ABS
	AND	ABS
	ROL	ABS
;
; $30 - $3F
;
	BMI	*
	AND	(IND), Y
	AND	ZP, X
	ROL	ZP, X
	SEC
	AND	ABS, Y
	AND	ABS, X
	ROL	ABS, X
;
; $40 - $4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