Friday, March 27, 2015

Understanding 6502 assembly on the Commodore 64 - (26) Intro to unsigned mathematics

Its time to talk about math.  Mathematics is naturally an important part to programming and can seem very confusing in machine language.  We have gotten comfortable with computers languages that allow for the easy computation of complex formulas.  It is quickly understood that mathematical routines may take many steps to complete a simple operation.

Click here for Chapter 26

Thursday, February 5, 2015

Commodore 817 has been released

   After much work, the first version of commodore 817 is available for download.  At this stage, testing has been completed.  The test log and status is at the bottom of the page.

   The running main program takes up only 3299 bytes staying within my goal of under 4K.  Other smaller areas of memory deal with Disk/Printer I/O and uncrunching.  This was written in assembly using Relaunch64 and Tass64.  On actual hardware this was testing using the Glink232 on a stock C64 with an MPS-801 printer

The program has been tested with 1541, SD2IEC, NTSC, PAL.   As well as Vice.  See instructions for VICE below

Download D64 image here

Opening screen

The program reiterates the importance of backing up the calibration data of the radio.  The only way to fix it should it become corrupted is to send it back to the factory for recalibration.   

Initial radio calibration check

The program also provides printouts of the calibration for a safe hardcopy

MPS-801 Output

The main screen shows both VFO and memory information currently running on the radio, as well as frequency, band information, CWID tag, tx/rx status, power levels, adjusted power levels, mode and squelch.A graphical Smeter also acts as the radios SWR meter during transmit.

Top menu functions include

VOX                       - ON/OFF
SPLIT TX/RX         - ON/OFF
CW KEYER            - ON OFF
CW ID                   -  ON OFF

Bottom menu functions include:

Change frequency - Also validates input for acceptable ranges and matches band

Toggle Mode - switches between all available modes

Toggle VFO - switches between VFO A/B

Toggle Power - switches between L1, L2, L3 , and High

A=B - copies all information from VFOA to B and matches current band

Charger ON/OFF

HELP -  An included help file

CHECK CAL - A utility that checks the calibration on the radio against the one saved on disk

check cal downloading cal data for testing

 Option to print after testing

 Portion of the Helpfile


Vice requires that true drive emulation be enabled under Drive settings.

Under RS232 settings

Enable ACIA RS232 interface emulation
ACIA device - serial 1
ACIA Base address $DE00
ACIA interrupt - NMI
ACIA emulation mode - SWIFTLINK

SERIAL 1 DEVICE - whatever your serial port is    mine is /dev/ttyUSB0
Baudrate 9600

Under Printer Settings

Enable Printer #4 IEC Device
Driver MPS-803
Output Graphics
Text output device - Printer 1 (file dump)

Print text device 1...    [where to save and the file name]

Save settings


6 FEB 15:
     Fixed an issue where program will hang when loading help or test cal if the button is pressed while squelch is open and radio receiving RF. Disable glink232 and its receive interrupt before loading disk

     Added disable all sprites before loading help or test cal so receive meter doesn't get stuck on the screen. SPENA to 00

Works in VICE on D64 and works on 1541 on c64, there is an unknown problem with SD2IEC.  Doesn't find calibration file nor save calibration file

7 FEB15:
     Fixed Dialogue when cal test fails

     Fixed check for calibration file code. now works with SD2IEC and 1541

     Fixed irq shutdown bit toggle 2 on GLINK232,    shuts just 2 instead of all bits
     Dumped undeeded vector relocation code used before help and check cal

     Added the don't touch radio medal when transferring A to B


8 FEB15:
    Removed extra 2 !! in A=B code



Wednesday, January 14, 2015

Chapter 2: Serial and network connection with Direwolf

This chapter will talk about programs that interface with Direwolf using serial communication or TCP.  This will not yet discuss AX.25 for network connectivity over packet and keep things simple

Monday, January 12, 2015

Chapter 1: Intro to Packet Radio in the modern age with Direwolf

     Packet radio could be awesome.   By packet radio I do not mean APRS.  If APRS is your thing, you will also benefit from this document.  Consider if you would, the resurgance of BBS's now popping up everywhere, having replaced dial-up with telnet, and still allowing connectivity on antique computers using TCPSER as a conduit.

    Up until now, there have been issues with getting going on packet radio.  First was cost.  Does anyone really want to spend hundreds of dollars on a TNC in the hopes of finding someone else on the air who did the same thing.  Secondly, looking at 15 year old pages of ancient AX25 implementations on the web can be disheartening.  You could not be blamed for making an attempt and quickly giving up on unsupported code from 1.x kernels running under motif, followed by page after page of contradictory information.

Saturday, January 10, 2015

Converting a D64 image on SD2IEC to a floppy disk on the 1541

No special cables required here.   You can move SD2IEC images directly onto the 1541 with your Commodore 64, VIC20 or 128 with ease.

You only need a PC to put the correct files onto the SD card.

See how to do it here!

Thursday, December 18, 2014

Understanding 6502 assembly on the Commodore 64 - (25) Address modes

We've steered of course long enough.  Its time to get back to grass roots.  One of these days I will get all of these chapters in order because addressing modes should definitely be in the first 10.

Click here for Chapter 25

Sunday, December 14, 2014

Understanding 6502 assembly on the Commodore 64 - (24) A better way with NMI

     So far, we've found a less than ideal way to implement our interrupt. So much so that I wanted to simply remove the chapter, but decided to keep it so we can make a comparison.  Lets look at a better way to do this.

Click here for Chapter 24  

Thursday, December 4, 2014

