65816 Assembler for Windows

Programming the 6502 microprocessor and its relatives in assembly and other languages.
bound
Posts: 59
Joined: 24 May 2004

65816 Assembler for Windows

Post by bound »

Hi

My 65816 assembler can be downloaded from
--- link deleted ---

Can someone please test it for me .

cheers




supported mnemonics :

BRK,CLC,CLD,CLI,CLV,DEX,DEY,INX,
PHY,PLA,PLB,PLD,PLP,PLX,PLY,RTI,
RTL,RTS,SEC,SED,SEI,STP,SWA,TAD,
TAS,TAX,TAY,TCD,TCS,TDA,TDC,TSA,
INY,NOP,PHA,PHB,PHD,PHK,PHP,PHX,
TSC,TSX,TXA,TXS,TXY,TYA,TYX,WAI,
XBA,XCE,ADC,AND,CMP,EOR,LDA,ORA,
SBC,STA,STX,STY,ASL,LSR,ROL,ROR,
DEC,INC,CPX,CPY,LDX,LDY,JMP,JML,
JSR,JSL,BIT,BCC,BCS,BEQ,BMI,BNE,
BPL,BRA,BVC,BVS,BRL,MVN,MVP,PEA,
PEI,PER,REP,SEP,STZ,TRB,TSB

supported commands

ORG , *= , BIN, EQU ,DCB , DCW , DSB, DSW, DB, DW
.ascii , .byte , .word , .incbin

.incbin or bin command will allow you to load extrnal binary file to your project . max size is set to 32k
Last edited by bound on Sun May 15, 2011 9:55 am, edited 4 times in total.
User avatar
BigDumbDinosaur
Posts: 9426
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: 65816 Assembler for Windows

Post by BigDumbDinosaur »

bound wrote:
My 65816 assembler can be downloaded...
Is there any documentation for it? Kind of hard to test if one doesn't know what it expects.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
BigDumbDinosaur
Posts: 9426
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: 65816 Assembler for Windows

Post by BigDumbDinosaur »

bound wrote:
My 65816 assembler can be downloaded...
Right out of the gate there's a strange problem:

Code: Select all

;test relative branching
;
baseaddr =$1ff2                ;base address
targ     =baseaddr+$07         ;branch target
;
addra    =$00                  ;base address
addrb    =$08                  ;target address
addrc    =$10                  ;computed target address
offset   =$18                  ;branch offset
;
         *=$2000
;
         ldx #<baseaddr
         ldy #>baseaddr
         stx addra             ;branch instruction +2
         sty addra+1
         ldx #<targ
         ldy #>targ
         stx addrb             ;branch target
         sty addrb+1
;
;================================================================================
;
;COMPUTE SHORT BRANCH OFFSET                   
;
addrboff sec
         lda addrb             ;target address LSB
         sbc addra             ;opcode address +2 LSB
         sta offset            ;offset LSB
         lda addrb+1           ;target address MSB
         sbc addra+1           ;opcode address +2 MSB
         sta offset+1          ;offset MSB
         bcs .0000100          ;forward branch
;
;
;	process backward branch...
;
         bpl .0000020          ;out of range
;        
.0000010 eor #@11111111        ;offset MSB 2's compliment
         bne .0000020          ;backward branch out of range
;
         bit offset
         bmi .0000030          ;in range
;
.0000020 sec
         brk
;
.0000030 clc
         brk
;
;
;	process forward branch...
;
.0000100 bne .0000020          ;out of range
;
         bit offset
         bmi .0000020          ;out of range
;
;
;	recompute target...
;
         ldx #<baseaddr
         ldy #>baseaddr
         stx addra
         sty addra+1
;
         lda addra             ;base address LSB
         ldy addra+1           ;base address MSB
         bit offset            ;branch offset
         bpl .0000040          ;forward branch
;
         dey                   ;backward branch
;
.0000040 clc
         adc offset            ;calculate target address LSB
         sta addrc             ;address LSB
         tya                   ;adjusted base address MSB
         adc #0                ;calculate target address MSB
         sta addrc+1           ;address MSB
         brk
The assembler thinks the BRK opcode is a label, as you will see when you try to assemble the above. Also, it took me a bit to figure out how to assemble (not compile) the code. :) Where's the assembly listing, symbol table output and executable file?
x86?  We ain't got no x86.  We don't NEED no stinking x86!
bound
Posts: 59
Joined: 24 May 2004

