mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-11-28 10:51:14 +00:00
Update Module block and associated header variables
This commit is contained in:
parent
1797d376db
commit
3773129162
@ -6,24 +6,20 @@ ESCKEY EQU $1B ;Escape/Stop Key (Escape)
|
||||
RTNKEY EQU $0D ;Return/Enter Key (Return)
|
||||
|
||||
;Zero Page Variables (*=System Variable)
|
||||
DSTLO EQU $06 ;Destination String/Array Pointer
|
||||
DSTHI EQU $07
|
||||
BLKLO EQU $08 ;Block Segment Pointer (block.a02)
|
||||
BLKHI EQU $09
|
||||
DSTPTR EQU $06 ;Destination String/Array Pointer
|
||||
BLKPTR EQU $08 ;Block Segment Pointer (block.a02)
|
||||
PTRLO EQU $1D ;System Pointer (pointer.a02)
|
||||
PTRHI EQU $1E
|
||||
RANDOM EQU $1F ;Random Number
|
||||
INVFLG EQU $32 ;*Inverse Flag: $3F=Blinking, $7F=Inverse, $FF=Normal
|
||||
RDSEED EQU $4E ;O/S Random Number Low Byte
|
||||
; EQU $4F ;O/S Random Number High Byte
|
||||
SRCLO EQU $71 ;Source String/Array Pointer
|
||||
SRCHI EQU $72
|
||||
SRCPTR EQU $71 ;Source String/Array Pointer
|
||||
; $E3 ;Unused
|
||||
BLKSLO EQU $EB ;Block Start Address
|
||||
BLKSHI EQU $EC
|
||||
BLKELO EQU $ED ;Block End Address
|
||||
BLKEHI EQU $EE
|
||||
BLKBGN EQU $EB ;Block Start Address
|
||||
BLKEND EQU $ED ;Block End Address
|
||||
BLKLEN EQU $EF ;Block Segment Length
|
||||
BFRPTR EQU $FA ;Work Buffer Pointer
|
||||
BFRLO EQU $FA ;Work Buffer Pointer
|
||||
BFRHI EQU $FB
|
||||
TEMP0 EQU $FC ;Temporary Storage
|
||||
|
@ -3,16 +3,12 @@
|
||||
/* Monitor Variables */
|
||||
|
||||
/* Standard Library Variables */
|
||||
char srclo,srchi; //Source String Pointer for Library Functions
|
||||
char dstlo,dsthi; //Destination String Pointer for Library Functions
|
||||
zeropage int srcptr, dstptr, bfrptr, blkptr;
|
||||
char bfrlo,bfrhi; //Buffer Pointer for Library Functions
|
||||
char blklo,blkhi; //Block Segment Pointer
|
||||
char ptrlo,ptrhi; //System Pointer
|
||||
|
||||
char blkslo, blkshi; //Block Start Address
|
||||
char blkelo, blkehi; //Block End Address
|
||||
char blklen; //Block Segment Length
|
||||
|
||||
int blkbgn, blkend; //Block Start and End Address
|
||||
char blklen; //Block Segment Length
|
||||
char temp0, temp1, temp2, temp3; //Temporary Variables
|
||||
|
||||
//System Variables
|
||||
|
@ -20,15 +20,10 @@ RTNKEY EQU $0D ;Return/Enter Key (Carriage Return)
|
||||
|
||||
;Standard Library Variables
|
||||
SRCPTR EQU $30 ;Source String Pointer (stdio.a02)
|
||||
SRCLO EQU $30 ;Source String Pointer (stdio.a02)
|
||||
SRCHI EQU $31
|
||||
DSTPTR EQU $32 ;Destination String Pointer (string.a02)
|
||||
DSTLO EQU $32 ;Destination String Pointer (string.a02)
|
||||
DSTHI EQU $33
|
||||
BFRLO EQU $34 ;Work Buffer Pointer
|
||||
BFRHI EQU $35
|
||||
BLKLO EQU $36 ;Block Segment Pointer (block.a02)
|
||||
BLKHI EQU $37
|
||||
BLKPTR EQU $36 ;Block Segment Pointer (block.a02)
|
||||
STKLO EQU $38 ;System Pointer (pointer.a02)
|
||||
STKHI EQU $39
|
||||
|
||||
@ -41,10 +36,8 @@ TEMP2 EQU $42
|
||||
TEMP3 EQU $43
|
||||
|
||||
BLKLEN EQU $47 ;Block Segment Length
|
||||
BLKSLO EQU $48 ;Block Start Address
|
||||
BLKSHI EQU $49
|
||||
BLKELO EQU $4A ;Block End Address
|
||||
BLKEHI EQU $4B
|
||||
BLKBGN EQU $48 ;Block Start Address
|
||||
BLKEND EQU $4A ;Block End Address
|
||||
STKSLO EQU $4C ;Stack Start Address
|
||||
STKSHI EQU $4D
|
||||
STKELO EQU $4E ;Stack End Address
|
||||
|
@ -7,14 +7,11 @@
|
||||
#define SYSBFL 128 //System Buffer Length
|
||||
|
||||
/* Standard Library Variables */
|
||||
char srclo,srchi; //Source String Pointer for Library Functions
|
||||
char dstlo,dsthi; //Destination String Pointer for Library Functions
|
||||
char blklo,blkhi; //Block Segment Pointer
|
||||
zeropage int srcptr, dstptr, bfrptr, blkptr;
|
||||
char stklo,skthi; //System Pointer
|
||||
|
||||
char blkslo, blkshi; //Block Start Address
|
||||
char blkelo, blkehi; //Block End Address
|
||||
char blklen; //Block Segment Length
|
||||
int blkbgn, blkend; //Block Start and End Address
|
||||
char blklen; //Block Segment Length
|
||||
|
||||
char stkslo, stkshi; //Stack Start Address
|
||||
char stkelo, stkehi; //Stack End Address
|
||||
|
@ -9,10 +9,7 @@ RTNKEY EQU $0D ;Return/Enter Key (Return)
|
||||
|
||||
;Zero Page Variables (*=System Variable)
|
||||
DSTPTR EQU $06 ;Destination Pointer [Unused]
|
||||
DSTLO EQU $06
|
||||
DSTHI EQU $07
|
||||
BLKLO EQU $08 ;Block Segment Pointer [Unused]
|
||||
BLKHI EQU $09
|
||||
BLKPTR EQU $08 ;Block Segment Pointer [Unused]
|
||||
SYSBFP EQU $1D ;Stack Pointer [Unused]
|
||||
; $1E ;Unused
|
||||
STKLO EQU $2E ;Stack Pointer [Tape Read Work Area]
|
||||
@ -20,13 +17,9 @@ STKHI EQU $2F
|
||||
RANDOM EQU $1F ;Random Number
|
||||
.INVFLG EQU $32 ;*Inverse Flag: $3F=Blinking, $7F=Inverse, $FF=Normal
|
||||
SRCPTR EQU $71 ;Source Pointer [Temporary Register]
|
||||
SRCLO EQU $71
|
||||
SRCHI EQU $72
|
||||
RDSEED EQU $E3 ;Random Seed
|
||||
BLKSLO EQU $EB ;Block Start Address [Unused]
|
||||
BLKSHI EQU $EC
|
||||
BLKELO EQU $ED ;Block End Address [Unused]
|
||||
BLKEHI EQU $EE
|
||||
BLKBGN EQU $EB ;Block Start Address [Unused]
|
||||
BLKEND EQU $ED ;Block End Address [Unused]
|
||||
BLKLEN EQU $EF ;Block Segment Length [Unused]
|
||||
BFRLO EQU $FA ;Work Buffer Pointer [Unused]
|
||||
BFRHI EQU $FB
|
||||
|
@ -7,16 +7,13 @@
|
||||
#define SYSBFL 255 //System Buffer Length
|
||||
|
||||
/* Standard Library Pointers */
|
||||
char srclo,srchi; //Source String Pointer for Library Functions
|
||||
char dstlo,dsthi; //Destination String Pointer for Library Functions
|
||||
zeropage int srcptr, dstptr, bfrptr, blkptr;
|
||||
char bfrlo,bfrhi; //Buffer Pointer for Library Functions
|
||||
char blklo,blkhi; //Block Segment Pointer
|
||||
char stklo,stkhi; //System Pointer
|
||||
|
||||
/* Standard Library Variables */
|
||||
char blkslo, blkshi; //Block Start Address
|
||||
char blkelo, blkehi; //Block End Address
|
||||
char blklen; //Block Segment Length
|
||||
int blkbgn, blkend; //Block Start and End Address
|
||||
char blklen; //Block Segment Length
|
||||
char stkslo, stkshi; //Stack Start Address
|
||||
char stkelo, stkehi; //Stsck End Address
|
||||
char random, rdseed; //Pseudo-Random Number Generation
|
||||
|
113
include/bbc.a02
Normal file
113
include/bbc.a02
Normal file
@ -0,0 +1,113 @@
|
||||
; C02 Program Initialization Code for BBC Micro
|
||||
|
||||
;System Specific ASCII Key Mappings
|
||||
DELKEY EQU $7F ;Delete/Backspace Key ($08=Backspace, $7F=Delete)
|
||||
ESCKEY EQU $1B ;Escape/Stop Key ($03=Ctrl-C, $1B=Escape)
|
||||
RTNKEY EQU $0D ;Return/Enter Key ($0D=Carriage Return)
|
||||
NULKEY EQU $00 ;No Key was Pressed ($00=Null)
|
||||
|
||||
;Zero Page Locations
|
||||
SRCPTR EQU $70 ;Source Pointer
|
||||
DSTPTR EQU $72 ;Destination String Pointer (string.asm)
|
||||
BFRLO EQU $74 ;Buffer Pointer LSB [Temporary String Pointer]
|
||||
BFRHI EQU $75 ;Buffer Pointer MSB [Temporary String Pointer]
|
||||
BLKPTR EQU $76 ;Block Pointer
|
||||
STKLO EQU $78 ;Stack Pointer
|
||||
STKHI EQU $79 ; Unused by OS
|
||||
|
||||
TEMP0 EQU $80 ;Temporary Storage
|
||||
TEMP1 EQU $81
|
||||
TEMP2 EQU $82
|
||||
TEMP3 EQU $83
|
||||
|
||||
BLKBGN EQU $84 ;Block Start Address
|
||||
BLKEND EQU $86 ;Block End Address
|
||||
|
||||
STKSLO EQU $88 ;Stack Start Address
|
||||
STKSHI EQU $89
|
||||
STKELO EQU $8A ;Stack End Address
|
||||
STKEHI EQU $8B
|
||||
|
||||
; EQU $8C ;Unused
|
||||
; EQU $8D ;Unused
|
||||
; EQU $8E ;Unused
|
||||
RANDOM EQU $8F ;Pseudo-RANDOM Number Storage
|
||||
RDSEED EQU $0296 ;System Clock Low Byte
|
||||
|
||||
ORG $1900 ;Program Start Address
|
||||
|
||||
START: JMP MAIN ;Execute Program
|
||||
|
||||
;Exit Program and Return to Operating System or Monitor
|
||||
EXIT: JMP ($FFFC) ;Execute Warm Start
|
||||
|
||||
;Poll Character from Keyboard
|
||||
PLKEY: LDA #$81 ;Set Command to Read Key
|
||||
LDY #0 ;Set Time Limit to 0
|
||||
LDX #0
|
||||
JSR #FFF4 ;Call OSBYTE
|
||||
TYA ;Check Status Code
|
||||
BNE GETCHE ;If Error, Check for Escape
|
||||
TXA ;Else Return Character
|
||||
RTS
|
||||
|
||||
;Read Character from Console
|
||||
GETKEY; ;Usually Drops into RDKEY, but may need to call RDKEY
|
||||
; then clean/convert returned value (e.g. Apple-1)
|
||||
|
||||
;Wait for Character from Keyboard
|
||||
GETCHR: JSR $FFE0 ;Call System Routine OSRDCH
|
||||
BCC GETCHX ;If Error
|
||||
GETCHE: CMP #$1B ;
|
||||
BNE GETCHZ ; If Escape Pressed
|
||||
LDA #$7E ; Acknowledge It
|
||||
JSR $FFF4 ; with OSBYTE Call
|
||||
LDA #$1B ; and Return ESC
|
||||
BNE GETCHX ; Else
|
||||
GETCHZ: LDA #0 ; Return 0
|
||||
GETCHX: RTS
|
||||
|
||||
;Delete Previous Character
|
||||
DELCHR: LDA #$7F ;Print DEL Character
|
||||
JMP PUTCHR
|
||||
|
||||
;Advance Cursor to Next line
|
||||
NEWLIN EQU $FFE7 ;Aliased to System Routine OSNEWL
|
||||
|
||||
;Print Character to Screen
|
||||
PUTCHR: EQU $FFE3 ;Aliased to OSASCI System Routine
|
||||
|
||||
;Clear the Screen
|
||||
CLRSCR: LDA #$0C ;Print FF Character
|
||||
JMP PUTCHR
|
||||
|
||||
;Move Cursor to Specified Coordinates
|
||||
SETPOS: TAX ;Save Column in X
|
||||
LDA #$1F ;Issue Move Cursor Command
|
||||
JSR PUTCHR
|
||||
TXA ;Send X Coordinate
|
||||
JSR PUTCHR
|
||||
TYA ;Send Y Coordinate
|
||||
JMP PUTCHR
|
||||
|
||||
;Get Cursor Position
|
||||
GETPOS: LDA $0318 ;Load Text Cursor X Coordinate
|
||||
LDY #0319 ;Load Text Cursor Y Coordinate
|
||||
RTS
|
||||
|
||||
;Get Screen Size
|
||||
GETSIZ: LDA $030A ;Get Right Side of Text Window
|
||||
SEC
|
||||
SBC $0308 ;Subtract Left Side of Text Window
|
||||
TAX ;Copy to X Register
|
||||
INX ;and Add 1
|
||||
LDA $0309 ;Get Bottom of Text Window
|
||||
SEC
|
||||
SBC $030B ;Subtract Top of Text Window
|
||||
TAY ;Copy to Y Register
|
||||
INY ;and Add 1
|
||||
TXA ;Copy Width to Accumulator
|
||||
RTS ;Return Screen Width in A, Height in Y
|
||||
|
||||
INCLUDE "../include/prbyte.a02" ;PRBYTE and PRHEX routine
|
||||
INCLUDE "../include/putstr.a02" ;PUTSTR routine
|
49
include/bbc.h02
Normal file
49
include/bbc.h02
Normal file
@ -0,0 +1,49 @@
|
||||
/* BBC Micro Header File for C02 Standard Library */
|
||||
|
||||
/* This header contains standardized Constants, *
|
||||
* Variables, and Function Calls tailored to a *
|
||||
* a specific platform. */
|
||||
|
||||
/* System Specific ASCII Key Codes */
|
||||
#define DELKEY $7F //Delete/Backspace Key
|
||||
#define ESCKEY $1B //Escape/Stop Key
|
||||
#define RTNKEY $0D //Return/Enter Key
|
||||
#define NULKEY $00 //No Key was Pressed
|
||||
|
||||
/* Zero Page Variables used as Pointers */
|
||||
zeropage int srcptr, dstptr, bfrptr, blkptr;
|
||||
char bfrlo,bfrhi; //Buffer Pointer for Library Functions
|
||||
char stklo,stkhi; //Stack Pointer
|
||||
|
||||
/* Ephemeral Library Variables *
|
||||
* Available for use in program code, but may *
|
||||
* be obliterated by Function Calls. *
|
||||
* May be Zero Page, but not required */
|
||||
char temp0,temp1,temp2,temp3; //Temporary variables
|
||||
|
||||
/* Static Library Variables *
|
||||
* Must be preserved between function calls *
|
||||
* May be Zero Page, but not required */
|
||||
int blkbgn, blkend; //Block Start and End Address
|
||||
char blklen; //Block Segment Length
|
||||
char stkslo, stkshi; //Stack Start Address
|
||||
char stkelo, stkehi; //Stsck End Address
|
||||
char random; //Last Result of Pseudo-Random Number Generator
|
||||
char rdseed; //System Seed for Pseudo-Random Number Generator
|
||||
|
||||
//System Subroutines
|
||||
void delchr(); //Delete previous character
|
||||
char getkey(); //Read ASCII character from Console
|
||||
char getpos(); //Get Cursor Position
|
||||
char getsiz(); //Get Screen Size
|
||||
void newlin(); //Advance cursor to beginning of next line
|
||||
char polkey(); //Poll Console for character
|
||||
char putchr(); //Print ASCII character to Console
|
||||
void prbyte(); //Print Accumulator as Hexadadecimal number
|
||||
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
|
||||
char getchr(); //Wait for character from Console
|
||||
void setpos(); //Set Cursor Position
|
||||
|
||||
//System Labels
|
||||
start: //Start of Code
|
||||
exit: //Return to Operating System
|
@ -10,13 +10,8 @@ XMBANK EQU $0A ;Extended Memory Bank (Load/Verify Flag)
|
||||
XADRLO EQU $0B ;Ext Memory Address LSB (Text Index/Array Size)
|
||||
XADRHI EQU $0C ;Ext Memory Address MSB (Array Dimension Fkags)
|
||||
SRCPTR EQU $22 ;Source Pointer [Temporary Pointers]
|
||||
SRCLO EQU $22 ;Source Pointer LSB [Temporary Pointers]
|
||||
SRCHI EQU $23 ;Source Pointer MSB [Temporary Pointers]
|
||||
DSTPTR EQU $24 ;Destination Pointer [Temporary Pointers]
|
||||
DSTLO EQU $24 ;Destination Pointer LSB [Temporary Pointers]
|
||||
DSTHI EQU $25 ;Destination Pointer MSB [Temporary Pointers]
|
||||
BLKLO EQU $26 ;Block Pointer LSB [Floating Point Work Area]
|
||||
BLKHI EQU $27 ;Block Pointer MSB [Floating Point Work Area]
|
||||
BLKPTR EQU $26 ;Block Pointer [Floating Point Work Area]
|
||||
STKLO EQU $28 ;Stack Pointer LSB [Floating Point Work Area]
|
||||
STKHI EQU $29 ;Stack Pointer MSB [Floating Point Work Area]
|
||||
BFRLO EQU $35 ;Buffer Pointer LSB [Temporary String Pointer]
|
||||
@ -32,10 +27,8 @@ SYSBFL EQU 88 ;System Buffer Size [88 Bytes]
|
||||
SYSBFR EQU $0200 ;System Buffer [Keyboard Buffer]
|
||||
SYSBFP EQU $0313 ;Position in System Buffer [Free Byte]
|
||||
|
||||
BLKSLO EQU $0334 ;Block Start LSB [Unused Byte]
|
||||
BLKSHI EQU $0335 ;Block Start MSB [Unused Byte]
|
||||
BLKELO EQU $0336 ;Block Start MSB [Unused Byte]
|
||||
BLKEHI EQU $0337 ;Block End MSB [Unused Byte]
|
||||
BLKBGN EQU $0334 ;Block Start [Unused Byte]
|
||||
BLKEND EQU $0336 ;Block Start [Unused Byte]
|
||||
BLKLEN EQU $0338 ;Block Length [Unused Byte]
|
||||
|
||||
RANDOM EQU $0339 ;Random Number Storage [Unused Byte]
|
||||
@ -102,4 +95,5 @@ NEWLIN: LDX #0 ;Store 0
|
||||
PUTSTR: TXA ;Copy LSB to Accumulator
|
||||
JMP $AB1E ;Execute STROUT
|
||||
|
||||
INCLUDE "../include/prbyte.a02" ;PRBYTE and PRHEX routine
|
||||
INCLUDE "prbyte.a02" ;PRBYTE and PRHEX routine
|
||||
|
||||
|
@ -7,16 +7,13 @@
|
||||
#define SYSBFL 88 //System Buffer Length
|
||||
|
||||
/* Standard Library Pointers */
|
||||
char srclo,srchi; //Source String Pointer for Library Functions
|
||||
char dstlo,dsthi; //Destination String Pointer for Library Functions
|
||||
zeropage int srcptr, dstptr, bfrptr, blkptr;
|
||||
char bfrlo,bfrhi; //Buffer Pointer for Library Functions
|
||||
char blklo,blkhi; //Block Segment Pointer
|
||||
char stklo,stkhi; //Stack Pointer
|
||||
|
||||
/* Standard Library Variables */
|
||||
char blkslo, blkshi; //Block Start Address
|
||||
char blkelo, blkehi; //Block End Address
|
||||
char blklen; //Block Segment Length
|
||||
int blkbgn, blkend; //Block Start and End Address
|
||||
char blklen; //Block Segment Length
|
||||
char stkslo, stkshi; //Stack Start Address
|
||||
char stkelo, stkehi; //Stack End Address
|
||||
char random, rdseed; //Pseudo-Random Number Generator
|
||||
|
@ -8,10 +8,8 @@ RTNKEY EQU $0D ;Return/Enter Key ($0D=Carriage Return)
|
||||
NULKEY EQU $00 ;No Key was Pressed ($00=Null)
|
||||
|
||||
;Zero Page Locations
|
||||
SRCLO EQU $00 ;Source String/Array Pointer
|
||||
SRCHI EQU $01
|
||||
DSTLO EQU $02 ;Destination String/Array Pointer
|
||||
DSTHI EQU $03
|
||||
SRCPTR EQU $00 ;Source Pointer
|
||||
DSTPTR EQU $02 ;Destination Pointer
|
||||
BFRLO EQU $04 ;Work Buffer Pointer
|
||||
BFRHI EQU $05
|
||||
|
||||
@ -23,12 +21,10 @@ TEMP1 EQU $11
|
||||
TEMP2 EQU $12
|
||||
TEMP3 EQU $12
|
||||
|
||||
BLKSLO EQU $20 ;Block Start Address
|
||||
BLKSHI EQU $21
|
||||
BLKELO EQU $22 ;Block End Address
|
||||
BLKEHI EQU $23
|
||||
BLKLO EQU $24 ;Block Pointer
|
||||
BLKHI EQU $25
|
||||
BLKBGN EQU $20 ;Block Start Address
|
||||
BLKEND EQU $22 ;Block End Address
|
||||
BLKPTR EQU $24 ;Block Pointer
|
||||
BLKLEN EQY $26 ;Block Segment Length
|
||||
|
||||
STKSLO EQU $28 ;Stack Start Address
|
||||
STKSHI EQU $29
|
||||
@ -81,5 +77,8 @@ NEWLIN: RTS ;Code to move Cursor to beginning of next line
|
||||
;Print Character to Screen
|
||||
PUTCHR RTS ;Code to write ASCII character to Screen
|
||||
|
||||
INCLUDE "../include/prbyte.a02" ;PRBYTE and PRHEX routines
|
||||
|
||||
INCLUDE "prbyte.a02" ;PRBYTE and PRHEX routines
|
||||
INCLUDE "putstr.a02" ;PUTSTR routine
|
||||
|
||||
;System Key Names
|
||||
KNAMES BYTE "DELETE",0,"ESCAPE",0,"RETURN",0
|
||||
|
@ -8,12 +8,10 @@
|
||||
#define DELKEY $7F //Delete/Backspace Key
|
||||
#define ESCKEY $1B //Escape/Stop Key
|
||||
#define RTNKEY $0D //Return/Enter Key
|
||||
#define NULKEY $00 //No Key was Pressed
|
||||
#define SYSBFL 128 //System Buffer Length
|
||||
|
||||
/* Zero Page Variables used as Pointers */
|
||||
char strlo,strhi; //String pointer for String and I/O functions
|
||||
char dstlo,dsthi; //Secondary string pointer for String functions
|
||||
char blklo,blkhi; //Block Segment Pointer
|
||||
zeropage int srcptr, dstptr, bfrptr, blkptr;
|
||||
char stklo,stkhi; //Stack Pointer
|
||||
|
||||
/* Ephemeral Library Variables *
|
||||
@ -25,23 +23,23 @@ char temp0,temp1,temp2,temp3; //Temporary variables
|
||||
/* Static Library Variables *
|
||||
* Must be preserved between function calls *
|
||||
* May be Zero Page, but not required */
|
||||
char blkslo, blkshi; //Block Start Address
|
||||
char blkelo, blkehi; //Block End Address
|
||||
char blklen; //Block Segment Length
|
||||
int blkbgn, blkend; //Block Start and End Address
|
||||
char blklen; //Block Segment Length
|
||||
char stkslo, stkshi; //Stack Start Address
|
||||
char stkelo, stkehi; //Stsck End Address
|
||||
char random; //Last Result of Pseudo-Random Number Generator
|
||||
char rdseed; //System Seed for Pseudo-Random Number Generator
|
||||
char sysbfr[], sysbfp; //System String Buffer and Position
|
||||
|
||||
//System Subroutines
|
||||
void delchr(); //Delete previous character
|
||||
char getchr(); //Wait for character from Console
|
||||
char getkey(); //Read ASCII character from Console
|
||||
void newlin(); //Advance cursor to beginning of next line
|
||||
char polkey(); //Poll Console for character
|
||||
char putchr(); //Print ASCII character to Console
|
||||
void prbyte(); //Print Accumulator as Hexadadecimal number
|
||||
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
|
||||
char getchr(); //Wait for character from Console
|
||||
|
||||
//System Labels
|
||||
start: //Start of Code
|
||||
|
@ -1,7 +1,7 @@
|
||||
; C02 library stdlib.h02 assembly language subroutines
|
||||
; C02 module intlib.h02 assembly language subroutines
|
||||
; Requires
|
||||
; external zero page locations SRCLO and SRCHI
|
||||
; and external locations RANDOM, RDSEED, TEMP0, TEMP1, and TEMP2.
|
||||
; external zero page words DSTPTR and SRCPTR
|
||||
; and external locations TEMP0, TEMP1, TEMP2, and TEMP3
|
||||
|
||||
SUBROUTINE INTLIB
|
||||
|
||||
@ -23,25 +23,25 @@ IABS: CPY #$80 ;If Negative (High Bit Set)
|
||||
|
||||
;imax(i) - Get MAXimum of Two Integers
|
||||
;Args: Y,X = Second Integer
|
||||
;Uses: SRCHI,SRCLO = First Integer
|
||||
;Uses: SRCPTR = First Integer
|
||||
;Affects: N,Z,C
|
||||
;Returns: Y,X = Larger of the Two Arguments
|
||||
IMAX: CPY SRCHI ;If Y < SRCHI
|
||||
BCC .GETSRC ; Return SRCLO, SRCHI
|
||||
CPX SRCLO ;IF X >= SRCLO
|
||||
IMAX: CPY SRCPTR+1 ;If Y < SRCPTR MSB
|
||||
BCC .GETSRC ; Return SRCPTR
|
||||
CPX SRCPTR ;IF X >= SRCPTR LSB
|
||||
BCS .RETURN ; Return Argument
|
||||
.GETSRC JMP GETSRC ;Return Integer in SRCLO, SRCHI
|
||||
.GETSRC JMP GETSRC ;Return Integer in SRCPTR
|
||||
|
||||
;imin(i) - Get MINimum of Two Integers
|
||||
;Args: Y,X = Second Integer
|
||||
;Uses: SRCHI,SRCLO = First Integer
|
||||
;Uses: SRCPTR = First Integer
|
||||
;Affects: N,Z,C
|
||||
;Returns: Y,X = Larger of the Two Arguments
|
||||
IMIN: CPY SRCHI ;If Y < SRCHI
|
||||
IMIN: CPY SRCPTR+1 ;If Y < SRCPTR+1
|
||||
BCC .RETURN ; Return Argument
|
||||
BNE .GETSRC ;If Y > SRCHI Return SRCHI,SRCLO
|
||||
CPX SRCLO ;If X >= SRCLO
|
||||
BCS .GETSRC ; Return SRCHI,SRCLO
|
||||
BNE .GETSRC ;If Y > SRCPTR+1 Return SRCPTR
|
||||
CPX SRCPTR ;If X >= SRCPTR
|
||||
BCS .GETSRC ; Return SRCPTR
|
||||
RTS ;Return Argument
|
||||
|
||||
;iaddc(c,i) - Add Byte c to Integer i
|
||||
@ -58,10 +58,10 @@ IADDC: JSR SETSRC ;Save Integer and Clear Y
|
||||
; N = Sign of Result
|
||||
IADD: CLC ;Clear Carry for Addition
|
||||
TXA ;Add Addend LSB
|
||||
ADC SRCLO ;to Augend LSB
|
||||
ADC SRCPTR ;to Augend LSB
|
||||
TAX ;and Copy to X
|
||||
TYA ;Add Addend MSB
|
||||
ADC SRCHI ;to Augebd MSB
|
||||
ADC SRCPTR+1 ;to Augebd MSB
|
||||
TAY ;and Copy to Y
|
||||
LDA #0 ;Set Overflow to 0
|
||||
ROL ; Rotate Carry (Same as Adding it)
|
||||
@ -77,10 +77,10 @@ IADD: CLC ;Clear Carry for Addition
|
||||
; N = Sign of Result
|
||||
ISUB: JSR SAVRXY ;Store Subtrahend in TEMP1,TEMP2
|
||||
SEC ;Set Carry for Subtraction
|
||||
LDA SRCLO ;Load Minuend LSB
|
||||
LDA SRCPTR ;Load Minuend LSB
|
||||
SBC TEMP1 ;Subtract Subtrahend LSB
|
||||
TAX ;Copy Difference LSB to X
|
||||
LDA SRCHI ;Load Minuend MSB
|
||||
LDA SRCPTR+1 ;Load Minuend MSB
|
||||
SBC TEMP2 ;Subtract Subtrahend MSB
|
||||
TAY ;Copy Difference MSB to Y
|
||||
LDA #0 ;Set Overflow Byte to 0
|
||||
@ -204,7 +204,7 @@ ISHFTR: JSR SAVRXY ;Save X,Y in TEMP1,TEMP2
|
||||
ATOI: JSR SETSRC ;Initialize Source String
|
||||
STY TEMP1 ;Initialize Result
|
||||
STY TEMP2
|
||||
.AILOOP LDA (SRCLO),Y ;Get Next Character
|
||||
.AILOOP LDA (SRCPTR),Y ;Get Next Character
|
||||
CMP #$30 ;If Less Than '0'
|
||||
BCC .AIDONE ; Exit
|
||||
CMP #$3A ;If Greater Than '9'
|
||||
@ -239,7 +239,7 @@ ATOI: JSR SETSRC ;Initialize Source String
|
||||
|
||||
;itoa(n) - Integer TO ASCII string
|
||||
;Args: Y,X = Integer Value to Convert
|
||||
;Uses: DSTHI,DSTLO = Destination String
|
||||
;Uses: DSTPTR = Destination String
|
||||
;Affects: X
|
||||
;Returns: A,Y = Length of String
|
||||
ITOA: JSR CVIBCD ;Convert Integer to Packed BCD
|
||||
@ -258,14 +258,14 @@ ITOA: JSR CVIBCD ;Convert Integer to Packed BCD
|
||||
TXA ;and Restore Digit
|
||||
LDY TEMP3 ;Get Index into String
|
||||
ORA #$30 ;Convert Digit to ASCII
|
||||
STA (DSTLO),Y ;and Store in String
|
||||
STA (DSTPTR),Y ;and Store in String
|
||||
INC TEMP3 ;Increment Index into String
|
||||
PLA ;Pull Digit Number off Stack
|
||||
TAY
|
||||
DEY ;Decrement Digit Number
|
||||
BPL .IALOOP ;Loop if >= Zero
|
||||
LDA #0 ;Terminate String
|
||||
STA (DSTLO),Y
|
||||
STA (DSTPTR),Y
|
||||
TYA ;Return String Length
|
||||
RTS
|
||||
|
||||
|
95
include/kowalski.a02
Normal file
95
include/kowalski.a02
Normal file
@ -0,0 +1,95 @@
|
||||
; Program initialization code for C02 programs
|
||||
; Template for System Specific Code
|
||||
|
||||
ORG $0400 ;Program Start Address
|
||||
|
||||
;System Specific ASCII Key Mappings
|
||||
DELKEY EQU $08 ;Delete/Backspace Key (Backspace)
|
||||
ESCKEY EQU $1B ;Escape/Stop Key (Escape)
|
||||
RTNKEY EQU $0D ;Return/Enter Key (Carriage Return)
|
||||
NULKEY EQU $00 ;No Key was Pressed (Null)
|
||||
|
||||
;Zero Page Locations
|
||||
SRCPTR EQU $10
|
||||
DSTPTR EQU $12
|
||||
BFRLO EQU $14 ;Work Buffer Pointer
|
||||
BFRHI EQU $15
|
||||
|
||||
STKSAV EQU $1D ;Stack Pointer Storage
|
||||
RDSEED EQU $1E ;Pseudo-RANDOM Seed
|
||||
RANDOM EQU $1F ;Pseudo-RANDOM Number Storage
|
||||
|
||||
TEMP0 EQU $20 ;Temporary Storage
|
||||
TEMP1 EQU $21
|
||||
TEMP2 EQU $22
|
||||
TEMP3 EQU $22
|
||||
|
||||
BLKBGN EQU $30 ;Block Start Address
|
||||
BLKEND EQU $32 ;Block End Address
|
||||
BLKPTR EQU $34 ;Block Pointer
|
||||
BLKLEN EQU $36 ;Block Segment Length
|
||||
|
||||
STKSLO EQU $48 ;Stack Start Address
|
||||
STKSHI EQU $49
|
||||
STKELO EQU $4A ;Stack End Address
|
||||
STKEHI EQU $4B
|
||||
STKLO EQU $4C ;Stack Pointer
|
||||
STKHI EQU $4D
|
||||
|
||||
;Memory Mapped I/O
|
||||
IOBASE EQU $E000
|
||||
IOINIT EQU IOBASE+0 ;Clear Terminal Window
|
||||
IOPUTC EQU IOBASE+1 ;Put Character
|
||||
IOPUTR EQU IOBASE+2 ;Put Raw Character
|
||||
IOPUTH EQU IOBASE+3 ;Put as Hexadecimal Number
|
||||
IOGETC EQU IOBASE+4 ;Get Character
|
||||
IOPOSX EQU IOBASE+5 ;Set Cursor X Position
|
||||
IOPOSY EQU IOBASE+6 ;Set Cursor Y Position
|
||||
|
||||
START: LDX #$FF ;Initialize Stack Pointer
|
||||
TXS ;
|
||||
STX IOINIT ;Clear Screen
|
||||
JMP MAIN ;Execute Program
|
||||
|
||||
;Exit Program and Return to Monitor
|
||||
EXIT: BRK ;Halt Debugger
|
||||
|
||||
;Read Character from Console
|
||||
GETKEY EQU $FFE0 ;Emulator CHRIN Routine
|
||||
|
||||
;Poll Character from Keyboard
|
||||
POLKEY: INC RDSEED ;Cycle the Random Seed
|
||||
LDA IOGETC ;Code Read from Keyboard
|
||||
RTS
|
||||
|
||||
;Wait for Character from Console
|
||||
GETCHR: JSR POLKEY ;Usually calls PLKEY
|
||||
BEQ GETCHR ; until a non-zero is returned
|
||||
RTS
|
||||
|
||||
;Delete Previous Character
|
||||
DELCHR: LDA #$08 ;Load Backspace into Accumulator
|
||||
JMP PUTCHR ; and Print it
|
||||
|
||||
;Advance Character to Next line
|
||||
NEWLIN: LDA #$0D ;Load Carriage Return
|
||||
JSR PUTCHR ;And Print It
|
||||
LDA #$0A ;Load Line Feed
|
||||
|
||||
;Print Character to Console
|
||||
PUTCHR: STA IOPUTC ;Write Character to Screen
|
||||
RTS
|
||||
|
||||
;Print Hexadecimal Digit
|
||||
PRHEX: AND #$0F
|
||||
ORA #'0'
|
||||
BNE PUTCHR
|
||||
|
||||
;Print Hexadecimal Byte
|
||||
PRBYTE: STA IOPUTH ;Put as Hexadecimal Number
|
||||
RTS
|
||||
|
||||
INCLUDE "putstr.a02" ;PUTSTR routine
|
||||
|
||||
|
||||
|
45
include/kowalski.h02
Normal file
45
include/kowalski.h02
Normal file
@ -0,0 +1,45 @@
|
||||
/* System Specific C02 Header File Template */
|
||||
|
||||
/* This header contains standardized Constants, *
|
||||
* Variables, and Function Calls tailored to a *
|
||||
* a specific platform. */
|
||||
|
||||
/* System Specific ASCII Key Codes */
|
||||
#define DELKEY $7F //Delete/Backspace Key
|
||||
#define ESCKEY $1B //Escape/Stop Key
|
||||
#define RTNKEY $0D //Return/Enter Key
|
||||
#define NULKEY $00 //No Key was Pressed
|
||||
|
||||
/* Zero Page Variables used as Pointers */
|
||||
zeropage int srcptr, dstptr, bfrptr, blkptr;
|
||||
char stklo,stkhi; //Stack Pointer
|
||||
|
||||
/* Ephemeral Library Variables *
|
||||
* Available for use in program code, but may *
|
||||
* be obliterated by Function Calls. *
|
||||
* May be Zero Page, but not required */
|
||||
char temp0,temp1,temp2,temp3; //Temporary variables
|
||||
|
||||
/* Static Library Variables *
|
||||
* Must be preserved between function calls *
|
||||
* May be Zero Page, but not required */
|
||||
int blkbgn, blkend; //Block Start and End Address
|
||||
char blklen; //Block Segment Length
|
||||
char stkslo, stkshi; //Stack Start Address
|
||||
char stkelo, stkehi; //Stsck End Address
|
||||
char random; //Last Result of Pseudo-Random Number Generator
|
||||
char rdseed; //System Seed for Pseudo-Random Number Generator
|
||||
|
||||
//System Subroutines
|
||||
void delchr(); //Delete previous character
|
||||
char getkey(); //Read ASCII character from Console
|
||||
void newlin(); //Advance cursor to beginning of next line
|
||||
char polkey(); //Poll Console for character
|
||||
char putchr(); //Print ASCII character to Console
|
||||
void prbyte(); //Print Accumulator as Hexadadecimal number
|
||||
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
|
||||
char getchr(); //Wait for character from Console
|
||||
|
||||
//System Labels
|
||||
start: //Start of Code
|
||||
exit: //Return to Operating System
|
78
include/orao.a02
Normal file
78
include/orao.a02
Normal file
@ -0,0 +1,78 @@
|
||||
; Orao Program Initialization Code for C02 programs
|
||||
|
||||
;System Specific ASCII Key Mappings
|
||||
DELKEY EQU $1F ;Left Arrow
|
||||
ESCKEY EQU $03 ;Ctrl-C
|
||||
RTNKEY EQU $0D ;Carriage Return
|
||||
NULKEY EQU $00 ;Null
|
||||
|
||||
;Zero Page Locations
|
||||
SRCLO EQU $30 ;Source String/Array Pointer
|
||||
SRCHI EQU $31
|
||||
DSTLO EQU $32 ;Destination String/Array Pointer
|
||||
DSTHI EQU $33
|
||||
BFRLO EQU $34 ;Work Buffer Pointer
|
||||
BFRHI EQU $35
|
||||
|
||||
STKSAV EQU $36 ;Stack Pointer Storage
|
||||
RDSEED EQU $37 ;Pseudo-RANDOM Seed
|
||||
RANDOM EQU $38 ;Pseudo-RANDOM Number Storage
|
||||
TEMP0 EQU $3A ;Temporary Storage
|
||||
TEMP1 EQU $3B
|
||||
TEMP2 EQU $3C
|
||||
TEMP3 EQU $3D
|
||||
|
||||
BLKBGN EQU $40 ;Block Start Address
|
||||
BLKEND EQU $42 ;Block End Address
|
||||
BLKPTR EQU $44 ;Block Pointer
|
||||
BLKLEN EQU $46 ;Block Segment Length
|
||||
|
||||
STKSLO EQU $48 ;Stack Start Address
|
||||
STKSHI EQU $49
|
||||
STKELO EQU $4A ;Stack End Address
|
||||
STKEHI EQU $4B
|
||||
STKLO EQU $4C ;Stack Pointer
|
||||
STKHI EQU $4D
|
||||
|
||||
ORG $1000 ;Program Start Address
|
||||
|
||||
START: TSX ;Save Stack Pointer
|
||||
STX STKSAV
|
||||
JMP MAIN ;Execute Program
|
||||
|
||||
|
||||
;Exit Program and Return to Operating System or Monitor
|
||||
EXIT LDX STKSAV ;Restore Stack Pointer
|
||||
TXS
|
||||
RTS ;and Return to Caller
|
||||
|
||||
RESET EQU $FFA3 ;Alias to WARMST (Monitor)
|
||||
|
||||
;Poll Character from Keyboard
|
||||
POLKEY: JSR $E5B0 ;Scan Keyboard
|
||||
BCC POLKEX ;If No Key Pressed
|
||||
LDA #NULKEY ;Return NUL
|
||||
POLKEX: RTS
|
||||
|
||||
;Read Character from Console
|
||||
GETKEY EQU $E500 ;Alias to INCHR function
|
||||
|
||||
;Wait for Character from Console
|
||||
GETCHR EQU GETKEY ;Alias to GETKEY
|
||||
|
||||
;Print Character to Screen
|
||||
PUTCHR EQU $E762 ;Alias to OUTCH Routine
|
||||
|
||||
;Delete Previous Character
|
||||
DELCHR EQU $F1F2 ;Alias to BCKSPC Routine
|
||||
|
||||
;Advance Cursor to Next line
|
||||
NEWLIN EQU $E7F6 ;Aliased to CRLF Routine
|
||||
|
||||
;Print Byte as Two-Digit Hex Number to Console
|
||||
PRBYTE EQU $E803
|
||||
|
||||
;Print Low Nybble as Hex Digit to Console
|
||||
PRHEX EQU $E80F
|
||||
|
||||
INCLUDE "../include/putstr.a02" ;PUTSTR Routine
|
48
include/orao.h02
Normal file
48
include/orao.h02
Normal file
@ -0,0 +1,48 @@
|
||||
/* Orao C02 Header File Template */
|
||||
|
||||
/* This header contains standardized Constants, *
|
||||
* Variables, and Function Calls tailored to a *
|
||||
* a specific platform. */
|
||||
|
||||
/* System Specific ASCII Key Codes */
|
||||
#define DELKEY $1F //Delete/Backspace Key
|
||||
#define ESCKEY $03 //Escape/Stop Key
|
||||
#define RTNKEY $0D //Return/Enter Key
|
||||
#define NULKEY $00 //No Key was Pressed
|
||||
|
||||
/* Zero Page Variables used as Pointers */
|
||||
zeropage int srcptr, dstptr, bfrptr, blkptr;
|
||||
char stklo,stkhi; //Stack Pointer
|
||||
|
||||
/* Ephemeral Library Variables *
|
||||
* Available for use in program code, but may *
|
||||
* be obliterated by Function Calls. *
|
||||
* May be Zero Page, but not required */
|
||||
char temp0,temp1,temp2,temp3; //Temporary variables
|
||||
|
||||
/* Static Library Variables *
|
||||
* Must be preserved between function calls *
|
||||
* May be Zero Page, but not required */
|
||||
int blkbgn, blkend; //Block Start and End Address
|
||||
char blklen; //Block Segment Length
|
||||
char stkslo, stkshi; //Stack Start Address
|
||||
char stkelo, stkehi; //Stsck End Address
|
||||
char random; //Last Result of Pseudo-Random Number Generator
|
||||
char rdseed; //System Seed for Pseudo-Random Number Generator
|
||||
|
||||
//System Subroutines
|
||||
void delchr(); //Delete previous character
|
||||
char getkey(); //Read ASCII character from Console
|
||||
char getpos(); //Get Cursor Position
|
||||
char getsiz(); //Get Screen Size
|
||||
void newlin(); //Advance cursor to beginning of next line
|
||||
char polkey(); //Poll Console for character
|
||||
char putchr(); //Print ASCII character to Console
|
||||
void prbyte(); //Print Accumulator as Hexadadecimal number
|
||||
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
|
||||
char getchr(); //Wait for character from Console
|
||||
void setpos(); //Set Cursor Position
|
||||
|
||||
//System Labels
|
||||
start: //Start of Code
|
||||
exit: //Return to Operating System
|
@ -6,14 +6,11 @@ ESCKEY EQU $1B ;Escape/Stop Key (Escape)
|
||||
RTNKEY EQU $0D ;Return/Enter Key (Carriage Return)
|
||||
|
||||
;Zero Page Locations
|
||||
SRCLO EQU $30 ;Source String Pointer (stdio.a02)
|
||||
SRCHI EQU $31
|
||||
DSTLO EQU $32 ;Destination String Pointer (string.a02)
|
||||
DSTHI EQU $33
|
||||
SRCPTR EQU $30 ;Source Pointer
|
||||
DSTPTR EQU $32 ;Destination Pointer
|
||||
BFRLO EQU $34 ;Work Buffer Pointer
|
||||
BFRHI EQU $35
|
||||
BLKLO EQU $36 ;Block Segment Pointer (block.a02)
|
||||
BLKHI EQU $37
|
||||
BLKPTR EQU $36 ;Block Segment Pointer (block.a02)
|
||||
STKLO EQU $38 ;Stack Pointer (stack.a02)
|
||||
STKHI EQU $39
|
||||
|
||||
@ -25,10 +22,8 @@ TEMP1 EQU $41
|
||||
TEMP2 EQU $42
|
||||
TEMP3 EQU $43
|
||||
|
||||
BLKSLO EQU $46 ;Block Start Address
|
||||
BLKSHI EQU $47
|
||||
BLKELO EQU $48 ;Block End Address
|
||||
BLKEHI EQU $49
|
||||
BLKBGN EQU $46 ;Block Start Address
|
||||
BLKEND EQU $48 ;Block End Address
|
||||
BLKLEN EQU $4A ;Block Segment Length
|
||||
|
||||
STKSLO EQU $4C ;Stack Start Address
|
||||
|
@ -6,16 +6,13 @@
|
||||
#define RTNKEY $0D //Return/Enter Key
|
||||
|
||||
//Library Pointer Variables
|
||||
char srclo,srchi; //Source String Pointer for Library Functions
|
||||
char dstlo,dsthi; //Destination String Pointer for Library Functions
|
||||
zeropage int srcptr, dstptr, bfrptr, blkptr;
|
||||
char bfrlo,bfrhi; //Buffer Pointer for Library Functions
|
||||
char blklo,blkhi; //Block Segment Pointer
|
||||
char stklo,stkhi; //Stack Pointer
|
||||
|
||||
//Library Variables
|
||||
char blkslo, blkshi; //Block Start Address
|
||||
char blkelo, blkehi; //Block End Address
|
||||
char blklen; //Block Segment Length
|
||||
int blkbgn, blkend; //Block Start and End Address
|
||||
char blklen; //Block Segment Length
|
||||
char stkslo, stkshi; //Stack Start Address
|
||||
char stkelo, stkehi; //Stsck End Address
|
||||
char random, rdseed; //Pseudo-Random Number Generation
|
||||
|
@ -6,12 +6,11 @@ ESCKEY EQU $1B ;Escape/Stop Key (Escape)
|
||||
RTNKEY EQU $0D ;Return/Enter Key (Carriage Return)
|
||||
|
||||
;Zero Page Locations
|
||||
SRCLO EQU $30 ;Source String Pointer (stdio.a02)
|
||||
SRCHI EQU $31
|
||||
DSTLO EQU $32 ;Destination String Pointer (string.a02)
|
||||
DSTHI EQU $33
|
||||
BLKLO EQU $34 ;Block Segment Pointer (block.a02)
|
||||
BLKHI EQU $35
|
||||
SRCPTR EQU $30 ;Source Pointer
|
||||
DSTPTR EQU $32 ;Destination Pointer
|
||||
BFRLO EQU $34 ;Work Buffer Pointer
|
||||
BFRHI EQU $35
|
||||
BLKPTR EQU $36 ;Block Segment Pointer (block.a02)
|
||||
STKLO EQU $36 ;Stack Pointer (stack.a02)
|
||||
STKHI EQU $37
|
||||
|
||||
@ -23,10 +22,8 @@ TEMP1 EQU $41
|
||||
TEMP2 EQU $42
|
||||
TEMP3 EQU $43
|
||||
|
||||
BLKSLO EQU $46 ;Block Start Address
|
||||
BLKSHI EQU $47
|
||||
BLKELO EQU $48 ;Block End Address
|
||||
BLKEHI EQU $49
|
||||
BLKBGN EQU $46 ;Block Start Address
|
||||
BLKEND EQU $48 ;Block End Address
|
||||
BLKLEN EQU $4A ;Block Segment Length
|
||||
|
||||
STKSLO EQU $4C ;Stack Start Address
|
||||
|
@ -3,21 +3,15 @@
|
||||
;System Specific ASCII Key Mappings
|
||||
DELKEY EQU $08 ;Delete/Backspace Key (Backspace)
|
||||
ESCKEY EQU $18 ;Escape/Stop Key (Control-X)
|
||||
RTNKEY EQU $0A ;Return/Enter Key (Line Feed)
|
||||
RTNKEY EQU $0D ;Return/Enter Key (Carriage Return)
|
||||
|
||||
;Zero Page Locations
|
||||
SRCPTR EQU $30 ;Source String Pointer (stdio.a02)
|
||||
SRCLO EQU $30
|
||||
SRCHI EQU $31
|
||||
DSTPTR EQU $32 ;Destination String Pointer (string.a02)
|
||||
DSTLO EQU $32
|
||||
DSTHI EQU $33
|
||||
BFRPTR EQU $34 ;Work Buffer Pointer
|
||||
BFRLO EQU $34
|
||||
BFRHI EQU $35
|
||||
BLKPTR EQU $36 ;Block Segment Pointer (block.a02)
|
||||
BLKLO EQU $36
|
||||
BLKHI EQU $37
|
||||
STKLO EQU $38 ;Stack Pointer (stack.a02)
|
||||
STKHI EQU $39
|
||||
|
||||
@ -29,10 +23,8 @@ TEMP1 EQU $41
|
||||
TEMP2 EQU $42
|
||||
TEMP3 EQU $43
|
||||
|
||||
BLKSLO EQU $46 ;Block Start Address
|
||||
BLKSHI EQU $47
|
||||
BLKELO EQU $48 ;Block End Address
|
||||
BLKEHI EQU $49
|
||||
BLKBGN EQU $46
|
||||
BLKEND EQU $48
|
||||
BLKLEN EQU $4A ;Block Segment Length
|
||||
|
||||
STKSLO EQU $4C ;Stack Start Address
|
||||
@ -55,38 +47,50 @@ _GETCH EQU $FFF1 ;Read Keyboard (Blocking)
|
||||
START: JMP MAIN ;Execute Program
|
||||
|
||||
;Read Character from Console
|
||||
GETKEY EQU $FFE0 ;Emulator CHRIN Routine
|
||||
GETKEY EQU $FFE0 ;Emulator _GETCH Routine
|
||||
|
||||
;Poll Character from Keyboard
|
||||
POLKEY: BRK ;Exit Emulator
|
||||
|
||||
|
||||
;Wait for Character from Console
|
||||
GETCHR: JSR GETKEY ;Read Character from STDIN
|
||||
GETCHR: JSR GETKEY ;Get Key from Console
|
||||
BEQ GETCHR ;If None Pressed, Loop
|
||||
RTS
|
||||
|
||||
;Read Character from stdin
|
||||
RDCHAR: LDA $FFEA ;Read Character from STDIN
|
||||
CMP #$FF ;If EOF
|
||||
BNE GETCHX
|
||||
LDA #ESCKEY ; Set to Escape Character
|
||||
GETCHX: ORA 0 ;Set Zero Flag
|
||||
BNE RDCHAX
|
||||
LDA #0 ; Set to ASCII NUL
|
||||
RDCHAX ORA #0 ;Set Flags
|
||||
RTS
|
||||
|
||||
;Delete Previous Character
|
||||
DELCHR: LDA #$08 ;Load Backspace into Accumulator
|
||||
JSR PUTCHR ; and Print it
|
||||
LDA #$20 ;Load Space into Accumulater
|
||||
LDA #$20 ;Load Space into Accumulator
|
||||
JSR PUTCHR ; and Print it
|
||||
LDA #$08 ;Load Backspace into Accumulator
|
||||
JMP PUTCHR ; and Print it
|
||||
|
||||
;Advance Character to Next line
|
||||
NEWLIN: LDA #RTNKEY ;Load Line Feed into Accumulater
|
||||
NEWLIN: LDA #$0D ;Load Carriage Return into Accumulator
|
||||
JSR PUTCHR ; and Print it
|
||||
LDA #$0A ;Load Line Feed into Accumulator
|
||||
JMP PUTCHR ; and Print it
|
||||
|
||||
;Print Character to Console
|
||||
PUTCHR EQU $FFE3 ;Emulator CHROUT Routine
|
||||
|
||||
;Write Character to stdout
|
||||
PRCHAR: STA $FFEA ;Read Character from STDIN
|
||||
RTS
|
||||
|
||||
EXIT EQU $FFEC ;Emulator SHUTDN Routine
|
||||
|
||||
FSCMD EQU $FFE6 ;run6502 File System Command Routine
|
||||
|
||||
INCLUDE "../include/prbyte.a02" ;PRBYTE and PRHEX routines
|
||||
INCLUDE "../include/putstr.a02" ;PUTSTR routine
|
||||
INCLUDE "prbyte.a02" ;PRBYTE and PRHEX routines
|
||||
INCLUDE "putstr.a02" ;PUTSTR routine
|
||||
|
||||
|
@ -3,19 +3,20 @@
|
||||
//Platform Specific Constants
|
||||
#define DELKEY $08 //Delete/Backspace Key
|
||||
#define ESCKEY $18 //Escape/Stop Key
|
||||
#define RTNKEY $0D //Return/Enter Key
|
||||
#define RTNKEY $0A //Return/Enter Key
|
||||
#define SYSBFL 128 //System Buffer Length
|
||||
|
||||
const char delnam; //Delete/Backspace Key Name
|
||||
const char escnam; //Escape/Stop Key Name
|
||||
const char rtnnam; //Return/Enter Key Name
|
||||
|
||||
//Library Pointer Variables
|
||||
zeropage int srcptr, dstptr, bfrptr, blkptr;
|
||||
char srclo,srchi; //Source String Pointer for Library Functions
|
||||
char dstlo,dsthi; //Destination String Pointer for Library Functions
|
||||
char bfrlo,bfrhi; //Buffer Pointer for Library Functions
|
||||
char blklo,blkhi; //Block Segment Pointer
|
||||
char stklo,stkhi; //Stack Pointer
|
||||
|
||||
//Library Variables
|
||||
char blkslo, blkshi; //Block Start Address
|
||||
char blkelo, blkehi; //Block End Address
|
||||
int blkbgn, blkend;
|
||||
char blklen; //Block Segment Length
|
||||
char stkslo, stkshi; //Stack Start Address
|
||||
char stkelo, stkehi; //Stsck End Address
|
||||
@ -28,11 +29,11 @@ char putcon; //Write Character to Console
|
||||
char getcon; //Read Character from Console
|
||||
|
||||
//System Subroutines
|
||||
char polkey(); //Poll Console for character (Exits Emulator)
|
||||
void delchr(); //Delete previous character
|
||||
char getchr(); //Wait for character from Console
|
||||
char getkey(); //Read ASCII character from Console (Exits Emulator)
|
||||
void newlin(); //Advance cursor to beginning of next line
|
||||
void delchr(); //Delete previous character
|
||||
char polkey(); //Poll Console for character (Exits Emulator)
|
||||
char putchr(); //Print ASCII character to Console
|
||||
void prbyte(); //Print Accumulator as Hexadadecimal number
|
||||
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
|
||||
@ -40,4 +41,3 @@ void prhex(); //Print Low Nybble of Accumulator as Hex Digit
|
||||
//System Labels
|
||||
start: //Start of Code
|
||||
exit: //Return to Operating System
|
||||
|
||||
|
@ -295,7 +295,7 @@ PRINTF: STA TEMP3 ;Save Byte to Format
|
||||
TYA ;Save Index
|
||||
PHA
|
||||
TXA ;Restore Specifier
|
||||
JSR GETDST ;Get Integer in DSTLO, DSTHI
|
||||
JSR GETDST ;Get Integer in DSTPTR
|
||||
CMP #'I' ;If 'i' or 'I'
|
||||
BNE .FDESTJ
|
||||
JSR PUTINT ; Print Integer Right Justified
|
||||
@ -319,7 +319,7 @@ PRINTF: STA TEMP3 ;Save Byte to Format
|
||||
|
||||
;char putdst()
|
||||
PUTDST LDY #0 ;Initialize character offset
|
||||
.DLOOP LDA (DSTLO),Y ;Read next character in string
|
||||
.DLOOP LDA (DSTPTR),Y ;Read next character in string
|
||||
BEQ .DRETY ;If Not 0
|
||||
JSR PUTC ; Print character at offset,
|
||||
INY ; increment offset, and
|
||||
|
@ -6,14 +6,9 @@ ESCKEY EQU $03 ;Escape/Stop Key (RUN/STOP)
|
||||
RTNKEY EQU $0D ;Return/Enter Key (RETURN)
|
||||
|
||||
;Zero Page Locations
|
||||
SRCPTR EQU $22 ;Source Pointer LSB [Temporary Pointers]
|
||||
SRCLO EQU $22 ;Source Pointer LSB [Temporary Pointers]
|
||||
SRCHI EQU $23 ;Source Pointer MSB [Temporary Pointers]
|
||||
DSTPTR EQU $24 ;Destination Pointer LSB [Temporary Pointers]
|
||||
DSTLO EQU $24 ;Destination Pointer LSB [Temporary Pointers]
|
||||
DSTHI EQU $25 ;Destination Pointer MSB [Temporary Pointers]
|
||||
BLKLO EQU $26 ;Block Pointer LSB [Floating Point Work Area]
|
||||
BLKHI EQU $27 ;Block Pointer MSB [Floating Point Work Area]
|
||||
SRCPTR EQU $22 ;Source Pointer [Temporary Pointers]
|
||||
DSTPTR EQU $24 ;Destination Pointer [Temporary Pointers]
|
||||
BLKPTR EQU $26 ;Block Pointer [Floating Point Work Area]
|
||||
STKLO EQU $28 ;Stack Pointer LSB [Floating Point Work Area]
|
||||
STKHI EQU $29 ;Stack Pointer MSB [Floating Point Work Area]
|
||||
BFRLO EQU $35 ;Buffer Pointer LSB [Temporary String Pointer]
|
||||
@ -32,10 +27,8 @@ USER1 EQU $0311 ;Free Byte for User Programs
|
||||
USER2 EQU $0312 ;Free Byte for User Programs
|
||||
SYSBFP EQU $0313 ;Position in System Buffer [Free Byte]
|
||||
|
||||
BLKSLO EQU $0334 ;Block Start LSB [Unused Byte]
|
||||
BLKSHI EQU $0335 ;Block Start MSB [Unused Byte]
|
||||
BLKELO EQU $0336 ;Block Start MSB [Unused Byte]
|
||||
BLKEHI EQU $0337 ;Block End MSB [Unused Byte]
|
||||
BLKBGN EQU $0334 ;Block Start [Unused Byte]
|
||||
BLKEND EQU $0336 ;Block Start [Unused Byte]
|
||||
BLKLEN EQU $0338 ;Block Length [Unused Byte]
|
||||
|
||||
RANDOM EQU $0339 ;Random Number Storage [Unused Byte]
|
||||
|
@ -7,16 +7,13 @@
|
||||
#define SYSBFL 88 //System Buffer Length
|
||||
|
||||
/* Standard Library Pointers */
|
||||
char srclo,srchi; //Source String Pointer for Library Functions
|
||||
char dstlo,dsthi; //Destination String Pointer for Library Functions
|
||||
zeropage int srcptr, dstptr, bfrptr, blkptr;
|
||||
char bfrlo,bfrhi; //Buffer Pointer for Library Functions
|
||||
char blklo,blkhi; //Block Segment Pointer
|
||||
char stklo,stkhi; //Stack Pointer
|
||||
|
||||
/* Standard Library Variables */
|
||||
char blkslo, blkshi; //Block Start Address
|
||||
char blkelo, blkehi; //Block End Address
|
||||
char blklen; //Block Segment Length
|
||||
int blkbgn, blkend; //Block Start and End Address
|
||||
char blklen; //Block Segment Length
|
||||
char stkslo, stkshi; //Stack Start Address
|
||||
char stkelo, stkehi; //Stsck End Address
|
||||
char random, rdseed; //Pseudo-Random Number Generation
|
||||
|
@ -8,16 +8,14 @@
|
||||
#define RTNKEY $0D //Return/Enter Key (RETURN)
|
||||
#define SYSBFL 88 //System Buffer Length
|
||||
|
||||
//Library Pointer Variables
|
||||
char srclo,srchi; //Source String Pointer for Library Functions
|
||||
char dstlo,dsthi; //Destination String Pointer for Library Functions
|
||||
char blklo,blkhi; //Block Segment Pointer
|
||||
/* Standard Library Pointers */
|
||||
zeropage int srcptr, dstptr, bfrptr, blkptr;
|
||||
char bfrlo,bfrhi; //Buffer Pointer for Library Functions
|
||||
char stklo,stkhi; //Stack Pointer
|
||||
|
||||
//Library Variables
|
||||
char blkslo, blkshi; //Block Start Address
|
||||
char blkelo, blkehi; //Block End Address
|
||||
char blklen; //Block Segment Length
|
||||
/* Standard Library Variables */
|
||||
int blkbgn, blkend; //Block Start and End Address
|
||||
char blklen; //Block Segment Length
|
||||
char stkslo, stkshi; //Stack Start Address
|
||||
char stkelo, stkehi; //Stsck End Address
|
||||
char random, rdseed; //Pseudo-Random Number Generation
|
||||
|
@ -8,16 +8,14 @@
|
||||
#define RTNKEY $0D //Return/Enter Key (RETURN)
|
||||
#define SYSBFL 88 //System Buffer Length
|
||||
|
||||
//Library Pointer Variables
|
||||
char srclo,srchi; //Source String Pointer for Library Functions
|
||||
char dstlo,dsthi; //Destination String Pointer for Library Functions
|
||||
char blklo,blkhi; //Block Segment Pointer
|
||||
/* Standard Library Pointers */
|
||||
zeropage int srcptr, dstptr, bfrptr, blkptr;
|
||||
char bfrlo,bfrhi; //Buffer Pointer for Library Functions
|
||||
char stklo,stkhi; //Stack Pointer
|
||||
|
||||
//Library Variables
|
||||
char blkslo, blkshi; //Block Start Address
|
||||
char blkelo, blkehi; //Block End Address
|
||||
char blklen; //Block Segment Length
|
||||
/* Standard Library Variables */
|
||||
int blkbgn, blkend; //Block Start and End Address
|
||||
char blklen; //Block Segment Length
|
||||
char stkslo, stkshi; //Stack Start Address
|
||||
char stkelo, stkehi; //Stsck End Address
|
||||
char random, rdseed; //Pseudo-Random Number Generation
|
||||
|
@ -13,13 +13,8 @@ XMBANK EQU $53 ;Extended Memory Bank
|
||||
XADRLO EQU $54 ;Ext Memory Address LSB
|
||||
XADRHI EQU $55 ;Ext Memory Address MSB
|
||||
SRCPTR EQU $56 ;Source Pointer
|
||||
SRCLO EQU $57 ;Source Pointer LSB
|
||||
SRCHI EQU $58 ;Source Pointer MSB
|
||||
DSTPTR EQU $59 ;Destination Pointer
|
||||
DSTLO EQU $5A ;Destination Pointer LSB
|
||||
DSTHI EQU $5B ;Destination Pointer MSB
|
||||
BLKLO EQU $5C ;Block Pointer LSB
|
||||
BLKHI EQU $5D ;Block Pointer MSB
|
||||
BLKPTR EQU $5C ;Block Pointer
|
||||
STKLO EQU $5E ;Stack Pointer LSB
|
||||
STKHI EQU $5F ;Stack Pointer MSB
|
||||
BFRLO EQU $60 ;Buffer Pointer LSB
|
||||
@ -40,10 +35,8 @@ SYSBFP EQU $68 ;Position in System Buffer [Free Byte]
|
||||
SYSBFL EQU 128 ;System Buffer Length
|
||||
;Other Variables - User Storage Area
|
||||
SYSBFR EQU $0700 ;System Buffer
|
||||
BLKSLO EQU $07F4 ;Block Start LSB
|
||||
BLKSHI EQU $07F5 ;Block Start MSB
|
||||
BLKELO EQU $07F6 ;Block End LSB
|
||||
BLKEHI EQU $07F7 ;Block End MSB
|
||||
BLKBGN EQU $07F4 ;Block Start Address
|
||||
BLKEND EQU $07F6 ;Block End Address
|
||||
BLKLEN EQU $07F8 ;Block Length
|
||||
|
||||
STKSAV EQU $07FA ;Machine Stack Storage
|
||||
|
@ -10,17 +10,13 @@
|
||||
#define SYSBFL 128 //System Buffer Length
|
||||
|
||||
/* Standard Library Pointers */
|
||||
zeropage char srclo,srchi; //Source Pointer for Library Functions
|
||||
zeropage char dstlo,dsthi; //String Pointer for Library Functions
|
||||
zeropage int srcptr,dstptr; //Source, Destination Pointers
|
||||
zeropage int srcptr, dstptr, bfrptr, blkptr;
|
||||
zeropage char bfrlo,bfrhi; //Buffer Pointer for Library Functions
|
||||
zeropage char blklo,blkhi; //Block Segment Pointer
|
||||
zeropage char stklo,stkhi; //Stack Pointer
|
||||
zeropage char xadrlo,xadrhi; //Physical Address LSB, MSB
|
||||
|
||||
/* Standard Library Variables */
|
||||
char blkslo,blkshi; //Block Start Address
|
||||
char blkelo,blkehi; //Block End Address
|
||||
int blkbgn, blkend; //Block Start and End Address
|
||||
char blklen; //Block Segment Length
|
||||
char stkslo,stkshi; //Stack Start Address
|
||||
char stkelo,stkehi; //Stsck End Address
|
||||
|
121
test/blktest.c02
121
test/blktest.c02
@ -16,8 +16,7 @@
|
||||
#include <block.h02>
|
||||
|
||||
char c, i, n, r, z;
|
||||
char savlo,savhi,tmplo,tmphi; //Address Pointer
|
||||
char chkhi,chklo; //Address Check
|
||||
int chkint, savptr;
|
||||
char number[5];
|
||||
const char numbrs = "zero one two threefour five six seveneightnine ten";
|
||||
const char sorted = {8,5,4,9,1,7,6,3,2,0};
|
||||
@ -25,48 +24,44 @@ const char name1 = "Dick", name2 = "Jane";
|
||||
char block[255]; //Array to Use as Block
|
||||
char temp[127];
|
||||
char seglo[9],seghi[9];
|
||||
char aa,xx,yy;
|
||||
|
||||
struct ssgmt {
|
||||
char key[6];
|
||||
char flag;
|
||||
char value;
|
||||
};
|
||||
char aa,xx,yy,zz;
|
||||
int yx;
|
||||
|
||||
struct ssgmt {char key[6]; char flag; char value;};
|
||||
struct ssgmt sgmt;
|
||||
struct ssgmt seg1;
|
||||
struct ssgmt seg2;
|
||||
struct ssgmt tseg;
|
||||
|
||||
char cmpptr(chkint) {putadr(blkptr); return cmpadr(blkptr);}
|
||||
void chkadr(yx) {putadr(yx);cmpadr(yx);psflln(<yx & >yx);}
|
||||
char equals(aa,zz) {A = (aa == zz) ? #TRUE : #FALSE;}
|
||||
char cmpadr(yx) {xx = equals(<chkint, <yx); yy = equals(>chkint, <yx); return xx & yy;}
|
||||
void clrseg() {setdst(); memset(0, @sgmt);}
|
||||
char chkmem() {A = equals(memcmp(), 0);}
|
||||
void prtadr() {putwrd(); putspc();}
|
||||
void prbadr() {putadr(blkptr); prtadr(blkend); putwrd(blkptr);newlin();}
|
||||
|
||||
main:
|
||||
|
||||
puts("blkbgn(&4321); ");
|
||||
blkbgn(&$4321); //Set Block Start
|
||||
setchk(&$4321); chkadr(blkshi,blkslo);
|
||||
|
||||
puts("blkend(&$4567); ");
|
||||
blkend(&$4567); //Set Block End
|
||||
setchk(&$4567); chkadr(blkehi,blkelo);
|
||||
|
||||
puts("blkseg(@sgmt); ");
|
||||
blkseg(@sgmt);
|
||||
printf(blklen,"blklen=%d:");
|
||||
if (blklen == @sgmt) passln(); else failln();
|
||||
puts("blkbgn = &$4321; "); blkbgn = &$4321;
|
||||
puts("blkend = &$4567; "); blkend = &$4567;
|
||||
putln("blklen = @sgmt;"); blklen = @sgmt;
|
||||
|
||||
puts("blkrst(); ");
|
||||
blkrst();
|
||||
setchk(&$4321); chkadr(blkhi,blklo);
|
||||
chkint = &$4321; chkadr(blkptr);
|
||||
|
||||
puts("blknxt(); ");
|
||||
blknxt();
|
||||
setchk(&$432A); chkadr(blkhi,blklo);
|
||||
chkint = &$432A; chkadr(blkptr);
|
||||
|
||||
puts("blkprv(); ");
|
||||
blkprv();
|
||||
setchk(&$4321); chkadr(blkhi,blklo);
|
||||
chkint = &$4321; chkadr(blkptr);
|
||||
|
||||
puts("blkset('@'); ");
|
||||
blkset('@'); r=chkptr(&$4321);
|
||||
blkset('@'); r=cmpptr(&$4321);
|
||||
while (blkget(1,&sgmt)) {if (sgmt[0]<>'@') r=#FALSE;} psflln(r);
|
||||
|
||||
newlin();//if (anykey()==#ESCKEY) goto exit;
|
||||
@ -80,14 +75,14 @@ puts("sgmt=");prtseg(&sgmt);
|
||||
newlin();
|
||||
|
||||
puts("blkput(@seg1,&seg1); ");
|
||||
blkrst(); blkput(@seg1,&seg1); r=chkptr(&$432A);
|
||||
blkrst(); blkput(@seg1,&seg1); r=cmpptr(&$432A);
|
||||
memdst(&$4321); r = chkmem(@seg1,&seg1) & r;
|
||||
psflln(r);
|
||||
puts(" _blk=");prtseg(&$4321);
|
||||
newlin();
|
||||
|
||||
puts("blkswp(@sgmt,&sgmt); ");
|
||||
blkrst(); blkswp(@sgmt,&sgmt); r = chkptr(&$4321);
|
||||
blkrst(); blkswp(@sgmt,&sgmt); r = cmpptr(&$4321);
|
||||
memdst(&$4321); r = chkmem(@seg2,&seg2) & r;
|
||||
memdst(&sgmt); r = chkmem(@seg1,&seg1) & r;
|
||||
psflln(r);
|
||||
@ -98,17 +93,17 @@ anykey();
|
||||
|
||||
puts("blkput(@sgmt, &sgmt);\n"); blkset(0); blkrst(); r = #TRUE;
|
||||
for (i=0; i<10; i++) {
|
||||
printf(i,"%d: "); nsgmt(i,&sgmt); savlo=blklo;savhi=blkhi;
|
||||
blkput(@sgmt,&sgmt); seglo[i]=savlo; seghi[i]=savhi;
|
||||
putadr(.,savhi,savlo); puts(" _blk="); prtseg(.,savhi,savlo);
|
||||
setdst(.,savhi,savlo); if (memcmp(@sgmt,&sgmt)) r = #FALSE;
|
||||
printf(i,"%d: "); nsgmt(i,&sgmt); savptr=blkptr;
|
||||
blkput(@sgmt,&sgmt); seglo[i]=<savptr; seghi[i]=>savptr;
|
||||
putadr(savptr); puts(" _blk="); prtseg(savptr);
|
||||
setdst(savptr); if (memcmp(@sgmt,&sgmt)) r = #FALSE;
|
||||
}
|
||||
puts("blkput:"); psflln(r); newlin();
|
||||
|
||||
puts("blkget(@temp, &temp);\n"); blkrst(); r = #TRUE;
|
||||
for (i=0; i<10; i++) {
|
||||
printf(i,"%d: "); nsgmt(i,&sgmt); memclr(@temp, &temp);
|
||||
putadr(.,blkhi,blklo); r = blkget(@temp, &temp);
|
||||
putadr(blkptr); r = blkget(@temp, &temp);
|
||||
setdst(&temp); if (memcmp(@sgmt, &sgmt)) r = #FALSE;
|
||||
puts(" temp="); prtseg(&temp);
|
||||
}
|
||||
@ -118,20 +113,19 @@ puts("blkmem(@sgmt, &sgmt);\n"); r = #TRUE;
|
||||
for (i=9; i:+; i--) {
|
||||
printf(i,"%d: "); nsgmt(i,&sgmt);
|
||||
blkmem(@sgmt,&sgmt);
|
||||
if (dstlo<>seglo[i]) r = #FALSE;
|
||||
if (dsthi<>seghi[i]) r = #FALSE;
|
||||
putadr(.,dsthi,dstlo); puts(" _blk="); prtseg(.,dsthi,dstlo);
|
||||
if (<dstptr<>seglo[i]) r = #FALSE;
|
||||
if (>dstptr<>seghi[i]) r = #FALSE;
|
||||
putadr(dstptr); puts(" _blk="); prtseg(dstptr);
|
||||
}
|
||||
puts("blkmem:"); psflln(r); newlin();
|
||||
|
||||
|
||||
puts("blkstr(@sgmt, &sgmnt);\n"); r = #TRUE;
|
||||
for (i=0; i<10; i++) {
|
||||
printf(i,"%d: "); nsgmt(i,&sgmt); memclr(@temp, &temp);
|
||||
setdst(&temp); blkstr(&sgmt.key);
|
||||
if (srclo<>seglo[i]) r = #FALSE;
|
||||
if (srchi<>seghi[i]) r = #FALSE;
|
||||
putadr(.,srchi,srclo); puts(" temp="); prtseg(&temp);
|
||||
if (<srcptr<>seglo[i]) r = #FALSE;
|
||||
if (>srcptr<>seghi[i]) r = #FALSE;
|
||||
putadr(srcptr); puts(" temp="); prtseg(&temp);
|
||||
if (memcmp(@sgmt, &sgmt)) r = #FALSE;
|
||||
i++; if (i=9) i=0; //evens then odds
|
||||
}
|
||||
@ -140,7 +134,7 @@ puts("blkstr:"); psflln(r); anykey();
|
||||
puts("blksrt(&temp);\n"); r = #TRUE; blksrt(&temp);blkrst();
|
||||
for (i=0; i<10; i++) {
|
||||
printf(i,"%d: "); nsgmt(sorted[i],&sgmt); memclr(@temp, &temp);
|
||||
putadr(.,blkhi,blklo); r = blkget(@temp, &temp);
|
||||
putadr(blkptr); r = blkget(@temp, &temp);
|
||||
setdst(&temp); if (memcmp(@sgmt, &sgmt)) r = #FALSE;
|
||||
puts(" temp="); prtseg(&temp);
|
||||
}
|
||||
@ -150,31 +144,6 @@ putln("Tests complete.");
|
||||
|
||||
goto exit;
|
||||
|
||||
char chkptr() {
|
||||
setchk(); //pass through args
|
||||
putadr(.,blkhi,blklo);
|
||||
return cmpadr(.,blkhi,blklo);
|
||||
}
|
||||
void setchk() {
|
||||
chklo=X; chkhi=Y;
|
||||
}
|
||||
|
||||
void chkadr(tmphi,tmplo) {
|
||||
putadr(.,tmphi,tmplo);
|
||||
cmpadr(.,tmphi,tmplo);
|
||||
psflln(tmplo & tmphi);
|
||||
}
|
||||
|
||||
char cmpadr(aa,yy,xx) {
|
||||
xx = (chklo == xx) ? #TRUE : #FALSE;
|
||||
yy = (chkhi == yy) ? #TRUE : #FALSE;
|
||||
return xx & yy;
|
||||
}
|
||||
|
||||
void clrseg() {
|
||||
setdst(); memset(0, @sgmt);
|
||||
}
|
||||
|
||||
void prtseg(aa,yy,xx) {
|
||||
setdst(&tseg); memcpy(@tseg,yy,xx);
|
||||
setdst(&tseg.key); printf("key=\"%s\",");
|
||||
@ -182,11 +151,6 @@ void prtseg(aa,yy,xx) {
|
||||
printf(tseg.value,",value=%d\n");
|
||||
}
|
||||
|
||||
char chkmem() {
|
||||
aa = memcmp(); //pass through args
|
||||
aa = (aa==0) ? #TRUE : #FALSE;
|
||||
return aa;
|
||||
}
|
||||
|
||||
//Copy Textual Representation of n to temp
|
||||
void numstr(n,yy,xx) {
|
||||
@ -197,27 +161,20 @@ void numstr(n,yy,xx) {
|
||||
}
|
||||
|
||||
//Build String Segment in Temp
|
||||
void nsgmt(n,tmphi,tmplo) {
|
||||
void nsgmt(n,yx) {
|
||||
memclr(@tseg,&tseg);
|
||||
numstr(n,&tseg.key);
|
||||
tseg.flag = trufls(n);
|
||||
tseg.value = n;
|
||||
setdst(.,tmphi,tmplo); memcpy(@tseg,&tseg);
|
||||
setdst(yx); memcpy(@tseg,&tseg);
|
||||
}
|
||||
|
||||
//Print Addresses
|
||||
void pradrs() {
|
||||
tmplo=srclo;tmphi=srchi;
|
||||
puts(" SRC: $");prbyte(tmphi);prbyte(tmplo);
|
||||
puts(" DST: $");prbyte(dsthi);prbyte(dstlo);
|
||||
puts(" BLK: $");prbyte(blkhi);prbyte(blklo);
|
||||
puts(" SRC: $");putwrd(srcptr);
|
||||
puts(" DST: $");putwrd(dstptr);
|
||||
puts(" BLK: $");putwrd(blkptr);
|
||||
newlin();
|
||||
}
|
||||
|
||||
//Print Block Addresses
|
||||
void prbadr() {
|
||||
prbyte(blkshi);prbyte(blkslo);putc(' ');
|
||||
prbyte(blkehi);prbyte(blkelo);putc(' ');
|
||||
prbyte(blkhi);prbyte(blklo);newlin();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user