ÚVOD | Novinky | 8 Bitů | Příslušenství | Drobnosti | TTL | Kontakt


SAPI-1 | ONDRA | PMI-80 | PMD-85 | klony PMD-85 | klony SM50/40 | PETR | PLAN-80A | IQ151 | TNS | FK-1 | HVĚZDA | SP 830 | PCS 1-QR6000


ZPS | Technické prostředky | Programové vybavení | Dokumentace


8 bity / SAPI-1 / Programové vybavení / V4.x / ASM MONITOR+ MIKOS-1


Výpis programu MONITOR+ MIKOS-1 V4.0H

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TITLE 'MONITOR PLUS, MIKOS V4.0H - SAPI 1'
;       30.7.1985       (P+S)
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;
CPM     EQU     0       ;EPROM VERSION
;
;       * ROZDELENI PAMETI *
;
        IF      NOT CPM
@R@     EQU     4000H
MONIT   EQU     100H
EPROM   EQU     800H
LSYSR   EQU     400H
TVBEG   EQU     3800H
PEDIT   EQU     4400H
BASIC   EQU     4400H
TRACER  EQU     4C00H
        ELSE
;
@R@     EQU     4000H   ;SYS RAM
MONIT   EQU     200H    ;MONITOR
EPROM   EQU     800H+200H       ; CPM
LSYSR   EQU     400H    ;SYS.RAM
TVBEG   EQU     0E800H
PEDIT   EQU     1200H   ;START
BASIC   EQU     4400H
TRACER  EQU     2000H
        ENDIF
;
;
;
;       * MONITOR ENTRY *
;
CSTS    EQU     MONIT + 12H
CI      EQU     MONIT + 3
RI      EQU     MONIT + 6
CO      EQU     MONIT + 09H
PO      EQU     MONIT + 0CH
CINCR   EQU     MONIT + 3FH
IODEF   EQU     MONIT + 1EH
EXPR    EQU     MONIT + 27H
DBYT    EQU     MONIT + 33H
DADR    EQU     MONIT + 30H
CRLF    EQU     MONIT + 24H
HILO    EQU     MONIT + 36H
NEXT    EQU     MONIT + 39H
TEXT    EQU     MONIT + 42H
IOCHK   EQU     MONIT + 15H
SPACE   EQU     MONIT + 3CH
IOSET   EQU     MONIT + 18H
ERROR   EQU     MONIT + 2AH
ASHEX   EQU     MONIT + 2DH
HXASC   EQU     MONIT + 48H
ASSEX   EQU     MONIT + 51H
;
;
LENGHT  EQU     255     ; BLOCK LENGHT
NAMLE   EQU     11      ; NAME LENGHT
COMLE   EQU     64      ; COMNENT LENGTH
;------------------------------------------
CR      EQU     0DH     ;KONSTANTY
LF      EQU     0AH
DEL     EQU     7FH     ; DELETE
ETX     EQU     03H
HT      EQU     9       ;TAB
PREAM   EQU     10H     ; PREAMBLE/POSTAMBLE
SUBS    EQU     1AH     ; END FLAG
;
; SER. I/O
USER    EQU     13H
UDATA   EQU     12H
USTAT   EQU     11H
UMODE   EQU     10H

; BLOCK LABELS
SOH     EQU     01H     ; START OF HEADER
EOT@    EQU     04H     ; END OF TAPE
CAN     EQU     ':'     ; VOLUME NAME
;               'A'     ; DATA BLOCK
;               'B'     ; BINARY BLOCK
;

;=====================================
        ASEG
        ORG     EPROM   ;START
;=====================================

        JMP     MICOS   ;BRANCH TABLE
        JMP     INITS   ;INIT SYSTEM
        JMP     EXMON   ;EXPAND
        JMP     FIND
        JMP     OPEN
        JMP     CLOSE
        JMP     LOAD
        JMP     SAVE
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;
; INIT SYSTEM AND I/O
;
INITS:  MVI     C,0A9H  ;LO=L,RI-1,PO-1
        MOV     A,C
        STA     FND     ;NO FIND MODE
        CALL    IOSET   ; SET P=R=1
        CALL    TXIMM   ;OHLASENI
        DB      'MIKOS-1 V4.0H '
        DB      '+' OR 80H
        CALL    ICMD1
        JMP     OCMD1
;
;
; INPUT SET
;
ICMD:   MVI     A,'R'
        CALL    ASSEX
ICMD1:  XRA     A
        STA     @IF1    ;FIND FLAG
        MVI     C,2
        LXI     D,GET@
        JMP     IODEF
;
; OUTPUT SET
;
OCMD:   MVI     A,'P'
        CALL    ASSEX
OCMD1:  XRA     A
        STA     @OF1    ;OPEN FLAG
        MVI     C,4
        LXI     D,PUT@
        JMP     IODEF
;
; MONITOR EXTENSION
;
EXMON:  MOV     A,L     ;COMMAND
        CPI     'W'
        JZ      WRITE
        CPI     'R'
        JZ      READ@
        CPI     'J'
        JZ      JUMP
        CPI     'N'
        JZ      NULL
        CPI     'E'
        JZ      EOF
        CPI     'I'
        JZ      ICMD
        CPI     'O'
        JZ      OCMD
        CPI     'P'
        JZ      PCMD
        CPI     'B'
        JZ      BCMD
        CPI     'T'
        JZ      TCMD
        CPI     'K'
        JZ      MICOS
        JMP     ERROR   ;MONITOR