Post by bound »

Hi .

well , I'm still working on this assembler so is not finish yet .
All it should do is to ASSEMBLE :) the code to binary file .
In did brk is taken as a label , i will fix it tomorrow . Thanks for your time !

Greetings
bound
Posts: 59
Joined: 24 May 2004

Post by bound »

good morning .

I have fix the problem with BRK instruction. So please do some more tests for me .

After assemble (without errors ) the binary file will be created in source directory.

fixed version :
--- link deleted ---

Thanks allot for your help.

ps 1: this assembler is in very early state so please be patient .

ps 2:assembly listing, symbol table ( if you mean labels list , then is available under view ) will be added but first of all I need to test the "assembly engine"

ps 3: hire is some example code .

Code: Select all

	nop
	nop
	rep	#$30
 org $1000

StartAddress
Label

	adc	($11,x)						; $79	(indirect,x)
	adc	$12,s						; $63	Stack relatve
	adc	$12							; $65	zeropage/DirectPage
	adc     [$33]						; $67	Direct Page LONG			65816
	adc	#$20				                ; $69	immediate
	adc	$1234		 				; $6d	absolute
	adc	$123456	 				; $6d	absolute LONG
	adc	($22),y						; $71	(indirect),y
	adc	($22)						; $72	(indirect)					65c02, 65816
	adc	($22,s),y					; $73	SR Indirect Index Y			65816
	adc	$33,x						; $75	zeropage,x
	adc [$33],y						; $77	Direct Page LONG indexed Y
	adc	$1234,y						; $61	absolute,y
	adc	$1234,x						; $7d	absolute,x
	adc	$123456,x					; $7f	absolute,x


	and	($11,x)						; $21	(indirect,x)
	and	$12,s						; $23	Stack relatve				65816
	and	$12							; $25	zeropage/DirectPage
	and [$33]						; $27	Direct Page LONG			65816
	and	#$55						; $29	immediate
	and	$1234		 				; $2d	absolute
	and	$123456	 				; $2f	absolute LONG				65816
	and	($22),y						; $31	(indirect),y
	and	($22)						; $32	(indirect)					65c02, 65816
	and	($22,s),y					; $33	SR Indirect Index Y			65816
	and	$33,x						; $35	zeropage,x
	and [$33],y						; $37	Direct Page LONG indexed Y	65816
	and	$1234,y						; $39	absolute,y
	and	$1234,x						; $3d	absolute,x
	and	$123456,x					; $3f	absolute,x					65816


	asl								; $0a	accumulator
	asl	$1234						; $0e	absolute
	asl	$00							; $06	zeropage
	asl	$1234,x						; $1e	absolute,x
	asl	$00,x						; $35	zeropage,x
dan1
	bcc	dan1							; $90	Relative
	bcs	dan2							; $b0	Relative
