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.
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.
The only file left to breakdown is the definitions file (A8DEFS.LIB). I’ve tried to keep similar items together. Here it is:
01 ; ------------------------------ 02 ; Lib.: A8DEFS.LIB 03 ; Desc: Definitions Library 09 ; ------------------------------ 99 ; I/O 0100 CIOV = $E456 ;CIO Vector 0110 ICHID = $0340 ;IOCB 0 S: 0120 ICCOM = $0342 ;IOCB Command 0130 ICBAL = $0344 ;Xfer Buffer Adr 0140 ICBAH = $0345 0150 ICBLL = $0348 ;Buffer Len 0160 ICBLH = $0349 0162 ICAX1 = $0350 ;AUX byte 1 0164 ICAX2 = $0351 ;AUX byte 2 0499 ; Cursor 0500 LMARG = $52 ;82d 0510 ROWCRS = $54 ;84d 0520 COLCRS = $55 ;85d 0799 ; Character 0800 EOL = $9B ;155d 0810 EOS = $00 0820 CLS = $7D ;125d 0830 CIX = $F2 ;Index to INBUFF 0832 INBUFF = $F3 ;2 byte InBuf Ptr 0840 LBUFF = $0580 ;128 bytes 0899 ; Floating Point 0901 FPTEMP = $0482 ; User Mem 126 bytes 0902 ASCFP = $D800 ; ATASCII to FP 0904 FPASC = $D8E6 ; FP to ATASCII 0906 INTFP = $D9AA ; INT to FP 0908 FPINT = $D9D2 ; FP to INT 0910 FPSUB = $DA60 ; FR0-FR1 0912 FPADD = $DA66 ; FR0+FR1 0914 FPMUL = $DADB ; FR0*FR1 0916 FPDIV = $DB28 ; FR0/FR1 0918 FPLD0R = $DD89 ; Load using X,Y 0920 FPLD0P = $DD8D ; Load using FLPTR 0922 FPLD1R = $DD98 ; Load using X,Y 0924 FPLD1P = $DD9C ; Load using FLPTR 0926 FPSTOR = $DDA7 ; Store using X,Y 0928 FPSTOP = $DDA8 ; Store using FLPTR 0930 FPMOVE = $DDB6 ; FR0 to FR1 0940 FPZFR0 = $DA44 ; FR0 = 0 0942 FPZAF1 = $DA46 ; Reg in X = 0 0944 FPPTR1 = $FC ; 2 byte ptr User FP1 0946 FPPTR2 = $FE ; 2 byte ptr User FP2 1000 ; Misc 1010 RANDM = $D20A
- 99 to 164: CIO (Central IO addresses)
- 499 to 520: Cursor and margin addresses
- 799 to 840: Character values and pointer locations
- 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
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 time I will demonstrate the library being used in my first fully functional, albeit simple, assembly language program. Success!