;
; JUMP TO SYSTEM PROGRAMS
;
BCMD:   MVI     B,'B'   ;BASIC
        LXI     H,BASIC
B0:     LXI     D,@BT   ; REENTRY FLAG
B1:     MOV     A,M
        CPI     0C3H    ;JUMP
        JNZ     ERROR   ;NO EPROM IN SYSTEM
        LDAX    D
        CMP     B       ;WARM START ?
        JZ      B2      ;+2
        ORA     A
        JNZ     ERROR
        MOV     A,B
        STAX    D       ;SET FLAG
        PCHL            ;COLD START
;
B2:     INX     H
        INX     H
        INX     H
        PCHL            ;WARM START
;
TCMD:   MVI     B,'T'
        LXI     H,TRACER
        JMP     B0
;
PCMD:   MVI     B,'P'   ;PEDIT
        LXI     H,PEDIT
        LXI     D,@PED
        JMP     B1
;
;
; JUMP TO USER PROGRAM
;
JUMP:   LHLD    EADR
        XCHG
        LHLD    SADR
        MOV     A,L     ;NO PRGM
        ORA     H
        JZ      ERROR   ;EMPTY FILE
        PUSH    H       ;START
        MVI     B,0     ; SUM
J1:     MOV     A,M
        ADD     B
        MOV     B,A
        CALL    HILO
        JNC     J1
        LDA     SUM
        CMP     B
        JNZ     ERROR
        RET             ; GOTO
;
;
; END OF FILE COMMAND
;

EOF:    MVI     C,1
        CALL    EXPR
        POP     H       ; START ADR
        MVI     B,1     ; TYP RECORDU
        XRA     A       ; PARAM.
        MOV     E,A     ; POCET BYTE
        CALL    PBEG
        XRA     A
        SUB     D       ; MONTROLNI COUCET
        CALL    PBYTE
        MVI     C,SUBS  ; CLOSE
        JMP     PO
;
;  120*BLANK

NULL:
LEAD:   LXI     B,7800H
        CALL    PO
        DCR     B
        JNZ     LEAD+3
        RET

;
; READ HEX INTEL FORMAT
;
READ@:  DCR     C
        CALL    EXPR    ;OFFSET
RED1:   POP     H
        PUSH    H
REDC0:  MVI     D,9     ; MAX POCET ZNAKU BEZ ODDELELNI
REDC1:  CALL    MREAD   ; CTI BYTE
        CALL    TERM    ; ODDELOVAC ?
        JZ      REDC0   ; ANO, NASTAV CITAC
        MVI     C,':'   ; ZACATEK RECORDU ?
        SUB     C
        JZ      REDC2   ; ANO, CTI HEX DATA
        DCR     D       ; DALSI ZNAK ?
        JNZ     REDC1   ; ANO
        JMP     REDER   ; ERROR ':' .. CHYBI ':' NA PASCE
REDC2:  MOV     D,A     ; NULOVANI KONTR. SOUCTU
        CALL    RBYTE   ; DELKA RADKU
        JZ      RED3    ; KDYZ 0, KONEC
        MOV     E,A     ; NASTAVENI CITACE
        CALL    RBYTE   ; HIGH ADR
        PUSH    PSW
        CALL    RBYTE   ; LOW ADR
        POP     B
        MOV     C,A
        DAD     B       ; OFFSET ADRESY
        CALL    RBYTE   ; PRIZNAK
RED2:   CALL    RBYTE   ; STROJ. KOD
        MOV     M,A
        CMP     M       ; TEST PAMETI
        MVI     C,'M'   ; ERROR 'M' .. MEMORY
        JNZ     REDER
        INX     H
        DCR     E       ; CITAC BYTE STROJ. KODU
        JNZ     RED2
        CALL    RBYTE   ; KONTR. SOUCET Z PASKY
        JZ      RED1    ; OK
        MVI     C,'S'   ; ERROR 'S' .. CHECK SUM
REDER:  CALL    CO      ; TYP CHYBY
        CALL    DADR
        JMP     ERSTP
RED3:   PUSH    H
        CALL    RBYTE   ; HYGH START ADR
        MOV     H,A
        CALL    RBYTE   ; LOW START ADR
        MOV     L,A
        CALL    RBYTE   ; CHECK SUN
        CALL    RBYTE
        JNZ     REDER-2 ; ERROR
        POP     D
        MOV     A,D
        ORA     E       ; OFFSET ?
        POP     D       ; STACK CORECTION
        RNZ             ; YES, NO START
        MOV     A,H
        ORA     L       ; START ADR
        RZ              ; NO
        PCHL            ; GOTO
;
; WRITE CONTENTS RAM TO TAPE HEX

WRITE:  CALL    EXPR
        CALL    CRLF
        POP     D
        POP     H
