Technical Notes

Free Programming e-book

Finding interesting stuff for the Mac is difficult given the relative numbers of users and programmers out there. I think I may have found something though.

In the *NIX world (including OS X) the Python language seems to be the up and coming thing for programming. Python is an interpreted object oriented language. Python comes free with OS X, Linux, and BSD. It has to be downloaded and installed if it is to run on a Windows machine. I have tried simple GUI programming under Linux and will try it for the Mac as I get to that point.

The book itself contains a number of exercises as well as instructions on how to write programs in Python. I have only reached the second set of exercises but have already found a number of useful items. Those starting out may want to take a look at my recent articles on shells and shell programming. Although it is possible to program exclusively in a GUI environment, it is still a very good idea to start out using the shell then transition to the GUI.

The title of the book is “Learning Python The Hard Way“. The link to the authors web site is http://sheddingbikes.com/posts/1285754959.html. Please read the information on the page before downloading the book.

Disk ][ And You

by John Covington

Finally! !! Disk II is out. If you’re lucky, you will be able to play with one in your local computer store until yours arrives from Cupertino. That is what I have been doing this last week, and this article comes from using the disk and my varied background in Data Processing. Hopefully, I’ll be able to explain some of the HOWS and WHYS of the disk system and clear up some of the blind spots in Disk II’s documentation. So let’s get on with it and explore the mysteries of DOS.

DOS is simply short for DISK OPERATING SYSTEM, the heart of Disk II. With it, Apple is able to talk to the disk and treat it like any other 110 device. The DOS is just a program (which resides in the top of RAM) so like Applesoft, if you write over it, you can kill it. However, with normal use, you don’t have to worry about that. If you are like me and have only 16K of RAM, the DOS will lock you out of using HIRES, because HIRES Page 1 uses your upper 8K of RAM. Now, let’s bring the DOS up and find out how to use it.

HOW DO YOU DO THAT???
First, follow the instructions that came with the Disk System and plug the controller card into slot 6 in your Apple (with the power off). Then connect the ribbon cable from the drive into the controller card connector marked “Drive 1″ (on the top of the card) and power your Apple up and hit reset twice. Insert the master diskette in the drive and type a 6 (for slot number), followed by Control P. This will bootstrap in the DOS and bring the disk system up. If all goes well you will see some titles and an Integer Basic prompt. This means DOS is up and you can begin running programs.

One of the first to run is the COpy program, but there is a hitch; it requires two drives. I’m sure the owner of your local computer outlet will let you run this program in his store, using your drive as the second drive. The purpose of running the copy program is to duplicate your master. It may save both of you a lot of headaches later. (We found out the hard way •… ed)

The reason is your master can be lost in a number of ways, ranging from oxide breakdown to operator error. Therefore it is prudent to have a backup disk to recover from.

To copy your master, you must first initialize a blank disk. To do this, boot the DOS up and then enter a short Integer Basic program (as per example) and use the INIT routine as follows:

INIT (program name), V{vol. no.), S{slot no.), D{drive no.).

Then run the COPY routine and Disk II will make you a second master.

WHA T’ s THIS INIT THING? ? ?
The INIT command INITializes new disks. Because the Apple system uses soft sector drives, the floppies must be formatted to fit the DOS software. Any
mini-floppy has 35 tracks (similar to a track on a phonograph record, except it does not spiral in; it meets itself after one revolution. ) each of which must be divided into a certain number of sectors (a sector is where the data actually goes, and is composed of 256 bytes). To perform the INIT, you must have an Integer Basic program in RAM, which serves as a model for the formatter. It can be any runable Basic program, but keep it short, as this program will automatically run each time the disk is booted. The short program listed on Page 4 will serve as well as any, and will also call the catalog up for you each time you boot the disk up. Well, I guess I’ve given you enough to make you dangerous!

HAPPY DISKING!

Apple ][ Mini Assembler

The following section covers use of the Apple II mini-assembler only. It is not a course in assembly language programming. The following section assumes the user has a working knowledge of 6502 programming and mnemonics. The Apple II mini-assembler is a programming aid aimed at reducing the amount of time requir.ed to convert a handwritten program to object code. The mini-assembler is basically a look-up table for opcodes. With it, you can type mnemonics with their absolute addresses, and the assembler will convert it to the correct object code and store it in memory.

Typing “F666G” will put the user in mini-assembler mode. While in this mode, any line typed in will be interpreted as an assembly language instruction, assembled, anctstored in binary form unless the first character on th’e command line is a “$”.

If it is, the remainder of the line will be interpreted as a normal monitor command, executed, and control returned to assembler mode. To get out of the assembler mode, reset ml1st be pushed. If the first character on the line is blank, the assembled instruction will be stored starting at the address immediately following the previously assembled instruction.

If the first character is nonblank (and not “$”). the line is assumed to contain an assembly language instruction preceded by the instruction address (a hex number followed by a “:”1. In either case. the instruction will be retyped over the line just entered in disassembler format to provide a visual check of what has been assembled. The counter that keeps track of where the next instruction will be stored is the pseudo PC (Pro~ram Counter) and it can be changed by many monitor commands (eg .• ·L·. ‘T’ •.. .1. Therefore. it is advisable to use the explicit instruction address mode after every monitor command and. of course, when the mini-assembler is first entered.

Errors (unrecognized mnemonic, illegal format, etc.l are Signalled by a “beep” and a carrot (“-”) will be printed beneath the last character read from the input line by the mini-assembler. The mnemonics and formats accepted by the mini-assembler are the same as those listed by the 6502 Programmers Manual, with the following exceptions and differences:

1. All imbedded blanks are ignored. except inside addresses.

2. All addresses typed in are assumed to be in hex (rather than decimal or symbolic). A preceding “$” (Indicating hex rather than decimal or symbolic) is therefore optional. except that it should not precede the instruction address.

3. Instructions that operate on the accumulator have a blank operand field instead of “A”.

4. When entering a branch instruction, following the branch mnemonic should be the target of the branch. If the destination address is not known at the time the instruction is entered. simply enter an address that is in the neighborhood, and later re-enter the branch instruction with the correct target address. NOTE: If a branch target is specified that is out of range. the mini-assembler will flag the address as being in error.

5. The operand field of an instruction can only be followed by a comment field. which starts with a semi-colon (“;”1. Obviously. the mini-assembler ignores the field and in fact will type over it when the line is typed over in disassemblerformat. This “feature” is included only to be compatible with future upgrades including input sources other than the keyboard.

6. Any page zero references will generate page zero instruction formats if such a mode exists. There is no way to force a page zero address to be.two bytes. even if the address has leading zeros.

In general, to specify an addressing type. simply enter it as it would be listed in the disassembly. For information on the disassembler. see Apple II System Monitor in the previous section. A complete listing of the mini-assembler appears at the end of this section. An example of the mini-assembler appears below. Note that the second “BRK” has no space before it hence Apple refused the input. sounded the bell and typed a “‘” underneath the “R”. In “LDA3B45″, Apple also refused the instruction because “R” is not a legal hex digit. Remember to hit the “RESET” key to get out of the mini-assembler.

*F666G
!0: INX
0000- E8 INX
! TXA
0001- ·8A TXA
! JSR £FDED
0002- 20 ED FD JSR $FDED
! JMP $0
0005- 4C 00 00 JMP $0000
! BRK
0008- 00 BRK
! BRK

! BRK
0009- 00 BRK
! LDA 3B45