<-[[.:start]] ====== 6502 Setup ====== ** Various pre-requisites ** ===== Vim Syntax Highlighting ===== To get better syntax highlighting for 6502 assembler I found a vim syntax file ''asmM6502.vim'' [[https://github.com/jestin/asmM6502.vim]] This was saved as ''~/.vim/syntax/asmM6502.vim'' To make sure assembler source code used the 6502 syntax add: autocmd BufRead,BufNewFile *.s,*.asm,*.inc set filetype=asmM6502 to ''~/.vimrc'' ==== Vim in action ==== {{:public:linux:6502:screenshot_2022-08-10_14.30.06.png?direct&400 |}} ===== Assembler compiler VASM ===== To compile source to machine-code suitable for blowing onto EEPROM use the ''vasm'' compiler It's possible to self-compile ''VASM'' by downloading the source-code from: [[http://sun.hasenbraten.de/vasm/]] but there are ready made binaries here, specifically for the 6502 //old-style// binaries: [[http://www.compilers.de/vasm.html]] Use the link at the foot of the page: [[http://www.ibaug.de/vasm/vasm6502.zip]] Download, unzip (extracts the files needed into ''../vasm6502_oldstyle/linux/'') sudo cp ./vasm6502_oldstyle/linux/* /usr/local/bin Add an alias to ''~/.bashrc'' alias vasm='vasm6502_oldstyle -Fbin -dotdir' for the most used options To compile a source file to a binary ''a.out'' file: vasm hello_world.s ++++ hello_world.s | PORTB = $6000 PORTA = $6001 DDRB = $6002 DDRA = $6003 E = %10000000 RW = %01000000 RS = %00100000 .org $8000 reset: ldx #$ff txs lda #%11111111 ; Set all pins on port B to output sta DDRB lda #%11100000 ; Set top 3 pins on port A to output sta DDRA lda #%00111000 ; Set 8-bit mode; 2-line display; 5x8 font jsr lcd_instruction lda #%00001110 ; Display on; cursor on; blink off jsr lcd_instruction lda #%00000110 ; Increment and shift cursor; don't shift display jsr lcd_instruction lda #$00000001 ; Clear display jsr lcd_instruction ldx #0 print: lda message,x beq loop jsr print_char inx jmp print loop: jmp loop message: .asciiz "Hello, world!" lcd_wait: pha lda #%00000000 ; Port B is input sta DDRB lcdbusy: lda #RW sta PORTA lda #(RW | E) sta PORTA lda PORTB and #%10000000 bne lcdbusy lda #RW sta PORTA lda #%11111111 ; Port B is output sta DDRB pla rts lcd_instruction: jsr lcd_wait sta PORTB lda #0 ; Clear RS/RW/E bits sta PORTA lda #E ; Set E bit to send instruction sta PORTA lda #0 ; Clear RS/RW/E bits sta PORTA rts print_char: jsr lcd_wait sta PORTB lda #RS ; Set RS; Clear RW/E bits sta PORTA lda #(RS | E) ; Set E bit to send instruction sta PORTA lda #RS ; Clear E bits sta PORTA rts .org $fffc .word reset .word $0000 ++++ gm4slv@laptop:~/6502 $ vasm hello_world.s vasm 1.8h (c) in 2002-2019 Volker Barthelmann vasm 6502 cpu backend 0.8 (c) 2002,2006,2008-2012,2014-2018 Frank Wille vasm oldstyle syntax module 0.13f (c) 2002-2018 Frank Wille vasm binary output module 1.8a (c) 2002-2009,2013,2015,2017 Volker Barthelmann seg8000(acrwx1): 143 bytes segfffc(acrwx1): 4 bytes Inspect the hexcode in the binary file ''hexdump'' gm4slv@laptop:~/6502 $ hexdump -C a.out 00000000 a2 ff 9a a9 ff 8d 02 60 a9 e0 8d 03 60 a9 38 20 |.......`....`.8 | 00000010 63 80 a9 0e 20 63 80 a9 06 20 63 80 a9 01 20 63 |c... c... c... c| 00000020 80 a2 00 bd 32 80 f0 07 20 79 80 e8 4c 23 80 4c |....2... y..L#.L| 00000030 2f 80 48 65 6c 6c 6f 2c 20 77 6f 72 6c 64 21 00 |/.Hello, world!.| 00000040 48 a9 00 8d 02 60 a9 40 8d 01 60 a9 c0 8d 01 60 |H....`.@..`....`| 00000050 ad 00 60 29 80 d0 ef a9 40 8d 01 60 a9 ff 8d 02 |..`)....@..`....| 00000060 60 68 60 20 40 80 8d 00 60 a9 00 8d 01 60 a9 80 |`h` @...`....`..| 00000070 8d 01 60 a9 00 8d 01 60 60 20 40 80 8d 00 60 a9 |..`....`` @...`.| 00000080 20 8d 01 60 a9 a0 8d 01 60 a9 20 8d 01 60 60 00 | ..`....`. ..``.| 00000090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00007ff0 00 00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 |................| 00008000 ===== minipro EEPROM programmer ===== An open source project ''minipro'' to use the TI866 USB EEPROM programmer under Linux git clone https://gitlab.com/DavidGriffith/minipro.git cd minipro make sudo make install to burn an EEPROM minipro -p AT28C256 -w a.out --- //John Pumford-Green 10/08/22 13:50// ===== Further Information ===== * Sept' 2022 : Moved to CA65 assembler. [[CA65 setup]] {{tag>6502}}