Archives

All posts for the month October, 2014

Now that I’ve completed the Assembly version of this little game, I want to contrast the required Assembly source with the equivalent BASIC source.

For those that don’t know, BASIC is a simplified computer language that uses an English like syntax. The word BASIC stands for Beginners All-purpose Symbolic Instruction Code. On the Atari 8 bit it is an interpreted language, meaning your program source does not compile down into machine opcode instructions. Rather the BASIC program itself executes each line of a programs source code on the fly when its run (interpreted).

BASIC often was, and perhaps still is in some cases, the first language a new programmer learns. It was designed to be easy to use, and it was included with many (now) vintage computers. Often these computers booted straight into BASIC if no other programs were present – as was the case with the Atari 8 bits. Today there is debate surrounding BASIC’s relevance.

From my point of view, BASIC and Assembly may as well be complete opposites.

Assembly Source

First the Assembly source code (in Mac/65 Assembly) for Number Guess, as presented in the last post.

BASIC Source

I crated two versions. The first version follows the same flow format and line numbering for an easy comparison. The second is shorter version without the same flow restrictions imposed. Both BASIC versions of Number Guess are in Atari BASIC.

Version 1

This is version that emulates the assembly program flow and line numbers to make an easy comparison. Any line number here can be matched up to the same line in the Assembly source above. The Assembly version will generally require more steps (lines) to do the same thing.

Comparison

See, BASIC does a lot of work for you! But at the cost of speed and the fact that BASIC must be loaded in some form before your program can be executed. With Assembly programs they can be run without any other programs (or interpreters) loaded first, which makes more memory available to your program.

Results

First a screen shot of the Assembly version being run:

Now a screen shot from the game being played with the first BASIC version:

And lastly, a screen shot from the game being played with the second BASIC version:

As you can see they are basic-ally the same. 😉 The only real difference with the BASIC versions is there is not a space after the “?” when the user inputs the guess.

Like this:

Now I put the library of Assembly routines to work. I created a small game which is an implementation of “Guess My Number”. Hey, you gotta start somewhere. In the previous post I detailed the library, so I’ll jump right into the game.

The game is simple.

A random number is generated between 1 and 100.

The current guess number is displayed, and the user is asked to make a guess.

If the guess is too high, a “too high” message is printed, the guess number is incremented, and step 2 is repeated.

If the guess is too low, a “too low” message is printed, the guess number is incremented, and step 2 is repeated.

If the guess is the random number, a “got it” message is printed followed by a “thanks” message and the game exits.

Instructions

New instructions introduced here.

CLD – CLear Decimal flag. Instructs the 6502 that plain binary numbers should be used rather than binary coded decimal (BCD).

AND – logical AND. Performs AND on the accumulator contents with the contents of the specified value or location with the result stored in the accumulator.

BCC – Branch if Carry Clear. Branches to specified location if the Carry flag is clear. Can only be +127 or -128 bytes of branch address.

Assembly Source

This is the Mac/65 Assembly source code. The source may work with other macro capable assemblers with or without slight modifications.

Like this:

If you have iOS8 on your iPhone or iPad, you use 1Password, and you are tired of doing a two app copy/paste shuffle with Safari and 1Password, then this post is for you.

Problem

Until iOS 8 it was not possible for 1Password to integrate with Safari. You could use 1Passwords built in browser when visiting sites requiring authentication, but it’s not quite as fast or robust as Safari. Declining that you are left with having to shuffle between Safari and 1Password using copy and paste twice each, once for the user, once for the password to perform a login. You could also just leave yourself logged in, but thats a big security no-no and opens your account to all kinds of mischief.

Solution

iOS 8 introduced a new feature called Active Extensions which lets Safari hook into other applications. Ideal for 1Password. This is how you enable it.

Setup

1. Open Safari.

2. Tap the Action menu icon at the bottom.

3. Scroll the bottom gray section to the right until you see more, then tap it.

4. Find 1Password in the list, likely at the bottom, and turn it on (see red circle). While your in there move it to the top of the list using the reorder control (green circle). Then Tap “Done” at the top.

That’s it! It is now setup.

Usage

1. Open a web page that requires authentication such as Google mail. Then tap the Action menu icon.

2. Tap the 1Password button.

3. 1Password is launched in context. Login to it.

4. 1Password will sense the web site you are on just like it does on the Mac, PC, or using its built in browser. If more than one account matches you will be asked which one to use. Just tap it.

5. 1Password will fill the username and password fields for you, then exit.

Like this:

In the beginning…

When I started this learning 6502 assembly project, I wanted to create pure assembly code without the use of macros or routine libraries. Working without routines can be done, but it creates a lot more work. So I caved in and decided re-useable code was a must have. In doing so I created several files that make up my library of routines. In this post I will break down the assembly routines I have written, and in the case of string to integer functions, adapted into my library. As I learn I’m determined to keep everything written by myself, unless it’s just over my head like the string to integer functions. I’m hoping that was the only exception.

The Library

I’m just calling my A8 Library. Currently it is comprised of four (4) files. There is a definitions file, a general functions file, a string macros file, and a string functions file. Each is in SAVE format, not LIST, so they can be included in program source. They are:

A8DEFS.LIB: Definitions, such as names for memory locations, etc.

A8FUNCS.LIB: Functions (general), such as position cursor, etc.

A8STRMAC.LIB: String Macros, the ones I adapted from Karl Weigers work in the July 1986 issue of A.N.A.L.O.G magazine.

A8STRFNC.LIB String Functions, the ones I adapted from Karl Weigers work in the July 1986 issue of A.N.A.L.O.G magazine.

The last three (2) files (A8STRMAC.LIB, and A8STRFNC.LIB) were broken down in the previous post “6502, String to Integer (and reverse)” so I will not break them down again here. The A8FUNCS.LIB was also been broken down in several previous posts, including corrections, so I will not break it down again either.

Breakdown

The only file left to breakdown is the definitions file (A8DEFS.LIB). I’ve tried to keep similar items together. Here it is:

899 to 946: Atari floating point routines. At one point I was going to try to use these for the string/integer routines.

1000+: Misc addresses

Usage

When I write a program, I include A8DEFS.LIB and A8FUNCS.LIB first. Then if I need string to integer or integer to string support I include A8STRMAC.LIB at the beginning and A8STRFNC.LIB at the end of the program source. This pulls all the pieces in at the right time during assembly.

You can download an ATR file with them on it here. It is named as PDF, but it is really an ATR due to a limitation with the hosting site. Use your browsers “download as” function and change the name: A8LIBV10.ATR

Next

Next time I will demonstrate the library being used in my first fully functional, albeit simple, assembly language program. Success!