Understanding 6502 assembly on the Commodore 64 - (23) The Ubiquitous Interrupt Request

     Conceptually, the interrupt at its core is easy to understand, yet rarely understood.   Before discussing an interrupt on the computer we must understand being interrupted in general.  To make this apparent we should assume that we are being interrupted from something we're doing or not doing.  We could consider not doing, the act of doing something, which is doing nothing.   Either way,  the interrupt comes as a distraction to what we were doing before we were interrupted.

Click here for Chapter 23

Understanding 6502 assembly on the Commodore 64 - (22) Output Display alternative

     Before we go any further in our program,  lets have a bit more fun.  Though we're still hanging off of our housekeeping interrupt, we're using the screen output addresses to display our code.  It's been effective, but a bit boring.   We can use what we learned in creating sprites to spruce things up a bit.

Click here for Chapter 22

Wednesday, December 3, 2014

Understanding 6502 assembly on the Commodore 64 - (21) Optimizing our interrupt code

     In the last chapter, we modified our code to run our binary converter 60 times per second using the system interrupt, bypassing the address of the usual housekeeping code with our own.  We then Jumped back to the housekeeping code so it could proceed.  We didn't cause an interrupt, we just added our code in as part of the normal system interrupt  But In doing so we ran into a bit of a problem.  

Click here for Chapter 21

Tuesday, December 2, 2014

Understanding 6502 assembly on the Commodore 64 - (20) May I Interrupt?

     In the last few chapters we've had to get through a lot of dry, but necessary stuff.  I figured since this is chapter 20, well do something fun.  Just about every 60th of a second, everything we do it put on hold for the computer to run its own housekeeping chores.  Cursor blink, keyboard input check, screen refresh, that sort of stuff.  To the user it is transparent, as if the 6502 is multitasking and running code in the background.  Arguably it is, but it isn't.  But it is the stuff of genius how this is accomplished.

Click here for Chapter 20

Monday, December 1, 2014

Understanding 6502 assembly on the Commodore 64 - (19) The Truth of the matter

If you haven't done much programming in the past, you will probably still remember Learning Truth tables in mathematics, wondering why you would ever need to know such a thing.  Well,   question answered.   Logical operations are a fundamental part of digital electronics.  The 6502 is no exception.  Before breaking into Mathematics,  we will first learn logical operations.

Sunday, November 30, 2014

Understanding 6502 assembly on the Commodore 64 - (18) Status flags NV-BDIZC

     The execution of Instructions in the 6502 is only half of the story.  The 6502 and its machine code is a running example of cause and effect.  We think of machine code as being at such low level that nothing is done without explicitly instructing it, however, the processor is much more dynamic than is initially apparent on the surface.

Click here for Chapter 18

Saturday, November 29, 2014

Understanding 6502 assembly on the Commodore 64 - (17) Stack and CPU Register in depth

     We need to stop for a minute with our programming, and discuss the registers that the 6502 uses.  We could then continue where we left off, perhaps, EXACTLY where we left off, having personally gained new information about the processor functionality, and continue on our merry way.  In fact, we could state that we are INTERRUPTING our normally scheduled programming to bring you this important information, and then upon completion return you to where you were.

Click here for Chapter 17

Wednesday, November 26, 2014

Disk ][ drive - Clean and Adjustment

     With the Commodore 1541 drives done, it was time to test out the Apple II disk drives.  The drive S6D2 was hardly every used and was at perfect speed and almost perfect alignment.  S6D1 was a different story, that was the workhorse.


See how to do it here!

Tuesday, November 25, 2014

Understanding 6502 assembly on the Commodore 64 - (16) Input and Data Manipulation

     If you haven't guessed by now,  Assembly is the ultimate strategy game.  With endless possibilities to achieve the desired result, we have enjoyed the fact that up until now, we have required very little data manipulation or error checking.  Our last program used a hardcoded value in a specific memory location to execute a task.  It was in fact, part of the program itself.  Sure you could put in whatever you wanted, but garbage in, garbage out. In fact, the only user interaction was running the program itself.

Click here for Chapter 16

Understanding 6502 assembly on the Commodore 64 - (15) The Zero Page

Many people learning 6502 will often hear about the mystical and revered Zero Page area of memory, and all of the magical things it can do.  Well, there is no trickery behind it. The concept is actually quite easy to understand. We can get through this in a single post.

Click here for Chapter 15

Monday, November 24, 2014

Understanding 6502 assembly on the Commodore 64 - (14) Space and cycle optimization

With the C64 and other 8 bit computers, limited in speed and storage space, it important to optimize code to be a small and as fast as possible.  While our simple binary conversion requires neither, its good to see how much we can reduce the size of the code and reduce the amount of cycles required to execute it.  I did not include every single possible optimization the world has to offer, so do not contact me with your idea.  This is primarily about optimizing there flow of the program, and not about   optimization through ways which beginning 6502 programmers might be confused.  

Click here for Chapter 14

Saturday, November 22, 2014

Understanding 6502 assembly on the Commodore 64 - (13) Watching the 6502 Think

I wrote a small program today, It takes a HEX value and returns the binary value onto the screen, or any other contiguous memory location.  I kept it simple, and while simple, still highly effective and adaptable.  What is more interesting though, is stepping through each process as the processor works towards the end of the program.  Thats what were going to do.  This is very hardware neutral code, Changing OURHEXNUM,TESTBYTE, and BIT7 to your preferred memory area will allow this to run on any 6502 based computer.

Click here for Chapter 13

Friday, November 21, 2014

Understanding 6502 assembly on the Commodore 64 - (12) Recap and Beginning Registers

Throughout our program, we have used relatively easy math to allow us to achieve our goals, this has primarily been accomplished with four operations. INX, INY, DEX, DEY.  This is the simplest form of addition and subtraction on the 6502, and its easy to understand.  You might have noticed as well that so far we have not only avoided writing code to NMI's or IRQ's, we have shown complete disregard for our status registers, a most important part of our processor.

Click here for Chapter 12