WR1:    MOV     A,L
        ADI     10H
        MOV     C,A
        MOV     A,H
        ACI     0
        MOV     B,A
        MOV     A,E
        SUB     C
        MOV     C,A
        MOV     A,D
        SBB     B
        JC      WR2
        MVI     A,10H   ; >16
        JMP     WR3
WR2:    MOV     A,C     ; <16
        ADI     11H
WR3:    ORA     A
        RZ              ; NEXT
        PUSH    D       ; USCHOVA HIGH ADR
        MOV     E,A     ; NASTAVENI CITACE
        XRA     A       ; SET PARAM.
        MOV     B,A     ; TYP
        CALL    PBEG
WR4:    MOV     A,M
        INX     H
        CALL    PBYTE   ; STROJ. KOD
        DCR     E
        JNZ     WR4
        XRA     A
        SUB     D
        CALL    PBYTE   ; KONTR. SOUCET
        POP     D
        JMP     WR1


; PRECTE 2 ZNAKY, SESTAVI BYTE, TVORI KONTR. SOUCET

RBYTE:  CALL    MREAD   ; CTE ZNAK S MASKOU 7F
        CALL    ASHEX   ; PREVOD ASCII-HEX
        RLC
        RLC
        RLC
        RLC
        MOV     C,A
        CALL    MREAD
        CALL    ASHEX
        ORA     C       ; SESTAVI BYTE
        MOV     C,A
        ADD     D       ; KONTROLNI SOUCET
        MOV     D,A
        MOV     A,C
        RET

; END OF EXPRESSION

TERM:   CPI     ','
        RZ
        CPI     HT
        RZ
        CPI     ' '
        RZ
        CPI     CR
        RET



; PUNCH BEGIN OF RECORT

PBEG:   MOV     D,A     ; NULL CHECK SUM
        MVI     C,CR
        CALL    PO
        MVI     C,LF
        CALL    PO
        MVI     C,':'
        CALL    PO
        MOV     A,E     ; E .. POCET BYTE
        CALL    PBYTE
        MOV     A,H     ; HL .. ADR
        CALL    PBYTE
        MOV     A,L
        CALL    PBYTE
        MOV     A,B     ; TYP
PBYTE:  PUSH    PSW
        CALL    HBYTE
        POP     PSW
        PUSH    PSW
        CALL    LBYTE
        POP     PSW
        ADD     D
        MOV     D,A
        RET
;
HBYTE:  RRC
        RRC
        RRC
        RRC
LBYTE:  ANI     0FH
        CALL    HXASC
        JMP     PO
;

; READ CHARACTER AND MASK, ERROR IF CARRY

MREAD:  CALL    RI
        JC      ERSTP   ; #VERS."G"#
        ANI     7FH     ; POTLACENI PARITNIHO BITU
        JZ      MREAD   ; #VERS."H"# BLANK?
        RET
;
;
;  USER COMMAND LEVEL
;
MICOS:  CALL    STOP
        MVI     C,'_'
        CALL    CO
        CALL    ECHOCR
        CPI     'B'
        JZ      BB      ;MICRO-BASIC CODE
        CPI     'A'
        JZ      APPEND
        CPI     'D'
        JZ      DIR     ;DIRECTORY
        CPI     'I'
        JZ      INIT    ; INIT NEW TAPE
        CPI     'O'
        JZ      OPEN    ;OPEN OUTPUT
        CPI     'C'
        JZ      CLOSE   ;CLOSE OUTPUT
        CPI     'F'
        JZ      FIND    ;FIND INPUT
        CPI     'S'
        JZ      SAVE    ;SAVE
        CPI     'L'
        JZ      LOAD    ;LOAD
        CPI     'M'     ;MONITOR
        RNZ             ; NO FIND
;-------------------------------
; MOTION
MOTA:   CALL    START   ;MOTA PASKY
        CALL    DONE
        JMP     STOP
;
START:  MVI     A,38H
GAPO:   OUT     UMODE
        MVI     A,1FH
        OUT     USTAT   ; CLEAR
        RET
;
;
STARW:  MVI     A,30H
        JMP     GAPO    ; START WRITE
;
;  APPEND NEW FILE ON TAPE
;
APPEND: STA     JOIN    ; NO INPUT
        LHLD    BNO     ; SET FILE NUMBER
        XCHG
        JMP     OPE50

;---------------------------------
;DIRECTORY CASSETE
DIR:    XRA     A       ; INPUT BUFFER
        STA     JOIN
        CALL    PLAY
DIR0:   CALL    SEARCH  ; HEADER
        CZ      PHDR    ; PRINT NAME
        CPI     EOT@
        JNZ     DIR0
        CALL    CRLF    ; PRINT:
        MOV     A,D
        CALL    DBYT    ; FILE NUMBER
        MVI     C,'-'
        CALL    CO
        MOV     A,E
        CALL    DBYT    ; BLOCK NUMBER
        JMP     DIR0

;----------------------------------
;OPEN OUTPUT FILE
OPEN:   CALL    PTP?
        LDA     @OF1    ;DOUBLE ?
        ORA     A
        JNZ     ERROR
        CALL    TXIMM
        DB      CR,LF
        DB      'LAST'
        DB      ' ' OR 80H
        MVI     A,-1    ;FLAG
        CALL    FINO
        JNZ     OPE1
