From: Rick_Michael_Cortese@cup.portal.com
Newsgroups: comp.sys.atari.8bit
Subject: Re: File Headers.
Date: Thu, 28 Jan 93 10:59:28 PST
Organization: The Portal System (TM)
  <VecTXB8w165w@cyberden.sf.ca.us>

10       .OPT NO OBJ
20       .OPT NO LIST
30 ;
40 ;Some stuff I knocked out for
50 ;      "The Dude"
60 ; Rick Cortese Sept '91
70 ;"ASM,,#D:WCS.COM" TO MAKE FILE
80 ;
90 ;            EQUATES
0100 ;These are all STD Atari locations
0110 ;i.e. The OS decides INBUFF, an
0120 ;I/O buffer, is at $580. The're
0130 ;are 2 software registers, each
0140 ;6 bytes, @ $D4 & $E0 that the OS
0150 ;sets up & uses for FP operation
0160 ;
0170 CIOV =  $E456
0180 EOL =   $9B
0190 CLS =   125
0200 B   =   30      BACKSPACE
0210 D   =   29      DOWN
0220 TAB =   127
0230 PUTREC = $09
0240 GETREC = $05
0250 INBUFF = $F3
0260 ;
0270 ;Index to 1st byte in buffer
0280 ;
0290 CIX =   $F2
0300 IOCB0 = $0340
0310 ICCOM = IOCB0+2
0320 ICBAL = IOCB0+4
0330 ICBAH = IOCB0+5
0340 ICBLL = IOCB0+8
0350 ICBLH = IOCB0+9
0360 ;
0370 ;ROM FP entry points from OS
0380 ;SOURCE LISTING, MAPPING THE
0390 ;ATARI, DE RE ATARI, etc.
0400 ;There are more, but I don't
0410 ;      use everything!
0420 ;
0430 ;Convert string to FP
0440 AFP =   $D800
0450 ;Convert FP to string
0460 FASC =  $D8E6
0470 ;Subtract FR0=FR0-FR1
0480 FSUB =  $DA60
0490 ;Divide FR0=FR0/FR1
0500 FDIV =  $DB28
0510 ;Move FR0 to FR1
0520 FMOVE = $DDB6
0530 ;Convert FP# in FR0 to integer
0540 ;(2 bytes) at $D4, $D5
0550 FPI =   $D9D2
0560 ;
0570 ;This'll make it load and go
0580 ;then continue with the next
0590 ;file if it is appended
0600 ;
0610 INIT =  $02E2
0620     *=  $3000
0630 ;
0640 ;Sparta JSR to 1st BYTE of file
0650 ;so stick this in to fool it
0660 ;should make it compatabile
0670 ;      with any DOS
0680 ;
0690     RTS
0700 START
0710     LDA #$38
0720     STA $D302
0730     LDA #$FF
0740     STA $D300
0750     LDA #$3C
0760 ;
0770 ;Use IOCB0 since the OS OPENs it
0780 ;on POWER UP (Saves time & MEM)
0790 ;save IOCB STATUS(A 5, 9,or 12)
0800 ;since this file may be chained
0810 ;it may have been changed by
0820 ;the 1st program in the file
0830 ;
0840     LDA ICCOM
0850     STA RESET
0860 ;
0870 ;Prompt user for number
0880 ;
0890     LDA #MESSAGE1&$FF
0900     STA ICBAL
0910     LDA #MESSAGE1/$0100
0920     STA ICBAH
0930     JSR OUTPUT
0940 ;
0950 ;INPUT user number to BUFFER
0960 ;I used mine to save INBUFF
0970 ;for intermediate I/O
0980 ;
0990     LDA #BUFFER&$FF
1000     STA ICBAL
1010     LDA #BUFFER/$0100
1020     STA ICBAH
1030     JSR INPUT
1040 ;
1050 ;LOAD FR0 with "144.39"
1060 ;
1070     LDA #ANUM&$FF
1080     STA INBUFF
1090     LDA #ANUM/$0100
1100     STA INBUFF+1
1110     LDA #0
1120     STA CIX
1130     JSR AFP
1140 ;
1150 ;MOVE it to FR1
1160 ;
1170     JSR FMOVE
1180 ;
1190 ;LOAD FR0 with user number
1200 ;
1210     LDA #BUFFER&$FF
1220     STA INBUFF
1230     LDA #BUFFER/$0100
1240     STA INBUFF+1
1250     LDA #0
1260     STA CIX
1270     JSR AFP
1280 ;
1290 ;SUBTRACT  FR0=FR0-FR1
1300 ;
1310     JSR FSUB
1320 ;
1330 ;MOVE result to FR1
1340 ;
1350     JSR FMOVE
1360 ;
1370 ;LOAD FR0 with .015 number
1380 ;
1390     LDA #BNUM&$FF
1400     STA INBUFF
1410     LDA #BNUM/$0100
1420     STA INBUFF+1
1430     LDA #0
1440     STA CIX
1450     JSR AFP
1460 ;
1470 ;This is actually .015/number
1480 ;
1490     JSR FDIV
1500     BCS BYE     OUT IF NUM/0
1510 ;
1520 ;FR0=>FR1
1530 ;
1540     JSR FMOVE
1550 ;
1560 ;MOVE "1" to FP0
1570 ;
1580     LDA #CNUM&$FF
1590     STA INBUFF
1600     LDA #CNUM/$0100
1610     STA INBUFF+1
1620     LDA #0
1630     STA CIX
1640     JSR AFP
1650 ;
1660 ;This inverts to number/.015
1670 ;
1680     JSR FDIV
1690     BCS BYE     out if ERROR
1700     JSR FASC
1710 ;
1720 ;Last DIGIT will be INVERSE
1730 ;
1740     LDY #$FF
1750 LOOP
1760     INY
1770     LDA (INBUFF),Y
1780     BPL LOOP
1790     AND #$7F
1800     STA (INBUFF),Y
1810     INY
1820     LDA #EOL
1830     STA (INBUFF),Y
1840     LDA #$80
1850     STA ICBAL
1860     LDA #$05
1870     STA ICBAH
1880     JSR OUTPUT
1890 ;
1900 ;CONVERT FP to INTEGER @ $D4
1910 ;
1920     JSR FPI
1930     LDA $D4
1940     STA $D300
1950     LDA RESET
1960     STA ICCOM
1970     RTS
1980 BYE
1990 ;
2000 ;Got here because of a NUM/0
2010 ;or user made a mistake or wants
2020 ;a ZERO so we give him one
2030 ;
2040     LDA #ZERO&$FF
2050     STA INBUFF
2060     LDA #ZERO/$0100
2070     STA INBUFF+1
2080     LDA #0
2090     STA CIX
2100     JSR AFP
2110     JSR FASC
2120     LDY #$FF
2130     JMP LOOP
2140 ANUM
2150     .BYTE "144.39",EOL
2160 BNUM
2170     .BYTE "0.015",EOL
2180 CNUM
2190     .BYTE "1",EOL
2200 ZERO
2210     .BYTE "0",EOL
2220 OUTPUT
2230     LDA #PUTREC
2240     STA ICCOM
2250     LDA #$FF
2260     STA ICBLL
2270     LDA #$00
2280     STA ICBLH
2290     LDX #0
2300     JSR CIOV
2310     RTS
2320 INPUT
2330     LDA #GETREC
2340     STA ICCOM
2350     LDA #$FF
2360     STA ICBLL
2370     LDA #$00
2380     STA ICBLH
2390     LDX #0
2400     JSR CIOV
2410     RTS
2420 RESET
2430     *=  *+1
2440 MESSAGE1
2450     .BYTE CLS,D,D,D,TAB,"Hello!"
2460     .BYTE D,D,B,B,B,B,B,B,B,B,B
2470     .BYTE "Input a number"
2480     .BYTE D,B,B,B,B,B,B,B,B,B,B
2490     .BYTE "BETWEEN 144.39 & "
2500     .BYTE "148.215",EOL
2510 BUFFER
2520 ;
2530 ;This really isn't Necessary
2540 ;since I just need the ADDRESS
2550 ;of the 1st free POSITION
2560 ;beyond the PROGRAM,
2570 ;but if I wanted to add some code
2580 ;after the BUFFER & before INIT...
2590 ;
2600     *=  *+$FF
2610     *=  INIT
2620     .WORD START
2630     .END
Newsgroups: comp.sys.atari.8bit