home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
MBUG
/
MBUG121.ARC
/
CPMUTILS.ARK
/
LIFE.AQM
/
LIFE.ASM
Wrap
Assembly Source File
|
1988-08-07
|
16KB
|
786 lines
; THIS PROGRAM WILL BE PERFORM THE NECESSARY ANALYSIS
; TO DO THE GAME OF LIFE.
; STARTED 4/2/83 LAST UPDATE 5/15/83
;
; MODIFIED FOR THE VT/180 STARTED 6/16/83
; MODIFIED TO MAKE RESPONSE CHARACTER EITH LOWER OR
; UPPER CASE. 5/10/84
;
VT EQU 000H ;-1=VT/180;0=OSBORNE
GRAPH EQU 0FFH ;0=NO GRAPHICS,-1=OSBORNE GRAPHICS
;
BDOS EQU 0005H ;SYSTEM CALL ADDRESS
ESC EQU 27 ;'ESCAPE' CODE
HOME EQU 26 ; CLEAR SCREEN CODE
;
ORG 0100H ;START
LXI H,0
DAD SP
SHLD OLDSP ;SAVE STACK POINTER
INIT LXI SP,STACK
IF NOT VT
MVI E,HOME ;GET CHARACTER TO CLEAR SCREEN
CALL OUTCH ;SEND IT
ENDIF
IF VT
MVI E,ESC ;GET CHARACTER TO CLEAR SCREEN
CALL OUTCH ;SEND IT
MVI E,'['
CALL OUTCH
MVI E,'2'
CALL OUTCH
MVI E,'J'
CALL OUTCH
ENDIF
;
;CLEAR BUFFER
;
CLEAR LXI D,BUFFER ;GET BUFFER ADDRESS
LXI B,2000H ;GET BUFFER SIZE
REPEAT MVI A,0 ;CLEAR A
STAX D ;STORE AT (DE)
INX D ;INCREMENT (DE)
DCX B ;DECREMENT (BC)
MOV A,B ;A < B
ORA A ;ARE WE DONE?
JNZ REPEAT ;IF NOT, REPEAT
;
LXI B,0 ;CLEAR GENERATION COUNTER
PUSH B ;SAVE IT
IF GRAPH
MVI E,ESC ;GET ESCAPE
CALL OUTCH ;SEND IT
MVI E,'G' ;GET END GRAPHICS
CALL OUTCH ;SEND IT
ENDIF
CALL START ;ENTER PATTERN
IF VT
MVI E,ESC ;GET CHARACTER TO CLEAR SCREEN
CALL OUTCH ;SEND IT
MVI E,'['
CALL OUTCH
MVI E,'2'
CALL OUTCH
MVI E,'J'
CALL OUTCH
ENDIF
IF GRAPH
MVI E,ESC ;GET ESCAPE
CALL OUTCH ;SEND IT
MVI E,'g' ;GET START GRAPHICS
CALL OUTCH ;SEND IT
ENDIF
CALL READ ;PRINT INITIAL PATTERN
DO CALL SCAN ;PROCESS NEXT GENERATION
CALL READ ;PRINT RESULTS
POP B ;GET GEN COUNTER
INX B ;INCREMENT IT
PUSH B ;SAVE IT
CALL DECODE ;DECODE GENERATION
MOV A,E ;STORE ASCII
STA GENN+3
MOV A,D
STA GENN+2
MOV A,C
STA GENN+1
MOV A,B
STA GENN
IF NOT VT
MVI H,23 ;SET SCREEN POSITION
MVI L,0
CALL POSCUR ;MOVE TO BOTTOM OF SCREEN
ENDIF
MVI C,9 ;SET PRINT STRING
LXI D,STRING ;GET ADDRESS
CALL BDOS ;DO IT
MVI C,0BH ;TEST CONSOLE
CALL BDOS
CPI 0 ;IF NOT (NOT READY)
CNZ CONT ;CALL CONTINUE
JMP DO ;REPEAT
;
;CONTINUE ?
;
IF NOT VT
CONT MVI H,23 ;SET SCREEN POSITION
MVI L,0
CALL POSCUR ;MOVE TO BOTTOM OF SCREEN
MVI C,1 ;GET STOP CHARACTER
CALL BDOS
CPI 03H ;SEE IF ^C
JZ STOP ;IS SO STOP
MVI H,23 ;SET SCREEN POSITION
MVI L,0
MVI E,'?' ;SET CHARACTER '?'
CALL POSCHR ;MOVE TO BOTTOM OF SCREEN
ENDIF
IF VT
CONT MVI C,9 ;SET PRINT STRING
LXI D,STRING3 ;GET ADDRESS;
CALL BDOS ;DO IT
MVI C,1 ;GET STOP CHARACTER
CALL BDOS
CPI 03H ;SEE IF ^C
JZ STOP ;IS SO STOP
MVI C,9 ;SET PRINT STRING
LXI D,STRING2 ;GET ADDRESS
CALL BDOS ;DO IT
ENDIF
MVI H,0BAH ;LOAD TIMER COUNTER
PUSH H ;STORE IT
CONT3 MVI C,0BH ;SEE IF CONSOLE READY
CALL BDOS
CPI 0 ;IF NOT (NOTREADY)
JNZ CONT4 ;GET CHARACTER
POP H ;GET TIMER
INX H ;INCREMENT IT
MOV A,H ;TEST TIMER
CPI 0 ;IF FINISHED
RZ ;RETURN
PUSH H ;IF NOT STORE TIMER
JMP CONT3 ;REPEAT
CONT4 POP H ;CLEAR STACK
MVI C,1 ;MODE- CONSOLE READ
CALL BDOS ;GET CHARACTER
CPI 03H ;SEE IF ^C
JZ STOP ;IS SO STOP
ANI 4FH ;MAKE UPPER CASE
CPI 4EH ;SEE IF 'N'
JZ CONT2 ;IF SO CONTINUE
RET ;OTHERWISE RETURN
CONT2 POP H ;CLEAR STACK RETURN ADD
IF GRAPH
MVI E,ESC ;GET ESCAPE
CALL OUTCH ;SEND IT
MVI E,'G' ;GET END GRAPHICS
CALL OUTCH ;SEND IT
ENDIF
JMP INIT ;GOTO START
;
;STOP
;
STOP
IF GRAPH
MVI E,ESC ;GET ESCAPE
CALL OUTCH ;SEND IT
MVI E,'G' ;GET END GRAPHICS
CALL OUTCH ;SEND IT
ENDIF
MVI H,23 ;SET SCREEN POSITION
MVI L,0
CALL POSCUR ;MOVE TO BOTTOM OF SCREEN
LXI D,NAME
MVI C,9
CALL BDOS
LHLD OLDSP ;GET OLD STACK ADDRESS
SPHL
RET
;
; SUBROUTINE TO PROCESS ARRAY
; 1 = REMAIN FROM PREVIOUS GENERATION
; 4 = CREATE IN NEXT GENERATION
; 5 = DIE IN NEXT GENERATION
;
;MOVE FIRST LINES TO BUFFER END
;
SCAN LXI B,0100H ;LOAD COUNTER
LXI D,BUFFER+0800H ;LOAD STORE ADDRESS
LXI H,BUFFER ;LOAD FIND ADDRESS
DB 0EDH ;LDIR ;MOVE BLOCK
DB 0B0H
;
LXI H,BUFFER ;GET BUFFER ADDRESS
SCAN1 PUSH H ;STORE IT
LXI D,03EH ;GET OFFSET TO NEXT LINE
MVI A,0 ;CLEAR COUNTER
MVI B,0 ;CLEAR INDICATOR B=1 IF CENTER
DB 0CBH ;BIT 0,(HL)
DB 046H ;LOCATION -1,-1
CNZ ADDA ;TEST IF OCCUPIED IF SO CALL ADDA
INX H ;INDEX ADDRESS
DB 0CBH ;BIT 0,(HL)
DB 046H ;LOCATION -1,0
CNZ ADDA
INX H
DB 0CBH ;BIT 0,(HL)
DB 046H ;LOCATION -1, 1
CNZ ADDA
DAD D ;GO TO NEXT LINE
DB 0CBH ;BIT 0,(HL)
DB 046H ;LOCATION 0,-1
CNZ ADDA
INX H
DB 0CBH ;BIT 0,(HL)
DB 046H ;LOCATION 0, 0
CNZ ADDB
INX H
DB 0CBH ;BIT 0,(HL)
DB 046H ;LOCATION 0, 1
CNZ ADDA
DAD D ;GO TO NEXT LINE
DB 0CBH ;BIT 0,(HL)
DB 046H ;LOCATION 1,-1
CNZ ADDA
INX H
DB 0CBH ;BIT 0,(HL)
DB 046H ;LOCATION 1, 0
CNZ ADDA
INX H
DB 0CBH ;BIT 0,(HL)
DB 046H ;LOCATION 1, 1
CNZ ADDA
DB 0CBH ;BIT 0,B
DB 040H
JZ BIRTH ;CHECK TO SEE IF CREATE
SUI 5 ;SEE IF MORE THAN 3 NEIGHBORS
JP KILL ;IF SO KILL
ADI 2 ;SEE IF LESS THAN 2 NEIGHBORS
JP SCAN5 ;IF NOT CONTINUE
KILL MVI A,5 ;MARK KILL POSITION
JMP CONTI ;CONTINUE
BIRTH SUI 3 ;SEE IF EXACTLY 3 NEIGHBORS
JNZ SCAN5 ;IF NOT CONTINUE
MVI A,4 ;STORE RESULTS
CONTI POP H ;GET CURRENT ADDRESS
PUSH H ;STORE IT AGAIN
LXI D,041H ;OFF SET TO CENTER
DAD D ;ADD TO ADDRESS
MOV M,A ;STORE NEW CONTENTS
SCAN5 POP H ;GET ADDRESS AGAIN
INX H ;INCREMENT IT
MOV A,H
SUI 0EH ;SEE IF GTREATER THAN 1A
JM SCAN1 ;IF SO REPEAT
;
;MOVE FIRST LINE BACK TO BEGINNING OF BUFFER
;
LXI B,041H ;LOAD COUNTER
LXI D,BUFFER ;LOAD STORE ADDRESS
LXI H,BUFFER+0800H ;LOAD FIND ADDRESS
DB 0EDH ;LDIR ;MOVE BLOCK
DB 0B0H
RET ;RETURN
;
ADDB MVI B,1 ;MARK IF CENTER OCCUPIED
ADDA ADI 1 ;ADD IF OCCUPIED
RET ;RETURN
;
;SUBROUTINE TO DECODE PATTERN AND DISPLAY
;IT READS BUFFER AND CALLS SETSCR
;NOTE: SCREEN SIZE IS LIMITED TO 24 IN THE Y DIRECTION
;AND 50 IN THE X DIRECTION
;
READ LXI H,0 ;CLEAR SCREEN ADDRESS
LXI B,0 ;CLEAR GENERATION COUNTER
READ1 PUSH H ;SAVE ADDRESS
LXI D,BUFFER ;GET OFFSET
DAD D ;ADD TO SCREEN ADDRESS
MOV A,M ;GET CONTENTS
ANI 0FFH ;SEE IF OTHER THAN 0
JZ READ2 ;IF SO DECODE AND PRINT
SUI 5 ;CHECK IF LOCATION IS TO DIE
JP BLANK ;IF SO, SEND BLANK
INX B ;INCREMENT COUNTER
ADI 2 ;CHECK IF NEW LOCATION
JM READ2 ;IF NOT CONTINUE
MVI A,1 ;REPLACE NEW LOCATION
MOV M,A ;STORE IT
IF GRAPH
MVI E,0DH ;SET GRAPHICS DOT
ENDIF
IF NOT GRAPH
MVI E,'*' ;SET DISPLAY CHARACTER
ENDIF
JMP PRINT ;PRINT IT
BLANK MVI A,0 ;CLEAR LOCATION
MOV M,A ;STORE IT
MVI E,' ' ;CLEAR CHARACTER
PRINT POP H ;GET SCREEN ADDRESS
PUSH H ;SAVE IT
MOV A,H ;FIND Y
RLC ;SHIFT Y VALUES
RLC
DB 0CBH ;BIT 6,L
DB 075H
JZ PRINT1 ;IF BIT SET
ADI 1 ;INCREMENT Y ADDRESS
PRINT1 DB 0CBH ;BIT 7,L
DB 07DH
JZ PRINT2 ;IF BIT SET
ADI 2 ;INCREMENT Y ADDRESS
PRINT2 MOV H,A ;STORE Y
MOV A,L ; GET X
ANI 03FH ;CANCEL BITS MOVED TO H
MOV L,A ;SAVE X
SUI 79 ;SEE IF X GREATER THAN SCREEN
JP READ2 ;IF SO CONTINUE
MOV A,H ;SEE IF Y GREATER THEN SCREEN SIZE
SUI 23
JP READ2 ;IF SO CONTINUE
PUSH B ;SAVE COUNTER
CALL POSCHR ;IF NOT PRINT CHARACTER
POP B ;GET COUNTER BACK
READ2 POP H ;RESTORE ADDRESS
INX H ;INDEX ADDRESS
MOV A,H ;SEE IF GREATER THEN 18H
SUI 0EH
JM READ1 ;IF NOT REPEAT
PUSH B ;SAVE POPULATION
CALL DECODE ;DECODE POPULATION
MOV A,E ;MOVE ASCII TO STORAGE
STA POPN+3
MOV A,D
STA POPN+2
MOV A,C
STA POPN+1
MOV A,B
STA POPN
POP B ;GET POPULATION
MOV A,B ;TEST UPPER BYTE
CPI 0 ;IF NOT ZERO RETURN
RNZ
MOV A,C ;TEST LOWER BYTE
CPI 0 ;IF NOT ZERO RETURN
RNZ
POP H ;CLEAR STACK RETURN ADD
MVI H,23 ;SET SCREEN POSITION
MVI L,0
MVI E,'?' ;SET CHARACTER '?'
CALL POSCHR ;MOVE TO BOTTOM OF SCREEN
MVI C,1 ;MODE- CONSOLE READ
CALL BDOS ;GET CHARACTER
CPI 53H ;SEE IF 'S'
JZ STOP ;IS SO STOP
IF GRAPH
MVI E,ESC ;GET ESCAPE
CALL OUTCH ;SEND IT
MVI E,'G' ;GET END GRAPHICS
CALL OUTCH ;SEND IT
ENDIF
JMP INIT
;
;SUBROUTINE TO WRITE CHARACTER TO ANY SCREEN POSITION
;THE CHARATER CODE IS SENT IN REGISTER E
;THE Y POSITION IS SENT IN REGISTER H
;THE X POSITION IS SENT IN REGISTER L
;
POSCHR PUSH D ;SAVE CHARATER
CALL POSCUR
POP D
OUTCH MVI C,2 ;SET FUNCTION WRITE
CALL BDOS ;CALL BDOS
RET
;
;SUBROUTINE TO POSITION CURSOR
;THE Y POSITION IS SENT IN REGISTER H
;THE X POSITION IS SENT IN REGISTER L
;
IF NOT VT
POSCUR LXI D,2020H ;LOAD OFFSETS
DAD D ;ADD TO LOCATIONS
PUSH H ;SAVE LOCATIONS
MVI E,ESC ;LOAD 'ESCAPE'
CALL OUTCH ;SEND 'ESCAPE'
MVI E,'=' ;LOAD '='
CALL OUTCH ;SEND '='
POP H ;GET Y LOCATION
MOV E,H ;LOAD Y LOCATION
PUSH H ;SAVE X LOCATION
CALL OUTCH ;SEND Y LOCATION
POP D ;GET X LOCATION
CALL OUTCH ;SEND X LOCATION
RET ;RETURN
ENDIF
;
; A NOTE THE VT/180 HAS TO HAVE THE ADDRESS CODE SENT AS THE
; ESC,[,A1,A2,;,A1,A2,H WHERE A1 AND A2 ARE THE ASCII CODES
; FOR THE SCREEN POSITION
;
IF VT
POSCUR INR H
INR H
INR L
MOV B,H
CALL DEC ;DECODE VERTICAL POSITION
MOV A,E ;STORE ASCII
STA VP+1
MOV A,D
STA VP
MOV B,L
CALL DEC ;DECODE VERTICAL POSITION
MOV A,E ;STORE ASCII
STA HP+1
MOV A,D
STA HP
MVI C,9
LXI D,PSTRING
CALL BDOS
RET ;RETURN
PSTRING DB 1BH,'['
VP DB ' '
DB ';'
HP DB ' '
DB 'H'
DB '$'
;
;SUBROUTINE TO DECODE NUMBERS INTO DECIMAL ASCII
;NUMBER SENT IN REGISTER B
;ASCII RETURNED IN C,D,E
;
DEC MOV A,B ;GET NUMBER
LXI B,0 ;CLEAR STORAGE
LXI D,0 ;CLEAR STOIRAGE
DC1 SBI 100 ;
JM DC2 ;IF NOT GO ON
INR C
JMP DC1
DC2 ADI 100
MOV B,A
MOV A,C
ADI 30H
MOV C,A
MOV A,B
DC3 SBI 10 ;
JM DC4 ;IF NOT GO ON
INR D
JMP DC3
DC4 ADI 10
MOV B,A
MOV A,D
ADI 30H
MOV D,A
MOV A,B
DC5 SBI 1 ;
JM DC6 ;IF NOT GO ON
INR E
JMP DC5
DC6 MOV A,E
ADI 30H
MOV E,A
RET
ENDIF
;
;WRITE BUFFER - CREATE TEST PATTERN
;
WRITE MVI E,HOME ;GET CHARACTER TO CLEAR SCREEN
CALL OUTCH ;SEND IT
POP H
MVI A,4 ;CHARACTER FOR BUFFER
LXI H,BUFFER ;GET ADDRESS
LXI D,0218H ;GET OFFSET
DAD D ;ADD TO ADDRESS
PUSH H ;STORE ADDRESS FOR LATER
PUSH H
MOV M,A ;STORE IT
INX H ;INDEX ADDRESS
MOV M,A
INX H
MOV M,A
INX H ;INDEX ADDRESS
MOV M,A
INX H
MOV M,A
INX H ;INDEX ADDRESS
MOV M,A
INX H
MOV M,A
INX H ;INDEX ADDRESS
MOV M,A
INX H
MOV M,A
LXI D,0040H ;INDEX IN Y DIRECTION
DAD D ;INDEX ADDRESS
MOV M,A ;STORE IT
DAD D
MOV M,A
DAD D
MOV M,A
DAD D
MOV M,A
DAD D
MOV M,A
DAD D
MOV M,A
LXI D,003FH ;INDEX IN X AND Y DIRECTION
POP H ;GET OLD START ADDRESS
DAD D ;INDEX ADDRESS
MOV M,A ;STORE IT
DAD D
MOV M,A
DAD D
MOV M,A
DAD D
MOV M,A
DAD D
MOV M,A
DAD D
MOV M,A
LXI D,041H ;INDEX IN X AND Y DIRECTION
POP H ;GET OLD START ADDRESS
MOV A,L
SUI 7
MOV L,A
MVI A,4
DAD D ;INDEX ADDRESS
MOV M,A ;STORE IT
DAD D
MOV M,A
DAD D
MOV M,A
DAD D
MOV M,A
DAD D
MOV M,A
DAD D
MOV M,A
RET
;
WRITE2 MVI E,HOME ;GET CHARACTER TO CLEAR SCREEN
CALL OUTCH ;SEND IT
POP H
MVI A,4 ;CHARACTER FOR BUFFER
DB 0DDH
LXI H,BUFFER ;GET ADDRESS
LXI D,0206H ;GET OFFSET
DB 0DDH
DAD D ;ADD TO ADDRESS
DB 0DDH
MOV M,A ;STORE IT
DB 0FEH
DB 0DDH
MOV M,A
DB 0FFH
DB 0DDH
MOV M,A
DB 0
DB 0DDH
MOV M,A ;STORE IT
DB 40H
DB 0DDH
MOV M,A ;STORE IT
DB 7FH
LXI D,0420H ;GET OFFSET
DB 0DDH
DAD D ;ADD TO ADDRESS
DB 0DDH
MOV M,A ;STORE IT
DB 0FEH
DB 0DDH
MOV M,A
DB 0BFH
DB 0DDH
MOV M,A
DB 0
DB 0DDH
MOV M,A ;STORE IT
DB 40H
DB 0DDH
MOV M,A ;STORE IT
DB 0C0H
RET
;
;SUBROUTINE TO ACCEPT SCREEN DISPLAY FOR PATTERN
;
START MVI H,12 ;LOAD INITIAL Y
MVI L,25 ;LOAD INITIAL X
MVI A,4 ;SET INTIAL DIRECTION
STA DIR ;STORE IT
PUSH H ;SAVE IT
IF VT
JMP RIGHT
ENDIF
START0 CALL POSCUR ;POSITION CURSOR
START1 MVI C,1 ;MODE- CONSOLE READ
CALL BDOS ;GET CHARACTER
CPI 0DH ;SEE IF CR
JZ DONE ;IS SO RETURN
CPI 03H ;SEE IF ^C
JZ STOP ;IS SO STOP
CPI 04H ;SEE IF RIGHT
JZ RIGHT
CPI 05H ;SEE IF UP
JZ UP
CPI 013H ;SEE IF LEFT
JZ LEFT
CPI 018H ;SEE IF DOWN
JZ DOWN
CPI 0CH ;SEE IF RIGHT
JZ RIGHT
CPI 0BH ;SEE IF UP
JZ UP
CPI 08H ;SEE IF LEFT
JZ LEFT
CPI 0AH ;SEE IF DOWN
JZ DOWN
CPI 050H ;SEE IF P
JZ WRITE
CPI 046H ;SEE IF F
JZ WRITE2
JMP START2 ;IF NOT
UP MVI A,1 ;SET DIRERCTION MARKER
STA DIR ;STORE IT
POP H ;GET ADDRESS
MOV A,H ;MOVE Y
SUI 1 ;SUBTRACT 1
CPI 0FFH ;SEE IF ZERO
JNZ UP1
MVI A,22 ;IF SO SET OTHER LIMIT
UP1 MOV H,A ;MOVE BACK
PUSH H ;STORE IT
JMP START0 ;POSITION CURSOR
LEFT MVI A,2 ;SET DIRERCTION MARKER
STA DIR ;STORE IT
POP H
MOV A,L
SUI 1
CPI 0FFH ;SEE IF ZERO
JNZ LEFT1
MVI A,78
LEFT1 MOV L,A
PUSH H
JMP START0
RIGHT MVI A,4 ;SET DIRERCTION MARKER
STA DIR ;STORE IT
POP H
INR L
MOV A,L
CPI 79 ;SEE IF ZERO
JNZ RIGHT1
MVI L,0
RIGHT1 PUSH H
JMP START0
DOWN MVI A,8 ;SET DIRERCTION MARKER
STA DIR ;STORE IT
POP H
INR H
MOV A,H
CPI 23 ;SEE IF ZERO
JNZ DOWN1
MVI H,0
DOWN1 PUSH H
JMP START0
START2 CPI 020H ;SEE IF SPACE
JNZ ST2 ;IF NOT GO ON
MVI E,' ' ;SET CHR TO SPACE
JMP ST3 ;GO ON
ST2 MVI E,'*' ;SET DOT
ST3 POP H ;GET ADDRESS
PUSH H ;STORE IT
PUSH D ;SAVE CHR WRITTEN
IF VT
DCR H ;MARK
ENDIF
CALL POSCHR ;PRINT CHARACTER
POP D ;GET CHARACTER
POP H ;GET ADDRESS
PUSH H ;SAVE IT
MOV A,H
RAR ;SHIFT RIGHT
JNC START3 ;IF CLEAR GO ON
DB 0CBH ;SET ;IF NOT SET BIT
DB 0F5H ;6,L
START3 RAR ;SHIFT RIGHT
JNC START4 ;IF CLEAR GO ON
DB 0CBH ;SET ;IF NOT SET BIT
DB 0FDH ;7,L
START4 ANI 03FH ;CLEAR UPPER BITS
MOV H,A ;SAVE Y LOCATION
LXI B,BUFFER ;FIND OFFSET
DAD B ;ADD TO ADDRESS
MOV A,E ;GET CHR
CPI ' ' ;CAMPARE TO SPACE
JNZ ST4 ;IF NOT GO ON
MVI A,0 ;IF SO CLEAR
JMP ST5 ;GO ON
ST4 MVI A,4 ;IF NOT SPACE MARK LOCATION
ST5 MOV M,A ;STORE IN BUFFER
LDA DIR ;RECALL DIR
CPI 1 ;CHECK UP
JZ UP
CPI 2 ;CHECK LEFT
JZ LEFT
CPI 4 ;CHECK RIGHT
JZ RIGHT
CPI 8 ;CHECK DOWN
JZ DOWN
JMP START1
DONE POP H ;CLEAR STACK
RET ;RETURN
;
DIR DS 1
;
;SUBROUTINE TO DECODE NUMBERS INTO ASCII
;NUMBER SENT IN REGISTER PAIR B,C
;ASCII RETURNED IN B,C,D,E
DECODE MOV A,C ;GET LOWEST NIBBLE
ANI 0FH ;CLEAR ACCUMULATOR
ADI 30H ;MAKE ASCII
CPI 3AH ;SEE IF GREATER THEN 9
JM D1 ;IF NOT GO ON
ADI 7 ;INCREMENT TO LETTER
D1 MOV E,A ;SAVE LOWEST NIBBLE
MOV A,C ;GET NEXT NIBBLE
RAR ;SHIFT OVER
RAR
RAR
RAR
ANI 0FH
ADI 30H
CPI 3AH
JM D2
ADI 7
D2 MOV D,A
MOV A,B ;GET LOWEST NIBBLE UPPER BYTE
ANI 0FH
ADI 30H
CPI 3AH
JM D3
ADI 7
D3 MOV C,A
MOV A,B ;GET HIGHEST BYTE
RAR
RAR
RAR
RAR
ANI 0FH
ADI 30H
CPI 3AH
JM D4
ADI 7
D4 MOV B,A
RET
;
OLDSP DS 2
DS 30
STACK DS 2
;
;PRINT BUFFER
;
NAME DB 0DH,0AH
DB 'LIFE R.A.R ver 1.61 5/10/84'
DB 0DH,0AH,'$'
STRING
IF VT
DB 1BH
DB '[24;0H'
ENDIF
DB ' GENERATION: '
GENN DB ' '
DB ' POPULATION: '
POPN DB ' '
STREND DB '$'
IF VT
STRING2 DB 1BH
DB '[24;00H?'
DB '$'
STRING3 DB 1BH
DB '[24;00H'
DB '$'
ENDIF
;
BUFFER DS 2000H
BUFEND DS 2
END
END