OPE01:  CALL    SEARCH  ;EOT ?
        JZ      OPE20   ;SOH
        CPI     EOT@
        JNZ     OPE01   ;NEXT BLOCK
OPE30:  CALL    OK?
        JZ      OPE50   ;OPEN NOW
OPE20:  CALL    CMPNM + 3       ; OK ?
OPE1:   CNZ     CMPNM
        LDA     BOUT-1
        CPI     CAN     ;VOLUME
        JZ      OPE50   ;IMMED. OPEN
        CALL    SEARCH
        CPI     EOT@
        JNZ     $ - 5
OPE50:  MOV     A,D
        INR     A       ;INCREM.FILE NUMBER
        MOV     H,A
        MVI     L,0
        SHLD    BNO     ;FILE&BLOCK NUMBER
        CALL    RECOR
        CALL    TXIMM
        DB      CR,LF
        DB      'NEW',' ' OR 80H
        MVI     A,SOH
        STA     @OF1
        JMP     WRNAM
;

;----------------------------------------
;  FIND INPUT FILE AND OPEN FOR READ
FIND:   CALL    PTR?
        XRA     A       ; FIND ONPUT FILE
        CALL    FINO
        CALL    CMPNM
        MVI     E,1
        XCHG
        SHLD    BNI     ;NUMBER FILE
        XCHG
        MVI     A,SOH
        STA     @IF1
        JMP     RIB
;---------------------------
;CLOSE OUTPUT FILE
CLOSE:  CALL    PTP?
        LDA     @OF1    ;NO OPEN
        ORA     A
        JZ      ERROR
        MVI     A,EOT@  ;CLOSE BLOK
        STA     BOUT-1
        CALL    WOB
        XRA     A
        STA     @OF1    ;CLOSE
        CALL    STARW   ;GAP 2*
        MVI     A,80    ; BOOMS
        CALL    TIME
        JMP     STOP
;---------------------
FINO:   STA     JOIN    ;I/O FLAG
        CALL    TXNAM
        LXI     H,FNAME
        PUSH    H
        MVI     B,NAMLE
        CALL    RNAME   ;READ
        CALL    PLAY
        POP     H
        MOV     A,M
        CPI     '*'     ;WILDCARDS ?
        RET

CMPNM:  CALL    SEARCH  ;COMPARE NAME
        JNZ     CMPNM   ;NO HDR
        LXI     B,FNAME
        MVI     E,NAMLE
        INX     H       ;NAME
CMPN0:  LDAX    B
        CPI     '*'
        JZ      CMPN1
        CALL    TERM    ;END OF NAME
        RZ
        CMP     M
        JNZ     CMPNM
        INX     B
        DCR     E
        JNZ     CMPN0 - 1
        RET             ;O.K
;
CMPN1:  PUSH    D
        CALL    BUADR
        PUSH    H
        CALL    PHDR
        POP     H
        POP     D
        MOV     A,H     ; CTENI NEBO ZAPIS
        CPI     (BIN-1) SHR 8
        JNZ     CMPN2
        MOV     A,M
        CPI     CAN     ; ':'... VOLUME BLOK
        JZ      CMPNM
CMPN2:  CALL    OK?
        JNZ     CMPNM
        RET
;
OK?:    CALL    TXIMM
        DB      7
        DB      '--(Y/N)','?' OR 80H
        CALL    ECHO
        CPI     'Y'
        RET
;--------------------
;INIT NEW CASSETTE
INIT:   CALL    START
        CALL    TXIMM
        DB      'BOT'
        DB      ' ' OR 80H
        CALL    RECOR
        CALL    STOP
        CALL    TXIMM
        DB      ' VOLUME'
        DB      ' ' OR 80H
        LXI     H,0     ;0..FILE NUMBER
        SHLD    BNO
        MVI     A,CAN

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;  FILE NAME LEVEL
WRNAM:  PUSH    PSW     ;HDR-LABEL
        CALL    TXNAM
        CALL    NULBF
        CALL    STOP
        POP     PSW
        MOV     M,A
        INX     H
        MVI     B,COMLE ;NAME+COMMENT
        PUSH    H
        CALL    RNAME
        POP     H
        MVI     B,NAMLE
        LXI     D,WRNM  ;OUTPUT AREA
WRN1:   MOV     A,M
        ANI     3FH
        JNZ     $+5
        MVI     A,' '   ;BLANK
        STAX    D
        INX     H
        INX     D
        DCR     B
        JNZ     WRN1
        CALL    WOB
        MVI     M,'A'   ;DATA TYP
        JMP     CRLF
; READ NAME <HL>..ADR,<B>..DELKA
;-----------------------------------
RNAME:  MOV     E,L     ;LOW-FIRST ADR
RNAM1:  MVI     M,' '
        CALL    CI
        ANI     7FH
        CPI     ETX
        JZ      MICOS
        CPI     CR
        JZ      CRLF
        CPI     DEL
        JZ      RNAM10
        CPI     08H     ;BS
        JNZ     RNAM2