dan2	beq	dan1							; $f0	Relative

	bit	$1234						; $2c	absolute
	bit	$00							; $24	zeropage

	bmi	dan1							; $30	Relative
	bne	dan1							; $d0	Relative;
	bpl	dan1 						; $10	Relative

	brk								; $00	implied

	bvc	dan1 						; $50	Relative
	bvs dan1 						; $70	Relative

	clc								; $18	implied
	cld								; $d8	implied
	cli								; $58	implied
	clv								; $b8	implied

	cmp	$1234						; $cd	absolute
	cmp	$00							; $c5	zeropage
	cmp	#$00						; $c9	immediate
	cmp	$1234,x						; $d0	absolute,x
	cmp	$1234,y						; $d9	absolute,y
	cmp	($00,x)						; $c1	(indirect,x)
	cmp	($00),y						; $d1	(indirect),y
	cmp	$00,x						; $d5	zeropage,x

	cpx	$1234						; $ec	absolute
	cpx	$00							; $e4	zeropage
	cpx	#$00						; $e0	immediate

	cpy	$1234						; $cc	absolute
	cpy	$00							; $c4	zeropage
	cpy	#$00						; $c0	immediate

	dec	$1234						; $ce	absolute
	dec	$00							; $c6	zeropage
	dec	$1234,x						; $de	absolute,x
	dec	$00,x						; $d6	zeropage,x

	dex								; $ca	implied
	dey								; $88	implied

	eor	$1234						; $4d	absolute
	eor	$00							; $45	zeropage
	eor	#$00						; $49	immediate
	eor	$1234,x						; $5d	absolute,x
	eor	$1234,y						; $59	absolute,y
	eor	($00,x)						; $41	(indirect,x)
	eor	($00),y						; $51	(indirect),y
	eor	$00,x						; $55	zeropage,x

	inc	$1234						; $ee	absolute
	inc	$00							; $e6	zeropage
	inc	$1234,x						; $fe	absolute,x
	inc	$00,x						; $f6	zeropage,x

	inx								; $e8	implied
	iny								; $c8	implied

	jmp	$1234						; $4c	absolute
	jmp	($34)						; $6c	(indirect)

	jsr	$1234						; $20	absolute

	lda	$1234						; $ad	absolute
	lda	$00							; $a5	zeropage
	lda	#$00						; $a9	immediate
	lda	$1234,x						; $bd	absolute,x
	lda	$1234,y						; $b9	absolute,y
	lda	($00,x)						; $a1	(indirect,x)
	lda	($00),y						; $b1	(indirect),y
	lda	$00,x						; $b5	zeropage,x

	ldx	$1234						; $ae	absolute
	ldx	$00							; $a6	zeropage
	ldx	#$00						; $a2	immediate
	ldx	$1234,y						; $be	absolute,y
	ldx	$00,y						; $b6	zeropage,y

	ldy	$1234						; $ac	absolute
	ldy	$00							; $a4	zeropage
	ldy	#$00						; $a0	immediate
	ldy	$1234,x						; $bc	absolute,x
	ldy	$00,x						; $b4	zeropage,x

	lsr								; $4a	accumulator
	lsr	$1234						; $4e	absolute
	lsr	$00							; $46	zeropage
	lsr	$1234,x						; $5e	absolute,x
	lsr	$00,x						; $56	zeropage,x

	nop								; $ea	implied

	ora	$1234						; $0d	absolute
	ora	$00							; $05	zeropage
	ora	#$00						; $09	immediate
	ora	$1234,x						; $1d	absolute,x
	ora	$1234,y						; $19	absolute,y
	ora	($00,x)						; $01	(indirect,x)
	ora	($00),y						; $11	(indirect),y
	ora	$00,x						; $15	zeropage,x

	pha								; $48	implied
	php								; $08	implied
	pla								; $68	implied
	plp								; $28	implied

	rol							; $2a	accumulator
	rol	$1234						; $2e	absolute
	rol	$00							; $26	zeropage
	rol	$1234,x						; $3e	absolute,x
	rol	$00,x						; $36	zeropage,x

	ror 							; $6a	accumulator
	ror	$1234						; $6e	absolute
	ror	$00							; $66	zeropage
	ror	$1234,x						; $7e	absolute,x
	ror	$00,x						; $76	zeropage,x

	rti								; $40	implied
	rts								; $60	implied

	sbc	$1234						; $ed	absolute
	sbc	$00							; $e5	zeropage
	sbc	#$00						; $e9	immediate
	sbc	$1234,x						; $fd	absolute,x
	sbc	$1234,y						; $f9	absolute,y
	sbc	($00,x)						; $e1	(indirect,x)
	sbc	($00),y						; $f1	(indirect),y
	sbc	$00,x						; $f5	zeropage,x

	sec								; $38	implied
	sed								; $f8	implied
	sei								; $78	implied

	sta	$1234						; $8d	absolute
	sta	$00							; $85	zeropage
	sta	$1234,x						; $9d	absolute,x
	sta	$1234,y						; $99	absolute,y
	sta	($00,x)						; $81	(indirect,x)
	sta	($00),y						; $91	(indirect),y
	sta	$00,x						; $95	zeropage,x

	stx	$1234						; $8e	absolute
	stx	$00							; $86	zeropage
	stx	$00,y						; $96	zeropage,y

	sty	$1234						; $8c	absolute
	sty	$00							; $84	zeropage
	sty	$00,x						; $94	zeropage,x

	tax								; $aa	implied
	tay								; $a8	implied
	tsx								; $ba	implied
	txa								; $8a	implied
	txs								; $9a	implied
	tya								; $98	implied

	lda  #$ff
	adc  #$55
	and  #$fe
	cmp  #$12
	eor  #$55
	ora  #$55
	sbc  #$55
	bit  #$55
	ldx  #$23
	cpx  #$55
	ldy  #$23
	cpy  #$55


	lda  #$ff12
	adc  #$5513
	and  #$fe43
	cmp  #$1223
	eor  #$5534
	ora  #$5534
	sbc  #$5534
	bit  #$5534
	ldx  #$2334
	cpx  #$5534
	ldy  #$2334
	cpy  #$5534

	adc	[$34]
	adc	[$34],y

	and	[$34]
	and	[$34],y

	cmp	[$34]
	cmp	[$34],y

	eor	[$34]
	eor	[$34],y



	lda	[$34]
	lda	[$34],y

	ora	[$34]
	ora	[$34],y

	sbc	[$34]
	sbc	[$34],y

	sta	[$34]
	sta	[$34],y

	inc					; $1A implied
	dec

