Difference between revisions of "Programming the Microprocessor"

From media_wiki
Jump to: navigation, search
 
(21 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''Use Notepad++ to write your source code.'''
+
'''Write your source code.'''
 
  Download and Install '''Notepad++''' from https://notepad-plus-plus.org/
 
  Download and Install '''Notepad++''' from https://notepad-plus-plus.org/
  Open '''Notepad++''' and select '''File''' and then select '''New''' (Opens a new window)
+
Create a new folder (direcotry) Called VASM6502
  Select '''Language''' and then select the Letter '''A''' then select '''Assembly'''  
+
  Open '''Notepad++''' and select '''File''' and then select '''New'''. (Opens a new window)
  Select '''File''' again and then '''Save AS''' [enter a file name for your program]  
+
  Select '''Language''' and then select the Letter '''A''' then select '''Assembly.'''  
  Make sure it has the yourfilename.'''asm''' extension click '''Save'''
+
Assembly Language file uses the .s extension or .asm
 
+
  Select '''File''' again and then '''Save AS''' to the folder VASM6502 [enter a file name '''updownblink.asm''']  
 
+
  Make sure it has the '''.asm''' extension then click '''Save'''.
  '''Example code:'''
+
  Make sure you have line numbering turned '''On'''. Found under '''Settings/Preferences/Editing/Display line number'''.  
      STX #$6ffc ; capture x reg
+
  Cut and paste the example code below into Notepad++ at line #1  
      LDX #$55    ; set counter to binary 10101010
+
Select '''File''' again and then '''Save '''  
count EQU *
 
      LDA #$0f  ; Turn on half of the LED's 00001111
 
      STA $6000 ; Write value to VIA chip
 
      DEX ; Decrease the X register by 1
 
      LDA #$f0  ; Turn on half of the LED's 11110000
 
      BNE count
 
      LDX $6ffc  ; Restore X reg to orginal value
 
      LDA #$00  ; turn off all LED's 00000000
 
      STA $6000  ; Write value to VIA chip
 
 
 
 
 
  
 +
'''Example code:'''
 +
  .org $8000          ; Reset Vector points to the Program address on EEPROM
 +
reset:  ; reset = address $8000 on the EEPROM
 +
  LDA #$FF          ; Set DDRB to output on 65c22
 +
  STA $6002 ; write to VIA Address for DDRB
 +
loop: ; Main loop starts here
 +
  LDA #$55 ; Load Hex 55 alternating 0101 0101 Turn on evey other LED
 +
  STA $6000 ; Write to VIA $55 binary 01010101
 +
  LDA #$00 ; Load $00 Binary 00000000 turn off LEDs
 +
  STA $6000 ; Write to VIA $00 binary 00000000
 +
  LDA #$AA ; Load Hex AA alternating 1010 1010 Turn on evey other LED
 +
  STA $6000 ; Write to VIA $AA binary 10101010
 +
  LDA #$00 ; Load $00 Binary 00000000 turn off LEDs
 +
  STA $6000 ; Write to VIA $00 binary 00000000
 +
  LDA #$55 ; Load Hex 55 alternating 0101 0101 Turn on evey other LED
 +
  STA $6000 ; Write to VIA $55 binary 01010101
 +
  LDA #$00 ; Load $00 Binary 00000000 turn off LEDs
 +
  STA $6000 ; Write to VIA $00 binary 00000000
 +
  LDA #$AA ; Load Hex AA alternating 1010 1010 Turn on evey other LED
 +
  STA $6000 ; Write to VIA $AA binary 10101010
 +
  LDA #$00 ; Load $00 Binary 00000000 turn off LEDs
 +
  STA $6000 ; Write to VIA $00 binary 00000000
 +
  LDA #$FF ; Load Hex FF all 1111 1111 to the A Register
 +
  STA $6000 ; Write to VIA $FF binary 11111111 to on all LED's
 +
  LDA #$00 ; Load $00 Binary 00000000 turn off LEDs
 +
  STA $6000 ; Write to VIA $00 binary 00000000
 +
  LDA #$FF ; Load Hex FF all 1111 1111 to the A Register
 +
  STA $6000 ; Write to VIA $FF binary 11111111 to on all LED's
 +
  LDA #$00 ; Load $00 Binary 00000000 turn off LEDs
 +
  STA $6000          ; Write to VIA $00 binary 00000000
 +
  LDA #$FF ; Load Hex FF all 1111 1111 to the A Register
 +
  STA $6000         ; Write to VIA $FF binary 11111111 to on all LED's
 +
  LDA #$00 ; Load $00 Binary 00000000 turn off LEDs
 +
  STA $6000 ; Write to VIA $00 binary 00000000
 +
  LDX #$00              ; Load the X register with $00 to start counting
 +
countup: ; Start counting up from 0
 +
  INX ; increment the X register
 +
  TXA ; transfer X register to A register
 +
  STA $6000          ; Write that value to the VIA chip to turn on LEDS
 +
  BNE countup         ; Branch not equal if less than 256
 +
  LDA #$00 ; Load $00 to turn off all LED's 
 +
  STA $6000         ; Write $00 to VIA to turn off LED's
 +
  LDX #$ff          ; Load X register with valus $FF to make sure in counts down correctly
 +
countdown: ; Start loop for count down
 +
  DEX ; decrement the X register
 +
  TXA ; transfer X register to A register
 +
  STA $6000          ; Write that value to the VIA chip to turn on LEDS
 +
  BNE countdown        ; Branch not equal if not = 0
 +
  LDA #$00          ; Load $00 to turn off all LED's
 +
  STA $6000         ; Write $00 to VIA to turn off LED's
 +
  JMP loop ; Jump back to the start of the program
 +
  .org $fffc         ; Address of where to load or start the program
 +
  .word reset         ; reset = address $8000
 +
  .word $0000         ; write a word $0000 to fill in the the whole EEPROM
  
 +
'''Compile your source code Windows 10.'''
 +
Download the application VASM from Dr. Volker Barthelmann´s Compiler Page: http://www.compilers.de/vasm.html
 +
'''Select Binaries of vasm for 6502 for x86-64 (Mac, Windows and Linux):''' http://www.ibaug.de/vasm/vasm6502.zip
 +
Move '''vasm6502.zip''' to your new folder VASM6502 and extract the zip file in that folder.
 +
Open the new folder called '''vasm6502_oldstyle''' and select your operating system. I will be using Windows folder. (Win\Win10)
 +
Open '''WIN''' folder then '''Win10''' folder and copy the relative path.
 +
C:\Users\this-PC\Documents\VASM-6502\vasm6502_oldstyle\win\win10
 +
Move the file '''updownblink.asm''' you created with Notepad++ to the Win10 folder.
  
 +
'''VASM6502 compiler''' is a command line program (CMD) so you need to use the CMD prompt terminal in Windows10.
 +
Open CMD prompt terminal and change directory to the '''VASM6502''' directory. 
 +
Example: CD Users\this-PC\Documents\VASM-6502\vasm6502_oldstyle\win\win10
 +
Do a list command to make sure your updownblink.asm file is in the folder.
 +
Type the following command: '''vasm6502_oldstyle.exe -Fbin -dotdir updownblink.asm'''
 +
Output creates the following lines and a file called '''a.out'''
 +
  ''vasm 1.8g (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):                106 bytes
 +
  segfffc(acrwx1):                  4 bytes''
 +
 
 +
Rename the a.out file so that when you create a new program you do not lose this one.
 +
rename a.out updownblink.out
 +
'''Next Step:'''
 +
Write the updownblink.out to the EEPROM
 +
== [[ Programming the EEPROM ]]==
 +
----
  
 +
== [[ 65C02 Vintage Computer Build ]] ==
  
 
----
 
----
 
+
==[[ Main Page ]]==
== [[ 65C02 Vintage Computer Build ]] ==
 

Latest revision as of 17:02, 7 June 2022

Write your source code.

Download and Install Notepad++ from https://notepad-plus-plus.org/
Create a new folder (direcotry) Called VASM6502
Open Notepad++ and select File and then select New. (Opens a new window)
Select Language and then select the Letter A then select Assembly. 
Assembly Language file uses the .s extension or .asm
Select File again and then Save AS to the folder VASM6502 [enter a file name updownblink.asm] 
Make sure it has the .asm extension then click Save.
Make sure you have line numbering turned On. Found under Settings/Preferences/Editing/Display line number.  
Cut and paste the example code below into Notepad++ at line #1 
Select File again and then Save  

Example code:

  .org $8000  	        ; Reset Vector points to the Program address on EEPROM
reset:  		; reset = address $8000 on the EEPROM
  LDA #$FF  	        ; Set DDRB to output on 65c22 
  STA $6002		; write to VIA Address for DDRB
loop:			; Main loop starts here
  LDA #$55		; Load Hex 55 alternating 0101 0101 Turn on evey other LED
  STA $6000		; Write to VIA $55 binary 01010101
  LDA #$00		; Load $00 Binary 00000000 turn off LEDs
  STA $6000		; Write to VIA $00 binary 00000000
  LDA #$AA		; Load Hex AA alternating 1010 1010 Turn on evey other LED
  STA $6000		; Write to VIA $AA binary 10101010 
  LDA #$00		; Load $00 Binary 00000000 turn off LEDs
  STA $6000		; Write to VIA $00 binary 00000000
  LDA #$55		; Load Hex 55 alternating 0101 0101 Turn on evey other LED
  STA $6000		; Write to VIA $55 binary 01010101
  LDA #$00		; Load $00 Binary 00000000 turn off LEDs
  STA $6000		; Write to VIA $00 binary 00000000
  LDA #$AA		; Load Hex AA alternating 1010 1010 Turn on evey other LED
  STA $6000		; Write to VIA $AA binary 10101010 
  LDA #$00		; Load $00 Binary 00000000 turn off LEDs
  STA $6000		; Write to VIA $00 binary 00000000 
  LDA #$FF		; Load Hex FF all 1111 1111 to the A Register	
  STA $6000		; Write to VIA $FF binary 11111111 to on all LED's
  LDA #$00		; Load $00 Binary 00000000 turn off LEDs
  STA $6000		; Write to VIA $00 binary 00000000
  LDA #$FF		; Load Hex FF all 1111 1111 to the A Register
  STA $6000		; Write to VIA $FF binary 11111111 to on all LED's
  LDA #$00		; Load $00 Binary 00000000 turn off LEDs
  STA $6000  	        ; Write to VIA $00 binary 00000000
  LDA #$FF		; Load Hex FF all 1111 1111 to the A Register
  STA $6000 	        ; Write to VIA $FF binary 11111111 to on all LED's
  LDA #$00		; Load $00 Binary 00000000 turn off LEDs
  STA $6000		; Write to VIA $00 binary 00000000
  LDX #$00              ; Load the X register with $00 to start counting
countup:		; Start counting up from 0 
  INX			; increment the X register
  TXA			; transfer X register to A register 
  STA $6000   	        ; Write that value to the VIA chip to turn on LEDS 
  BNE countup	        ; Branch not equal if less than 256
  LDA #$00 		; Load $00 to turn off all LED's  
  STA $6000 	        ; Write $00 to VIA to turn off LED's 
  LDX #$ff   	        ; Load X register with valus $FF to make sure in counts down correctly 
countdown:		; Start loop for count down
  DEX			; decrement the X register
  TXA			; transfer X register to A register 
  STA $6000   	        ; Write that value to the VIA chip to turn on LEDS 
  BNE countdown         ; Branch not equal if not = 0
  LDA #$00   	        ; Load $00 to turn off all LED's 
  STA $6000 	        ; Write $00 to VIA to turn off LED's 
  JMP loop		; Jump back to the start of the program
  .org $fffc	        ; Address of where to load or start the program
  .word reset	        ; reset = address $8000
  .word $0000 	        ; write a word $0000 to fill in the the whole EEPROM

Compile your source code Windows 10.

Download the application VASM from Dr. Volker Barthelmann´s Compiler Page: http://www.compilers.de/vasm.html
Select Binaries of vasm for 6502 for x86-64 (Mac, Windows and Linux): http://www.ibaug.de/vasm/vasm6502.zip
Move vasm6502.zip to your new folder VASM6502 and extract the zip file in that folder.
Open the new folder called vasm6502_oldstyle and select your operating system. I will be using Windows folder. (Win\Win10)
Open WIN folder then Win10 folder and copy the relative path.
C:\Users\this-PC\Documents\VASM-6502\vasm6502_oldstyle\win\win10
Move the file updownblink.asm you created with Notepad++ to the Win10 folder. 
VASM6502 compiler is a command line program (CMD) so you need to use the CMD prompt terminal in Windows10.
Open CMD prompt terminal and change directory to the VASM6502 directory.  
Example: CD Users\this-PC\Documents\VASM-6502\vasm6502_oldstyle\win\win10
Do a list command to make sure your updownblink.asm file is in the folder.
Type the following command: vasm6502_oldstyle.exe -Fbin -dotdir updownblink.asm

Output creates the following lines and a file called a.out

 vasm 1.8g (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):                 106 bytes
 segfffc(acrwx1):                   4 bytes
 

Rename the a.out file so that when you create a new program you do not lose this one.

rename a.out updownblink.out

Next Step:

Write the updownblink.out to the EEPROM

Programming the EEPROM


65C02 Vintage Computer Build


Main Page