RNAM10: MOV     A,E
        CMP     L       ;FIRST
        JZ      RNAM1
        DCX     H
        INR     B
        CALL    TXIMM   ;DELETE
        DB      08,20H,88H
        JMP     RNAM1
RNAM2:  MOV     M,A
        INX     H
        MOV     C,A
        CALL    CO
        DCR     B
        JNZ     RNAM1
        JMP     CRLF
;
;PRINT HEADER OF FILE
;--------------------
PHDR:   CALL    CRLF
        INX     H
        MVI     D,COMLE
        JMP     TEXT

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;  POMOCNE PROGRAMY
;
; CT OR PUNCHER ?
PTP?:   PUSH    H
        LXI     H,3020H
        JMP     $+7
;
; CT OR READER ?
PTR?:   PUSH    H
        LXI     H,0C08H
        CALL    IOCHK
        ANA     H
        CMP     L
        POP     H
        RZ              ; YES .. CT
        INX     SP
        INX     SP      ; NESTING
        RET             ; NO FINO
;TEXTY PRO OBSLUHU
;-----------------
TXIMM:  XTHL
        MOV     A,M
        ANI     7FH
        MOV     C,A
        CALL    CO
        MOV     A,M
        RLC
        INX     H
        JNC     TXIMM+1
        XTHL
        RET
;
TXNAM:  CALL    TXIMM
        DB      ' NAME'
        DB      CR,LF
        DB      ':' OR 80H
        RET

;
;NULL OUTPUT BUFFER
;------------------
NULBF:  LXI     H,BOUT-1
        PUSH    H
        MVI     A,LENGHT
        INX     H
        MVI     M,0
        DCR     A
        JNZ     $-4
        POP     H       ;(BLOCK TYP) ADRM
        RET

BREAK:  CALL    CSTS
        RZ
        CALL    CI
        JMP     ETX?

;CTI A VYPIS ZNAK
ECHO:   CALL    CINCR
        RZ
ETX?:   CPI     ETX
        RNZ
        CALL    CLSTP   ;CLOSE & STOP
        JMP     NEXT    ;BREAK=>C

;DISPLAY "PLAY"
PLAY:   CALL    TXIMM
        DB      'PLAY'
        DB      ' ' OR 80H
RECO:   CALL    DONE
        JMP     START

;DISPLAY "RECORD"
RECOR:  CALL    TXIMM
        DB      CR,LF
        DB      'RECORD'
        DB      ' ' OR 80H
;
DONE:   CALL    TXIMM
        DB      ' DONE','?' OR 80H
ECHOCR: CALL    ECHO
        PUSH    PSW
        CALL    CRLF
        POP     PSW
        RET


;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;  FILE OPERATIONS LEVEL
;
;SERACH BLOCK IN TAPE
;--------------------
SEARCH: CALL    BUADR
SEAR1:  MVI     C,'#'   ;ERROR
        CC      CO
        CALL    READF
        JC      SEAR1   ; SERACH ERROR
        JMP     RIB2
;
; BUFFER ADR
BUADR:  LDA     JOIN    ;INPUT OR OUTPUT ?
        ORA     A
        LXI     H,BOUT-1
        RNZ             ;OUTPUT
        LXI     H,BIN-1
        RET
;

; READ INPUT BUFFER
;--------------------
RIB:    PUSH    D
        PUSH    B
        LHLD    BNI
        INX     H
        SHLD    BNI
        LXI     H,BIN-1
        CALL    READ
        JC      ERRD    ;ERROR
        CALL    NUFIL   ; NUMBER O.K. ?
        JNZ     ERRD    ; BLOCK ERROR
RIB1:   POP     B
        POP     D
RIB2:   MOV     A,M     ;BLOCK  TYP
        CPI     CAN     ;VOLUME NAME
        RZ
        CPI     SOH     ;FILE NAME
        RET             ;(HL)..BLOCK TYP
;ERROR READ
ERRD:   CALL    STOP    ;# VERS."E"#
        CALL    TXIMM
        DB      ' ERROR/N'
        DB      '?' OR 80H
        CALL    ECHO    ;CONTINUE
        CPI     'N'
        JZ      ERRD1
        CALL    TXIMM
        DB      ' BACK'
        DB      ' ' OR 80H
        CALL    PLAY
ERRD0:  LXI     H,BIN-1 ;INPUT BUFFER
        CALL    READF
        JC      ERRD    ;NEXT ERROR
        CALL    NUFIL
        JNZ     ERRD0   ;NEXT BLOCK
ERRD1:  CALL    CRLF
        LXI     H,BIN-1
        JMP     RIB1

;WRITE OUTPUT BUFFER
WOB:    PUSH    D
        LHLD    BNO
        INX     H
        SHLD    BNO
        XCHG
        LXI     H,BOUT-1
        CALL    WRBLO
        POP     D
        RET
;
; NUMBER FILE O.K. ?
;
NUFIL:  LDA     BNI
        CMP     E
        RNZ             ;NO
        LDA     BNI+1
        CMP     D
        RET
;
;GET BYTE FROM CASSETTE
;----------------------
GET@:   PUSH    B
        PUSH    D
        PUSH    H
        LDA     @IF1    ;WAS OPEN ?
        ORA     A
        CZ      FIND    ;NO THEN FIND
        LHLD    ADRI