.byte	0,0,0,0,0,0,0

	adc	$ffffff
	adc	$563412,x

	and	$ffffff
	and	$111111,x

	cmp	$ffffff
	cmp	$111111,x

	eor	$ffffff
	eor	$111111,x

	jmp	$7f3355
	jsr	$7f3355

	lda	$7f1234
	lda	$aaee55,x

	ora	$ffffff
	ora	$111111,x

	sbc	$ffffff
	sbc	$111111,x

	sta	$ffffff
	sta	$111111,x

.byte	0,0,0,0,0,0,0

	adc	($55)

.byte	0,0,0,0,0,0,0


	adc	($34)
	and	($34)
	cmp	($34)
	eor	($34)
	lda	($34)
	ora	($34)
	sbc	($34)
	sta	($34)

	jmp	($34,x)
	jsr	($3422,x)

.byte	0,0,0,0,0,0,0

	adc	($34,s),y
	and	($34,s),y
	cmp	($34,s),y
	eor	($34,s),y
	lda	($34,s),y
	ora	($34,s),y
	sbc	($34,s),y
	sta	($34,s),y


.byte	0,0,0,0,0,0,0

	adc	$34,s
	and	$34,s
	cmp	$34,s
	eor	$34,s
	lda	$34,s
	ora	$34,s
	sbc	$34,s
	sta	$34,s

	adc	$ff,s
	adc	$00

	bit	$00,x
	bit	$1234,x
	bit	#$12

	xce

.byte	0,0,0,0,0,0,0
.byte	0,0,0,0,0,0,0

	mvn	$40,$50
	mvp	$f4,$33
Last edited by bound on Sun May 15, 2011 9:55 am, edited 1 time in total.
bound
Posts: 59
Joined: 24 May 2004

Post by bound »

Hi
For debugging purposes I have add simple procedure which creates listing file in source directory . Hope that will help you guys to find problems .
So ones more updated file can be downloaded form --- link deleted ---

Thanks
Last edited by bound on Sun May 15, 2011 9:55 am, edited 1 time in total.
bound
Posts: 59
Joined: 24 May 2004

Post by bound »

nobody wants to help ? one week online , more then 200 openings and only one comment from grumbler ? . I have spend a lot of time working on this software . OK , one million dollar question .. is any one interested ??
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Post by BigEd »

Hi bound, sorry, but I'm only interested in theory - in practice I use ca65. It's good that you did the project and shared it. It might be worth putting up a simple website, and over time you'll accumulate some interest. In fact if you make it the www link in your profile, you'll get a good ranking in search results. I'm in favour of open source - do you intend to share your sources?

Cheers
Ed

Edit: sadly, bound withdrew his project and his downloads. See the next page for a list of existing open-source 65816 assemblers.
Last edited by BigEd on Sat Apr 07, 2012 2:50 pm, edited 1 time in total.
ElEctric_EyE
Posts: 3260
Joined: 02 Mar 2009
Location: OH, USA

Post by ElEctric_EyE »

bound wrote:
nobody wants to help ? one week online , more then 200 openings and only one comment from grumbler ? . I have spend a lot of time working on this software . OK , one million dollar question .. is any one interested ??
One of the main problems I think is that when people get used to an editor or assembler, it's very difficult to switch and change to something different. For me, I like MK's assembler for the 6502. I know of others here, like BDD, who uses MK's assembler and even adapts it to the 65816 by making macros, which very honestly is probably what I will do as well when the time comes.