GET0:   INX     H
        MOV     A,L     ;WAS EMPTY
        CPI     BIEND AND 0FFH
        MOV     A,M
        SHLD    ADRI
        JZ      GET1    ;<A>..BYTE
        ORA     A       ;NCY
        JMP     GETEX
GET1:   LDA     BIN-1
        CPI     EOT@    ; "CLOSE" BLOK?
        JZ      GET2
        CALL    RIB
        JNZ     GET0    ;END OF FILE
GET2:   MVI     A,SUBS
        STC
GETEX:  POP     H
        POP     D
        POP     B
        RET
;
;PUT BYTE TO CASSETTE
PUT@:   PUSH    B
        PUSH    D
        PUSH    H
        LDA     @OF1    ; WAS OPEN
        ORA     A
        PUSH    B
        CZ      OPEN    ;IF NO THEN DO
        POP     B
        LHLD    ADRO
        INX     H
        MOV     M,C     ;SAVE
        SHLD    ADRO
        MOV     A,L
        CPI     (BOEND AND 0FFH) - 1
        CZ      WOB     ;NEXT
        LDA     BOUT-1
        CPI     'B'     ;BINAR DUMP?
        JZ      PUTEX
        LDA     MODE
        ANI     2       ;BIN.FILE?
        JNZ     PUTEX
        MOV     A,C     ;CLOSE CHAR.?
        CPI     SUBS
        CZ      CLOSE
PUTEX:  POP     H
        POP     D
        POP     B
        MOV     A,C
        ORA     A       ;NCY
        RET

;
;
; LOAD BINARY DATA FROM TAPE TO MEMORY
;
LOAD:   CALL    FIND    ;OPEN FILE
        MVI     A,'B'   ;BINAR
        STA     BIN-1
        CALL    START
LO1:    CALL    RICH
        ORA     A       ; BLANK?
        JZ      LO1
        SUI     '<'
        JNZ     ERSTP   ;#NOT BINARY FORMAT
        MOV     B,A     ;SUM
        CALL    RADR@
        SHLD    EADR    ;LAST
        XCHG
        CALL    RADR@   ;LAST
        SHLD    SADR    ; START ADR
        CALL    RICH
        CPI     '>'
        JNZ     ERSTP   ;#NOT BINARY
        CALL    CHECK
        MVI     B,0     ;CLEAR
LO2:    CALL    RICH
        MOV     M,A
        CALL    HILO
        JNC     LO2
        CALL    CHECK
        STA     SUM
CLSTP:  XRA     A
        STA     @IF1    ;SLOSE
        CALL    STOP
        JMP     CRLF    ;OK

; CHECK SUM ?
CHECK:  MOV     C,B
        CALL    RICH
        CMP     C
        JNZ     ERSTP
        RET
;
RADR@:  CALL    RICH
        MOV     L,A
        CALL    RICH    ;HL
        MOV     H,A
        RET
;
RICH:   CALL    RI      ;READ & SUM
        JC      ERSTP
        PUSH    PSW
        ADD     B
        MOV     B,A
        POP     PSW
        RET
;
; SAVE BINARY DATA TO TAPE
;
SAVE:   MVI     C,2
        CALL    EXPR    ;FROM TO
        LDA     @OF1
        ORA     A
        CZ      OPEN
        MVI     A,'B'   ;BINAR
        STA     BOUT-1
        CALL    STARW
        MVI     A,80    ; 800MS
        CALL    TIME
        MVI     C,'<'   ;START BYTE
        CALL    POCH
        MVI     B,0     ;ADR-SUM
        POP     H       ;START
        POP     D       ;LAST
        CALL    PADR@
        XCHG
        CALL    PADR@
        MVI     C,'>'
        CALL    POCH
        MOV     C,B     ;SUM OF ADR.
        CALL    POCH
;
        MVI     B,0     ;DATA-SUM
SAV1:   MOV     C,M
        CALL    POCH
        CALL    HILO
        JNC     SAV1
        MOV     C,B     ;SUM
        CALL    POCH
        MVI     C,SUBS
        CALL    POCH    ;END MARK
        JMP     CLOSE
;
PADR@:  MOV     C,L
        CALL    POCH
        MOV     C,H
;
POCH:   MOV     A,C     ;PUNCHER AND SUM
        ADD     B
        MOV     B,A
        JMP     PO

;

SINC:   IN      UDATA
SINC1:  MVI     A,1     ; 10 MS
        CALL    TIME
        CALL    BREAK
        IN      USTAT
        RLC
        JC      SINC    ;WAIT IF READY
        DCR     C
        JNZ     SINC1
        RET
;
; READ BLOCK (HL-BUF.ADR)
; OUT (DE-BLOCK &FILE COUNTER; CY=1 ERROR)
;
READF:  XRA     A       ;FIND MODE SET
        STA     FND
READ:
RBLOK:  PUSH    B
        PUSH    H
        CALL    START   ;MOTION
RBLG:   MVI     C,1     ; WAIT 10MS NOT READY
        CALL    SINC    ; START BLOCK
RBL2:   MVI     C,3     ; 3*PREAMBLE
RBL3:   CALL    SERIN
        CPI     PREAM
        JNZ     RBLG    ; GAP
        DCR     C
        JNZ     RBL3
        MVI     A,':'
        STA     TVBEG
        LXI     B,(LENGHT+1) AND 0FFH   ;B=0,C=LENGHT
        CALL    SERIM   ;READ DATA
        MVI     C,'*'
        LDA     FND     ;FIND MODE?
        ORA     A
        JNZ     RBL20   ;NO-READ
        MVI     C,' '
RBL20:  LXI     H,TVBEG
        MOV     M,C
        INX     H
        MVI     M,'"'
        INX     H
        MVI     C,NAMLE
RBL33:  CALL    SERIM
        MVI     M,'"'
        INX     H
        MVI     M,20H
        INX     H
        CALL    SERIN
        MOV     E,A
        CALL    HEXMEM  ; REG 'E' -> MEM HEX
        CALL    SERIN
        MOV     D,A
        MVI     A,' '
        STA     FND
        MOV     C,B     ;CHECK SUM
        CALL    SERIN
        SUB     C
        POP     H
        POP     B
        SHLD    ADRI    ;BEG. ADR
        PUSH    PSW     ;SAVE ZERO FLG
        LDA     BIN-1   ;#VERS "E"#
        CPI     'B'     ;#
        CNZ     STOP    ;#
RBL5:   POP     PSW     ;IF ZERO ..O.K
        RZ
        STC
        RET             ;ELSE ...ERROR
;
;WRITE BLOCK (HL-ADR,DE-BLOCK &FILE NUMBER)
;
WRBLO:  PUSH    B
        PUSH    H
        PUSH    D
        CALL    STARW   ;START WRITE
        MVI     A,80    ; 800/100 MS
        CALL    BTIME
        CALL    SEROP
        CALL    SEROP
        CALL    SEROP   ;PREAMBLE
        LXI     B,(LENGHT+1) AND 0FFH
        CALL    SEROM   ;DATA
        LXI     H,WRNM
        MVI     C,NAMLE
        CALL    SEROM   ;NAME
        POP     D
        MOV     A,E
        CALL    SEROUT  ;BLOCK-NUMBER
        MOV     A,D
        CALL    SEROUT  ;FILE-NUMBER
        MOV     A,B
        CALL    SEROUT  ;CHECK SUM
        CALL    SEROP
        XRA     A
        CALL    SEROUT  ;SENTINEL
        LXI     H,TVBEG
        CALL    HEXMEM
        POP     H
        POP     B
        SHLD    ADRO    ;SET ADR
        MVI     A,1     ; 10 MS
        CALL    TIME
        LDA     BOUT-1  ;#VERS "E"#
        CPI     'B'     ;#
        RZ              ;#
STOP:   MVI     A,10H
        OUT     UMODE
        RET
;
; ROUTINES
;
; 'E' REG HEX TO MEMORY, CLEAR TO END LINE
HEXMEM: MOV     A,E
        RRC
        RRC
        RRC
        RRC
        CALL    HEXC
        MOV     A,E
        CALL    HEXC
        MVI     A,39    ; LINE LENGTH-1
HEXM1:  MVI     M,' '
        INX     H
        CMP     L       ; END LINE ?
        JNC     HEXM1
        RET

; DISPLAY HEX CIFF.
HEXC:   ANI     0FH
        CALL    HXASC
        ANI     3FH
        MOV     M,A
        INX     H
        RET
;
SEROM:  MOV     A,M     ;FROM MEMORY
        INX     H
        CALL    SEROUT  ;TO:CT:
        DCR     C
        JNZ     SEROM
        RET             ;ALL

SEROP:  MVI     A,PREAM ;BLOCK-MARK

SEROUT: PUSH    PSW
        ADD     B
        MOV     B,A     ;CHECK SUM
        CALL    BREAK
SERO:   IN      USTAT
        ADD     A
        JP      SERO
        POP     PSW
        OUT     UDATA
        RET
;
SERIM:  CALL    SERIN   ;READ TO MEMORY
        MOV     M,A
        INX     H
        DCR     C
        JNZ     SERIM
        RET

SERIN:  CALL    BREAK
        IN      USTAT
        RLC
        JNC     SERIN
        IN      UDATA
        PUSH    PSW
        ADD     B
        MOV     B,A
        POP     PSW
        RET
;
; TIME ROUTINES
;
BTIME:  MOV     B,A     ; * 10 MS
        MOV     A,M     ; 'B' ?
        CPI     'B'
        MOV     A,B
        JNZ     TIME
        RRC
        RRC
        RRC             ; /8

TIME:   PUSH    B       ; ACC*10MS (TCY=500NS)
TIME1:  LXI     B,800+255
TIME2:  DCX     B       ;( 5)
        INR     B       ;( 5)
        DCR     B       ;( 5)
        JNZ     TIME2   ;(10) 10MS LOOP @ 12.5US
        DCR     A
        JNZ     TIME1
        POP     B
        RET