I'll tell you a software project that would be worth its weight in gold: Make an assembler/disassembler for the 65816, that will run on a 65816 and not a PC. Is there even such a program now free or payware?
User avatar
8BIT
Posts: 1787
Joined: 30 Aug 2002
Location: Sacramento, CA
Contact:

Post by 8BIT »

ElEctric_EyE wrote:
I'll tell you a software project that would be worth its weight in gold: Make an assembler/disassembler for the 65816, that will run on a 65816 and not a PC. Is there even such a program now free or payware?
I agree with this. Hypothetically, if its written in ANSI C, CC65 would probably be able to compile it. You would only need to wrap file system support around it. And since I have CC65 working for my SBC-3, that might not be too hard to do.

Purhaps a new thread should be started though, as not to detract from Bound's project.
ElEctric_EyE
Posts: 3260
Joined: 02 Mar 2009
Location: OH, USA

Post by ElEctric_EyE »

8BIT wrote:
...Purhaps a new thread should be started though, as not to detract from Bound's project.
I agree. Learning how to do this would be very much appreciated!
User avatar
BitWise
In Memoriam
Posts: 996
Joined: 02 Mar 2004
Location: Berkshire, UK
Contact:

Post by BitWise »

bound wrote:
nobody wants to help ? one week online , more then 200 openings and only one comment from grumbler ? . I have spend a lot of time working on this software . OK , one million dollar question .. is any one interested ??
I have my own cross-platform macro assembler/linker package written in Java. It serves all my needs for 6501/6502/65C02/65816/65832.
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
User avatar
BigDumbDinosaur
Posts: 9426
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Post by BigDumbDinosaur »

BitWise wrote:
bound wrote:
nobody wants to help ? one week online , more then 200 openings and only one comment from grumbler ? . I have spend a lot of time working on this software . OK , one million dollar question .. is any one interested ??
I have my own cross-platform macro assembler/linker package written in Java. It serves all my needs for 6501/6502/65C02/65816/65832.
I *hate* Java. :P
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
BigDumbDinosaur
Posts: 9426
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

65816 Assembler for Windows

Post by BigDumbDinosaur »

bound wrote:
nobody wants to help ? one week online , more then 200 openings and only one comment from grumbler ? . I have spend a lot of time working on this software . OK , one million dollar question .. is any one interested ??
I've been super-busy the last several days with revenue work, so haven't had much time to fiddle with my 65xx "toys." I might be able to get back to it in a few days. By the way, I'm not a "grumbler." Having pounded on assemblers of one sort or another for over 40 years, I know what I like. See following comments.
ElEctric_EyE wrote:
One of the main problems I think is that when people get used to an editor or assembler, it's very difficult to switch and change to something different.
Editor/assembler combinations are to bare-metal programmers as guitars are to rock musicians. You get familiar with the package, it's quirks and how to use it to quickly produce quality code. There's a rhythm to it that gets broken when a switch is made to a different package. That's part and parcel of changing anything, but is particularly an issue for a programmer. It especially becomes an issue when non-standard syntax is used in the new assembler (e.g., non-standard radices, the on-going debate concerning ASL A vs. ASL, etc.).
Quote:
I'll tell you a software project that would be worth its weight in gold: Make an assembler/disassembler for the 65816, that will run on a 65816 and not a PC. Is there even such a program now free or payware?
The BIOS ROM in my POC unit has a full-tilt machine code monitor that runs in 65C816 native mode and makes extensive use of the MPU's features, including 16 bit operations and those nifty MVN/MVP instructions. The monitor includes an assembler/disassembler that supports all '816 instructions in all addressing modes. One of my things to do 65xx-wise is extract the monitor from the rest of the ROM and make it available here as source code. There will be some machine-dependent I/O matters to resolve, as well as minor assembler syntax snags, but nothing that anyone here can't handle.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
digidice
Posts: 43
Joined: 03 Oct 2010

Post by digidice »

I think its a worthy project. Sure a lot of guys like the sound of their steel guitars. But I for one am always interested in other options. I dont have much issue with the possibility of a better mousetrap.
I like the idea of having a straight up 816 compiler.

I also would like to know if your planning on open source on this so that it can be made to operate native on 816 hardware?
Post Reply