;
;       MICRO-BASIC FORMAT
;
BB:     MVI     C,1     ;1. ADR
        CALL    EXPR
        CALL    PLAY
        MVI     C,50    ; 500MS GAP
BB1:    CALL    SINC
        MVI     C,'*'
        CALL    CO
        CALL    SERIN
        CPI     'B'     ; BASIC RECORD?
        LXI     B,10    ; 100MS & CLEAR SUM
        JNZ     BB1
        CALL    SERIN   ;NAME
BB2:    MOV     C,A
        CALL    CO
        CALL    SERIN
        CPI     CR
        JNZ     BB2
        CALL    SERIN
        MOV     E,A
        CALL    SERIN
        MOV     D,A
        LXI     H,-40F0H        ;OFFSET
        DAD     D
        POP     D
        DAD     D
        XCHG            ;DE-LAST ADR
BB3:    CALL    SERIN
        MOV     M,A
        CALL    HILO
        JNC     BB3
        MOV     C,B
        CALL    SERIN
        CMP     C
        JZ      STOP    ;#VERS."E"#
ERSTP:  CALL    CLSTP   ;#
        JMP     ERROR   ;#
@ENDPR  EQU     $
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        ORG     @R@
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; SYSTEM RAM SAPI-1  M4
;
RST1:   DS      21      ;RESTART VECTOR
;<<... USER & MONITOR STACK
;
;
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        ORG     @R@+090H
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; MONITOR DATA
;
MSTAK:  DS      2       ; SAVE REGISTERS
ACSAV:  DS      2
BCSAV:  DS      2
DESAV:  DS      2
HLSAV:  DS      2
PCSAV:  DS      2
SPSAV:  DS      2
;
BRAD:   DS      2
INSTR:  DS      1
BRAD2:  DS      2
INST2:  DS      1
LASTC:  DS      1       ;LAST CODE "REPEAT"
CADR:   DS      2       ; CURSOR ADR
CHAR:   DS      1       ; CODE
FLAG:   DS      1       ; FLAG MEMBR
LIMIT:  DS      2       ; TIME LIMIT FOR AUTO REPEAT
@BT:    DS      1
@PED:   DS      1
UADR:   DS      2       ;USER ADR
SADR:   DS      2       ; START ADR
EADR:   DS      2       ; END ADR
SUM:    DS      1

;*******************************
;MONITOR PLUS DATA
JOIN:   DS      1
FNAME:  DS      11
BNO:    DS      1       ;BLOCK NUMSER,FILE NUMBER
BTO:    DS      1
BNI:    DS      1       ; --- " ---
BTI:    DS      1
ADRO:   DS      2
ADRI:   DS      2
PBITM:  DS      2
FND:    DS      1       ; FIND FLAG

;-------------------------
;       USER I/O DEVICE
;
CILOC:  DS      3
COLOC:  DS      3
R1LOC:  DS      3
R2LOC:  DS      3
P1LOC:  DS      3
P2LOC:  DS      3
LILOC:  DS      3
CSLOC:  DS      3
;******************************
;<< EXTERNE OVLADANE FLAGY: >>
;******************************
MODE:   DS      1       ;CO-MODE
@IF1:   DS      1
@IF2:   DS      1
@OF1:   DS      1
@OF2:   DS      1
LINE:   DS      1       ;LINE
COLUM:  DS      1       ;COLUMN
RESL:   DS      1       ;RESERVE
UBYTE:  DS      1       ;USER BYTE (REALTIME..)
@SFLG:  DS      1       ;#0..NO STOP
EXSER   EQU     $-MODE  ;EXTERNAL SERVICE
IOBYT:  DS      1       ;I/O CONTROL
MEMTOP: DS      2       ;MEMTOP "RAM"

;-------------------------
; I/O BUFFERS
        DS      1       ; BLOCK LABEL
BOUT:   DS      255     ;BLOCK LENGHT
BOEND   EQU     $
;
        DS      1       ; BLOCK LABELS
BIN:    DS      255     ;BLOCK  LENGHT
BIEND   EQU     $
;
WRNM:   DS      11
;=============================
        ORG     @R@ + 300H
;=============================
; "MAT" ARRAY
        DS      0FFH
;=============================
        ORG     @R@ + 400H
;=============================
; SYSTEM OR USER PROGRAMS
;---->>>>>>>>>>>
;
;
;
        END     ;[P]

ÚVOD | Novinky | 8 Bitů | Příslušenství | Drobnosti | TTL | Kontakt


SAPI-1 | ONDRA | PMI-80 | PMD-85 | klony PMD-85 | klony SM50/40 | PETR | PLAN-80A | IQ151 | TNS | FK-1 | HVĚZDA | SP 830 | PCS 1-QR6000


ZPS | Technické prostředky | Programové vybavení | Dokumentace


8 bity / SAPI-1 / Programové vybavení / V4.x / ASM MONITOR+ MIKOS-1



SAPI.cz - web o československých osmibitech, zejména SAPI-1. Provozuje EC1045 od roku 2011
Za korekce češtiny dekuji: MELSOFTovi, Silliconovi, Martinu Lukáškovi a NOSTALCOMPovi

Když začínám blbnout z 8bitů tak se chodím léčit mezi otaku.
Animefest.cz