Home   • Persönlich •

< Persönlich

< Persönlich: Projects


> Intro

> Hardware

• Manual

> Session


 

— Projects: ADA, Manual —

ADA-950225 Manual, Command Description

The ADA dedicated commands to control the ADA-950225 are described below. They are an integral part of the UZE BIOS Version 2.1a. Version 2.1a is a super-set of UZE V.2.01. UZE V.2.01 commands are described in detail in the UZE User's Guide (UZE > Manual).

After startup of ADA-950225, the HPMAN label is copied into ILoopV. Execution starts with Dumy-Ap, which looks in ILoopV for the application to run.

Connect the "X-AXIS" output of HP3581C to "IN-X" and "Y-AXIS" to "IN-Y" of ADA-950225. The "OUT-X" must be connected to the X-channel input of an oscilloscope and "OUT-Y" to the Y-channel.

Connect a spectrum rich function signal to the input of the Selective Voltmeter / Wave Analyzer HP3581C "INPUT" terminal, select "SWEEP MODE" "MAN" and turn slowly "MANUAL VERNIER" knop clockwise. The time base of the oscilloscope should be set to X/Y-Mode. Adjust X and Y channel input attenuators and center the image until a satisfactory spectrum can be seen.

The HPMAN-loop can be terminated by HPStop (see below) and then activating the NMI (right switch on ADA-950225). The loop can be re-entered with the ADARun extended command (see below).


HP3581C Control Commands

Rev(ision — Syntax: aRev.
Returns the revision number of the dedicated ADA routines. It uses the extended A-command Ver(sion at its entry label Versi0.

HPStop — Syntax: aHPStop. (do not forget to toggle NMI).
In the ADA-system, DumyAp is HPMan. HPMan constantly writes the analog input of the Y-input into memory location 32,768 for 256 bytes and overwritting the old contents by the new measured values. With HPMan running, it would not be possible to use the same memory for the other ADA dedicated procedures.

HPStop resets the IQRS (instruction queue return stack) and initialises it with the UZE DumyAp address. After HPStop is called, a NMI (non maskable interrupt) will start DumyAp.

Use HPStop and toggle NMI switch (right) before using any other ADA dedicated program. HPMan can be restarted with the ADARun command (see below).

Screenshot

Terminal screen (see UZE Terminal) after aHPStop executed and NMI was toggled. The UZE can be fully used.

HPRep — Syntax: aHPRep{,n}.
This command controls the Selective Voltmeter / Wave Analyzer HP3581C. The Analyzer must be set so Sweep-Mode REP(etitive, PEN and TRG of ADA-950225 must be connected to "PEN LIFT" and "EXT. TRIG" respectively. The recorder X- and Y-axis outputs must be connected to In-X and In-Y respectively. The X- and Y-Out terminals should be connected to the appropriate inputs of an oscilloscope. The oscilloscope's timebase must be set to X/Y-mode.

As soon as the HP3581C lifts the pen, ADA-950225 triggers the sweep. The number of sweeps specified ({n}: n=[1;127], default is 1) will be taken. The X-input reads the ramp voltage that sweeps the analyzer and uses the digitized voltage to point to a memory location. The Y-input reads the meter and stores the digitized voltage at the memory location specified by the ramp voltage on the X-input.

After the specified number of sweeps have been taken, the X-output recreates the sweep ramp voltage, points to the memory location and outputs that value on the Y-channel. Thus, frequency and voltage are synchronised. The memory readout is performed by the HPShow procedure (see below). It can be stopped by either toggeling the PEN-switch to override (down position) or by removing the PEN input. The Analyzer Sweep-Mode should be changed to "OFF".

HPShow — Syntax: aHPShow.
Outputs ramp voltage on Out-X. This ramp is used to point to the Y-channel memory. The value at that memory location is output on Out-Y. The loop can be stopped by toggeling PEN to override (down) position.


Sampling Commands

SampleChop — Syntax: aSampleChop.
Samples voltage at Y-In and X-In in about 100 ms and stores Y values in memory from 32,768 to 33,023, the X values from 33,024 to 33,279 in chop-mode, then stops. Chop-mode means that both channels are sampled simultanously; well, not actually simultanously but alternately: Y-value, X-value, Y-value, X-value …

SampleAlt — Syntax: aSampleAlt.
As SampleChop, but first takes 256 samples from Y-In, then from X-In. This is the alternate mode.

SampleY — Syntax: aSampleY.
Takes 256 samples from Y-In and stores values from memory location 32,768 hence.

SampleX — Syntax: aSampleX.
Takes 256 samples from X-In and stores values from memory location 33,024 hence.


Sweep Commands

SweepChop — Syntax: aSweepChop.
Outputs memory content at 32,768 to Out-Y and 33,024 to Out-X in chop mode. First, byte-0 for channel-Y, then byte-0 for channel-X is output. Then, byte 1 from channel-Y, and so on. Sweeping can be terminated by toggeling PEN to override (down) position.

SweepAlt and SweepBurst — Syntax: aSweepAlt. and aSweepBurst
Outputs memory content at 32,768 to Out-Y and 33,024 to Out-X in alternate or burst mode. First, 256 bytes of Y-memory are output on Y-Out, then all 256 bytes from the X-memory on X-Out. Then is the Ys turn again. This gives a burst-like appearance on the oscilloscope, hence the alternate name Sweep-Burst. Sweeping can be terminated by toggeling PEN to override (down) position.

SweepY — Syntax: aSweepY.
Outputs memory content from 32,768 to 33,023 on Y-Out. Sweeping can be terminated by toggeling PEN to override (down) position.

SweepX — Syntax: aSweepX.
Outputs memory content from 33,024to 33,279 on X-Out. Sweeping can be terminated by toggeling PEN to override (down) position.


Sample and Hold Commands

SaHChop — Syntax: aSaHChop.
Sample and Hold in Chop-Mode. Samples Y-In and X-In in chop-mode exactly as SampleChop (which routine it uses). After the scan, both channels are output in chop-mode, exactly as SweepChop (which routines it uses) does. Sweeping can be terminated by toggeling PEN to override (down) position.

SaHAlt — Syntax: aSaHAlt.
Sample and Hold in Alternate-Mode. Takes 256 samples on Y-In, then on X-In exactly as SampleAlt (which routines it uses) does. After the scan, both channels are output in chop-mode, exactly as Sweep-Chop (which routines it uses) does. Sweeping can be terminated by toggeling PEN to override (down) position. While Y is sampled, LED is lit bright, while X-channel is being samled, LED is lit half bright.

SaHY — Syntax: aSaHY.
Sample and Hold Y-channel. Samples Y-Input for 256 values and stores it in memory from 32,768 hence (see SampleY). During the sample, the LED lights. After data aquisition, the memory content is output on Y-channel (see SweepY). Sweeping can be terminated by toggeling PEN to override (down) position.

SaHX — Syntax: aSaHX.
Sample and Hold X-channel. Samples X-Input for 256 values and stores it in memory from 33,024 hence (see SampleX). During the sample, the LED lights. After data aquisition, the memory content is out-put on X-channel (see SweepX). Sweeping can be terminated by toggeling PEN to override (down) position.


Scanning Commands

ScanChop — Syntax: aScanChop.
Samples Y- and X-inputs and stores the measured value in the respective memory location. During the time the ADC is busy converting, the Y- and X-memory contents are output on Y-out and X-out in chop mode. (ADC worst case conversion time is 260 µs). ScanChop can be terminated by toggeling PEN to override (down) position.

ScanY — Syntax: aScanY.
Outputs memory from 32,768 to 33,023 on Y-Out while ADC is busy converting Y-In and storing it at 32,768 hence. ScanY can be terminated by toggeling PEN to override (down) position.

ScanX — Syntax: aScanX.
Outputs memory from 33,024 to 33,279 on X-Out while ADC is busy converting X-In and storing it at 33,024 hence. ScanX can be terminated by toggeling PEN to override (down) position.


Recording and Play Commands

Record and RecordMono — Syntax: aRecord. and aRecordMono.
Reads Y-In and converts it for 31,680 bytes to 32,768. This gives approximately 8 seconds worth of data. During reecording, LED is on.

RecordStereo — Syntax: aRecordStereo.
Records Y-In and X-In in chop mode for 15,840 bytes each and stores the Y-values from 32,768 to 48,607 in memory and X-values from 48,608 to 64,447. The LED is lit while recording.

PlayMono and PlayBack — Syntax: aPlayMono. and aPlayBack.
Outputs values from memory 32,768 to 64,774 on Y- and X-channel in parallel. After 31,680 bytes are output, restarts playing back at 32,768. Play can be stopped by toggeling PEN to override (down) position.

PlayStereo — Syntax: aPlayStereo.
Outputs memory values from 32,768 to 48,607 on Y-Out and from 48,608 to 64,447 on X-Out in chop mode. After memory is dumped, restarts at 32,768 and 48,608, respectively. Play can be stopped by toggeling PEN to override (down) position.


Data Logging Commands

LogSingle — Syntax: aLogSingle,m,t.
Logs input of channel-Y for 31,680 bytes from 32,768 to 64,447. The delay between 2 samples can be set with either 6.5 µs or 425.9 ms resolution. Log time can be thus selected from 260 ms to over 10 days. Use as 1 channel data logger. LogSingle can be prematurely aborted by toggeling PEN to override (down) position. The system variable CAcntr = AUXY,3 holds the number of remaining loops.

m = "S" or "L"
t = delay multiplier [1;65,535] (0=65,536)
Calculation of delay:
Case m = S (short): t x 6.5 µs x 31,680
Case m = L (long):   t x 425.9 ms x 31,680

LogDouble — Syntax: aLogDouble,m,t.
Logs inputs of Y- and X-channels in chop mode for 15,840 bytes each. Y-channel values are stored from 32,768 to 48,607 and X-channel data from 48,608 to 64,447. The delay between 2 samples can be set with either 6.5 ┬Ás or 425.9 ms resolution. Log time can be between 200 ms and over 5 days. Use as a 2 channel data logger. LogDouble can be prematurely aborted by toggeling PEN to override (down) position. The system variable CAcntr = AUXY,3 holds the number of remaining loops.

m = "S" or "L"
t = delay multiplier [1;65,535] (0=65,536)
Calculation of delay:
Case m = S (short): t x 6.5 µs x 15,840
Case m = L (long):   t x 425.9 ms x 15,840

PenBit — Syntax: aPenBit.
PenBit is a 1 bit recorder. The PEN input is read for 4096 bits. Each 8 bits are stored as bytes from 33,280 to 33,791 for 512 bytes. After all 4096 bits are read, PenBit terminates. Read is quite fast and no premature abort facility is implemented. 47 ms are needed to get the 4096 bits.

TrgBit — Syntax: aTrgBit.
512 bytes from 33,280 to 33,791 are sent as 4096 bits to the TRG output. After all bits are output, restarts at 33,280. This loop can be interrupted by toggeling PEN to override (down position).


Memory Management Commands

XopyXY — Syntax: aCopyXY.
Copies Y-buffer at 32,768 to X-buffer at 33,024 (256 bytes).

XopyYX — Syntax: aCopyYX.
Copies X-buffer at 33,024 to Y-buffer at 32,768 (256 bytes).

SwapXY — Syntax: aSwapXY.
Copies Y-buffer at 32'768 temporarily to 33'280, then copies X-buffer at 33,024 to Y-buffer at 32,768. Finally, copies temporary Y-buffer at 33'280 to X-buffer at 33,024. This exchanges the X- and Y-buffers (256 bytes each). The first half of the PenBit-buffer at 33,280 is overwritten by the Y-buffer data.

Sine — Syntax: aSine.
Fills Y-buffer from 32'768 to 33'023 with a 1 Hz full swing sine wave function.
Note: PowerBASIC 3.20 program FUNCTGEN is a more complete function generator with amplitude, offset and frequency options. A data file of 256 bytes is generated. This file can be loaded into the appropriate memory.

Ramp — Syntax: aRamp.
Fills Y-buffer from 32,768 to 33,023 with a 1 Hz full swing ramp function.
Note: PowerBASIC 3.20 program FUNCTGEN is a more complete function generator with amplitude, offset and frequency options. A data file of 256 bytes is generated. This file can be loaded into the appropriate memory.

Triangle — Syntax: aTriangle.
Fills Y-buffer from 32,768 to 33,023 with a 1 Hz full swing triangle function.
Note: PowerBASIC 3.20 program FUNCTGEN is a more complete function generator with amplitude, offset and frequency options. A data file of 256 bytes is generated. This file can be loaded into the appropriate memory.

Square — Syntax: aSquare.
Fills Y-buffer from 32,768 to 33,023 with a 1 Hz full swing square wave function.
Note: PowerBASIC 3.20 program FUNCTGEN is a more complete function generator with amplitude, offset and frequency options. A data file of 256 bytes is generated. This file can be loaded into the appropriate memory.

Pulse — Syntax: aPulse.
Fills Y-buffer from 32,768 to 33,023 with a 1 Hz full swing pulse function of 10% duty cycle (10% on, 90% off).
Note: PowerBASIC 3.20 program FUNCTGEN is a more complete function generator with amplitude, offset and frequency options. A data file of 256 bytes is generated. This file can be loaded into the appropriate memory.

InvertY — Syntax: aInvertY.
Inverts data in Y-buffer from 32,768 to 33,023.

InvertX — Syntax: aInvertX.
Inverts data in X-buffer from 33,024 to 33,279.


ADA-950225 Source Listing: Z80 Source Listing of ADA Commands

The ADA dedicated command and control software for the ADA-950225 is listed below. It is an integral part of the UZE BIOS Version 2.1a. Version 2.1a is a super-set of UZE V.2.01. UZE V.2.01 commands are described in detail in the UZE User's Guide. Only the ADA-specific routines are shown here.

;===========================================================================
; ADA-950225 SPECIFIC ROUTINES
;===========================================================================
;
; REVISION - Revision: returns version number of Dedicated ADA routines
;            Text must end with chr$(255). Uses VER to issue string.
;   Syntax: aRev.
;---------------------------------------------------------------------------
;
Revisi: dw        HPSTOP                   ;next word
        db        'REv'                    ;REV
        ld        hl,RevisN                ;HL=text start
        jp        Versi0
RevisN: db        cr,lf
        db        'ADA-950225 Control Software, '
        db        'Rev.1.00; 951103 (c) HoroSoft, '
        db        'CH-3952 Susten.',cr,lf,255
;
;
;=============== THIS IS THE ETERNAL LOOP ==================================
; HP3581C Sweep Mode MANual is the infinite loop
; DACs are reset thus that on both channels 0Vdc are output and LED off
; After that, the X- and Y-inputs are constantly scanned and output.
; Loops eternally. Can be stopped by writing DumyAp addr into ILoopV.
; (See HPStop and ADARun)
;---------------------------------------------------------------------------
;
HPMAN:  call      HPInit           ;initialize ADA-950225
        ld        hl,ADABuY        ;start of buffer
        ld        d,h
        ld        e,l              ;DE is set as HL
;
;---- Start ADC for both axis at the same time
;
        ld        a,StrtXY         ; 7 start both to synchronize axes
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7 deselect all devices
        out       (piobd),a        ;11
;
;==== Loops here as long as PEN is normal (up-position) and (ILoopV)=HPMAN
;
;---- Get interrupts, if active, read X and Y channels, else display
;
HPMAN1: in        a,(piobd)        ;11 get interrupts
        and       ChkXY            ; 7 channels are synchronized
        jr        nz,HPMAN2        ;1/7
        PAM3I                      ;54 if interrupts, set PIO-A to input
        ld        a,ReadX          ; 7 enable ADC-X
        out       (piobd),a        ;11
        in        a,(pioad)        ;11 get ramp value
        ld        l,a              ; 4 HL points to memory
        ld        a,ReadY          ; 7 enable ADC-Y
        out       (piobd),a        ;11
        in        a,(pioad)        ; 7 get level value
        ld        (hl),a           ; 7 store level
        ld        a,StrtXY         ; 7 restart both ADCs
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7 deselect all devices
        out       (piobd),a        ;11
        PAM3O                      ;54 set PIO-A to output
;
;---- Output one X-/Y-position for oscilloscope: first, synthesize ramp
;
HPMAN2: ld        a,e              ; 4 get address
        out       (pioad),a        ;11 put ramp data onto PIO-bus
        ld        a,EnablX         ; 7 enable DAC-X, synthesize ramp
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7 deselect all devices
        out       (piobd),a        ;11
;
;---- now output measured and stored value
;
        ld        a,(de)           ; 7 get value at ramp position
        out       (pioad),a        ;11 put value onto PIO-bus
        ld        a,EnablY         ; 7 enable DAC-Y, recreate data
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7 deselect all devices
        out       (piobd),a        ;11
        inc        e               ; 4 next read-memory position
;
;---- Check PEN OVERRIDE
;
        in        a,(piobd)        ;11 read PEN
        and       ChkPen           ; 7 mask out others than PEN
        jr        z,HPMAN1         ;1/7 OVERRIDE=GND=1
;
;==== Loops here as long as PEN is OVERRIDE and (ILoopV)=HPMAN
;
HPMAN3: ld        a,l              ; 4 get adress
        out       (pioad),a        ;11 synthesize ramp
        ld        a,EnablX         ; 7 enable X-channel
        out       (piobd),a        ;11 ramp
        ld        a,TrigOn         ; 7 inhibit all devices, put LED on
        out       (piobd),a        ;11
        ld        a,(hl)           ; 7 get value
        out       (pioad),a        ;11 send it
        ld        a,EnablY         ; 7 enable Y-channel
        out       (piobd),a        ;11
        ld        a,TrigOn         ; 7 deselect all devices, LED on
        out       (piobd),a        ;11
        inc       l                ; 4 next address
        jr        nz,HPMAN3        ;1/7 repeat 1 sweep
;
;---- Check PEN toggled from OVERRIDE to normal up position
;
        in        a,(piobd)        ;11 get status
        and       a,ChkPen         ; 7
        jr        nz,HPMAN3        ;1/7 PEN=GND=1
;
;---- If PEN switch in up position (PEN=5V=0), read inputs again
;
        jr        HPMAN1           ;12 loop eternally
;
;
; HPINIT - SUBROUTINE Initialize ADA-950225. PIO-A is set to output, PIO-B
;          to input (bits 5 thru 7) and output (bits 0 thru 4)
;---------------------------------------------------------------------------
;
HPInit: push      af               ;save only register used
        PBM3IO                     ;PIO-B set
        PAM3O                      ;PIO-A to output
        xor       a                ;0
        out       (pioad),a        ;0 onto bus
        ld        a,EnabXY         ;enable both DAC, output 0Vdc
        out       (piobd),a
        ld        a,DeSlct         ;deselect all devices
        out       (piobd),a
        pop       af               ;restore AF
        ret                        ;done
;
;====================== END OF ETERNAL LOOP ================================
;
;
; HPSTOP - Stops HPMan by resetting Instruction Queue Return Stack and
;          initializing IQRS by DumyAp.
;          This command must be used before any scans/samples can be used,
;          because HPMan would overwrite ADABuY and ADABuX.
;
;  Syntax: aHPStop.
;---------------------------------------------------------------------------
;
HPStop: dw        ADARUN
        db        'HPSTOp'
        ld        hl,DumyAp
        call      IQStkA           ;initialize IQRST
        jp        Home
;
;
;  SUBROUTINE empties Instruction Queue Return Stack and puts execution
;    address in HL onto Stack and into ILoopV.
;---------------------------------------------------------------------------
;
IQStkA: ld        a,(SysByt + 6)   ;A=depth of IQRSP
        ld        b,a
IQStk1: call      iqdrop           ;drop item
        djnz      IQStk1           ;until empty
        ld        (SysWrd + 6),hl  ;into ILoopV
        call      iqpush           ;onto return stack
        call      iqpush           ;twice
        ret
;
;
; ADARun - Runs HPREP by resetting Instruction Queue Return Stack and
;         initializing IQRS by HPMan.
;         This command can be used to run ADA-950225 autonomously again.
;         Also, to run HPMan.
;
;  Syntax: aADARun.
;---------------------------------------------------------------------------
;
ADARun: dw        HPREP
        db        'ADARUn'
        ld        hl,HPMan
        call      IQStkA           ;initialize IQRST
        jp        Home
;
;
; HPREP - HP3581C Repetitive Sweep-Mode.
;   Wave Analyzer must be in Sweep-Mode [REP], PEN and TRG connected.
;   If PEN is up, triggers analyzer for one sweep. If more than one sweep
;   is selected, sweeps number of selected times.
;   It then continues at HPShow and shows memory until PEN is toggled.
;
;  Syntax: aHPRep{,n}.  where n=number of repeats [1;127] 
;          (default is 1)
;---------------------------------------------------------------------------
;
HPREP:  dw        HPSHOW
        db        'HPREp'          ;HP on REP Sweep mode
        ld        a,1              ;into param1
        call      FetPar           ;(param1)=repetitions
        ld        a,(SysWrd + 64)  ;get low byte only
        add       a,a              ;needs double, Zaphod may know why
        or        a                ;check 0
        jr        nz,HPRep1        ;ok if > 0
        ld        a,2              ;minimum value
HPRep1: inc       a                ;add one
        and       11111110b        ;must be even
        ld        c,a              ;C is actual loop counter
        call      HPInit           ;initialize ADA
;
;==== Loops here (Turns) times
;---- Wait for PEN high, i.e. HP terminated sweep
;
HPRep2: in        a,(piobd)        ;get status
        and       ChkPen           ;mask INT-X and INT-Y
        jr        nz,HPRep2        ;contact open, end of sweep = 0
;
;---- Wait 0.3 seconds to let filter settle
;
HPRep3: ld        hl,706           ;706 x 0.425 ms = 0.3 s
HPRep4: ld        b,l              ;delay with 0.475 ms resolution
HPRep5: djnz      HPRep5           ;main delay loop
        dec       hl
        ld        a,l
        or        h                ;check HL=0
        jr        nz,HPRep4        ;end of delay - derived from LDelay Sub
        ld        hl,ADABuy        ;start of buffer
        ld        d,h              ;start of buffer
        ld        e,l
;
;---- Now, Sweep can be started
;
        ld        a,TrigOn         ;set TRG high to start sweep
        out       (piobd),a
        ld        a,DeSlct         ;set TRG low, sweep has started
        out       (piobd),a
;
;---- Start ADC for both axis at the same time
;
        ld        a,StrtXY         ; 7 start both to synchronize axes
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7 deselect all devices
        out       (piobd),a        ;11
;
;==== Loops here for one full HP sweep up to 3000 sec = 50 min
;---- Get interrupts, if active, read X and Y channels, else display
;
HPRep6: ld        b,0              ; 7 no read yet
        in        a,(piobd)        ;11 get interrupts
        and       ChkXY            ; 7 channels are synchronized
        jr        nz,HPRep7        ;1/7
        PAM3I                      ;54 if interrupts, set PIO-A to input
        ld        a,ReadX          ; 7 enable ADC-X
        out       (piobd),a        ;11
        in        a,(pioad)        ;11 get ramp value
        ld        l,a              ; 4 HL points to memory
        ld        a,ReadY          ; 7 enable ADC-Y
        out       (piobd),a        ;11
        in        a,(pioad)        ; 7 get level value
        ld        (hl),a           ; 7 store level
        ld        a,StrtXY         ; 7 restart both ADCs
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7 deselect all devices
        out       (piobd),a        ;11
        PAM3O                      ;54 set PIO-A to output
        inc       b                ; 4 we had a read
;
;---- Output one X-/Y-position for oscilloscope: first, synthesize ramp
;
HPRep7: ld        a,e              ; 4 get address
        out       (pioad),a        ;11 put ramp data onto PIO-bus
        ld        a,EnablX         ; 7 enable DAC-X, synthesize ramp
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7 deselect all devices
        out       (piobd),a        ;11
;
;---- now output measured and stored value
;
        ld        a,(de)           ; 7 get value at ramp position
        out       (pioad),a        ;11 put value onto PIO-bus
        ld        a,EnablY         ; 7 enable DAC-Y, recreate data
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7 deselect all devices
        out       (piobd),a        ;11
        inc       e                ; 4 next read-memory position
;
;---- Check if we had at least one read
;
        dec       b                ; 4 0-1=255, 1-1=0
        jr        nz,HPRep6        ;1/7 if we had not had a read, retry
;
;---- Check end of sweep. If not ended, attempt to read ramp and value
;
        in        a,(piobd)        ;11 read PEN
        and       ChkPen           ; 7 mask out others than PEN
        jr        nz,HPRep6        ;1/7 contact is opened at end = 0
;
;---- Check end of all scans
;
        dec       c                ; 4 one full sweep done
        jp        nz,HPRep3        ;13 restart analyzer take another sweep
        jr        HPSho0           ;after all sweeps, continue with HPShow
;
;
; HPSHOW - HP3581C Shows memory content on channel-Y and output ramp on
;          channel-X until PEN is toggled down.
;
;  Syntax: aHPShow.
;---------------------------------------------------------------------------
;
HPShow: dw        SAMCHP
        db        'HPSHOw'
        call      HPInit           ;initialize ADA-950225
HPSho0: ld        hl,ADABuy        ;start of buffer
HPSho1: ld        a,l              ; 4 get adress
        out       (pioad),a        ;11 synthesize ramp
        ld        a,EnablX         ; 7 enable X-channel
        out       (piobd),a        ;11 ramp
        ld        a,DeSlct         ; 7 inhibit all devices
        out       (piobd),a        ;11
        ld        a,(hl)           ; 7 get value
        out       (pioad),a        ;11 send it
        ld        a,EnablY         ; 7 enable Y-channel
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7 deselect all devices
        out       (piobd),a        ;11
        inc       l                ; 4 next address
        jr        nz,HPSho1        ;1/7 repeat 1 sweep
;
;---- ShowIt can be stopped by manually override PEN or by restarting
;     HP3581C by removing [EXT.TRIG] cable
;
        in        a,(piobd)        ;11 get status
        and       a,ChkPen         ; 7
        jr        z,HPSho1         ;1/7 repeat until override (=HP sweeps)
        call      HPInit           ;reset ADA-950225
        jp        Home             ;and call it a day
;
;
; SAMPLECHOP - Samples Y- and X-channel in chop mode for one sweep
;            Routine uses Sample and Hold Chop (SAHCHP), but will not hold
;
;  Syntax: aSampleChop.
;---------------------------------------------------------------------------
;
SamChp: dw        SAMALT
        db        'SAMPLECHOp'
        xor       a                ;reset Hold flag
        ld       (SysBuf + 8),a
        jp       SamCh0
;
;
; SAMPLEALT - Scans Y- and X-channel in alternate mode for one sweep
;        Routine uses Sample and Hold Alternate (SAHALT), but will not hold
;
;  Syntax: aSampleAlt.
;---------------------------------------------------------------------------
;
SamAlt: dw        SAMPLY
        db        'SAMPLEALt'
        xor       a                ;reset Hold flag
        ld        (SysBuf + 8),a
        jp        SamAl0
;
;
; SAMPLEY - Takes one Sample from Channel Y
;
;  Syntax: aSampleY.
;---------------------------------------------------------------------------
;
SamplY: dw        SAMPLX
        db        'SAMPLEy'
        call      HPInit           ;initialize ADA-950225
        PAM3I
        ld        hl,ADABuY        ;buffer start
SampY1: ld        a,StartY         ; 7 start Y only, LED on
        out       (piobd),a        ;11
        ld        a,TrigOn         ; 7 deselect all
        out       (piobd),a        ;11
SampY2: in        a,(piobd)        ;11 get interrupts
        and       01000000b        ; 7 INT-Y
        jr        nz,SampY2        ;1/7
        ld        a,ReadY          ; 7 enable ADC-Y
        out       (piobd),a        ;11
        in        a,(pioad)        ;11 get data
        ld        (hl),a           ; 4 store data byte
        ld        a,DeSlct         ; 7 deselect devices
        out       (piobd),a        ;11
        inc       l                ; 4 next address and flag if 256
        jr        nz,SampY1        ;1/7 if not yet 256, repeat
        jp        Home             ;256 samples taken
;
;
; SAMPLEX - Takes one Sample from Channel X
;
;  Syntax: aSampleX.
;---------------------------------------------------------------------------
;
SamplX: dw        SWPCHP
        db        'SAMPLEx'
        call      HPInit           ;initialize ADA-950225
        PAM3I
        ld        hl,ADABuX        ;buffer start
SampX1: ld        a,StartX         ; 7 start X only, LED on
        out       (piobd),a        ;11
        ld        a,TrigOn         ; 7 deselect all
        out       (piobd),a        ;11
SampX2: in        a,(piobd)        ;11 get interrupts
        and       10000000b        ; 7 INT-X
        jr        nz,SampX2        ;1/7
        ld        a,ReadX          ; 7 enable ADC-X
        out       (piobd),a        ;11
        in        a,(pioad)        ;11 get data
        ld        (hl),a           ; 4 store data byte
        ld        a,DeSlct         ; 7 deselect devices
        out       (piobd),a        ;11
        inc       l                ; 4 next address and flag if 256
        jr        nz,SampX1        ;1/7 if not yet 256, repeat
        jp        Home             ;256 samples taken
;
;
; SWEEPCHOP - Outputs Y and X memory content onto Y- and X-channel in
;                   chop mode. One value each.
;
;  Syntax: aSweepChop.
;---------------------------------------------------------------------------
;
SwpChp: dw        SWEEPB
        db        'SWEEPCHOp'
SwpCh0: call      HPInit           ;initialize ADA-950225
        ld        hl,ADABuX        ;X-buffer at 33024
SwpCh1: dec        h               ; 4 previous page for Y-data
        ld        a,(hl)           ; 7 get Y-data from memory (HL)
        out       (pioad),a        ;11 put Y onto bus
        ld        a,EnablY         ; 7 enable DAC-Y
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7 deselect all devices
        out       (piobd),a        ;11
        inc       h                ; 4 next page for X-data
        ld        a,(hl)           ; 7 get X-data from memory (HL)
        out       (pioad),a        ;11 put X onto bus
        ld        a,EnablX         ; 7 enable DAC-X
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7 deselect all devices
        out       (piobd),a        ;11
        inc       l                ; 4 next address
        in        a,(piobd)        ;11 now read PEN ---- CHECK PEN
        and       00100000b        ; 7  mask out others than PEN
        jr        z,SwpCh1         ;1/7 reloop if not +PEN
        call      HPInit           ;reset ADA-950225
        jp        Home
;
;
; SWEEPBURST - Alternate name for SweepAlt
;
;  Syntax: aSweepBurst.
;---------------------------------------------------------------------------
;
SweepB: dw        SWPALT
        db        'SWEEPBURSt'
        jr        SwpAl0
;
;
; SWEEPALT - Outputs memory on Y- and X-channel in alternate or burst mode
;            until PEN
;
;  Syntax: aSweepAlt.
;---------------------------------------------------------------------------
;
SwpAlt: dw        SWEEPY
        db        'SWEEPALt'
SwpAl0: call        HPInit         ;initialize ADA-950225
        ld        hl,ADABuX        ;buffer X

;---- Start, LED on. Sweeps in 74 t_cycles = 0.0185ms per channel
;
SwpAl1: dec       h                ; 4 previous page for Y-data ---- YYYY
        ld        a,DeSlct         ; 7 deselect all devices
        out       (piobd),a        ;11
        ld        a,EnablY         ; 7 enable DAC-Y
        out       (piobd),a        ;11
SwpAl2: ld        a,(hl)           ; 7 get Y-data from memory (HL)
        out       (pioad),a        ;11 put Y onto bus
        inc       l                ; 4 next address
        jr        nz,SwpAl2        ;1/7 do one full sweep
        inc       h                ; 4 next page for X-data ---- XXXX
        ld        a,DeSlct         ; 7 deselect all devices
        out       (piobd),a        ;11
        ld        a,EnablX         ; 7 enable DAC-X
        out       (piobd),a        ;11
SwpAl3: ld        a,(hl)           ; 7 get X-data from memory (HL)
        out       (pioad),a        ;11 put X onto bus
        inc       l                ; 4 next address
        jr        nz,SwpAl3        ;1/7 do one full sweep
        in        a,(piobd)        ;11 now read PEN ---- PEN ABORT
        and       00100000b        ; 7  mask out others than PEN
        jr        z,SwpAl1         ;1/7 reloop if not +PEN
        call      HPInit           ;reset ADA-950225 if PEN
        jp        Home
;
;
; SWEEPY - Sweeps memory on Y-channel until PEN
;
;  Syntax: aSweepY.
;---------------------------------------------------------------------------
;
SweepY: dw        SWEEPX
        db        'SWEEPy'
SwepY0: call      HPInit           ;initialize ADA-950225
        ld        a,EnablY         ; 7 enable DAC-Y
        out       (piobd),a        ;11
        ld        hl,ADABuY        ;   initialize buffer
SwepY1: ld        a,(hl)           ; 7 get Y-data from memory (HL)
        out       (pioad),a        ;11 put Y onto bus
        inc       l                ; 4 next address
        in        a,(piobd)        ;11 now read PEN
        and       00100000b        ; 7  mask out others than PEN
        jr        z,SwepY1         ;1/7 reloop if not +PEN
        call      HPInit           ;reset ADA-950225
        jp        Home
;
;
; SWEEPX - Sweeps memory on X-channel until PEN
;
;  Syntax: aSweepX.
;---------------------------------------------------------------------------
;
SweepX: dw        SAHCHP
        db        'SWEEPx'
SwepX0: call      HPInit           ;initialize ADA-950225
        ld        a,EnablX         ; 7 enable DAC-Y
        out       (piobd),a        ;11
        ld        hl,ADABuX        ;   initialize buffer
SwepX1: ld        a,(hl)           ; 7 get Y-data from memory (HL)
        out       (pioad),a        ;11 put Y onto bus
        inc       l                ; 4 next address
        in        a,(piobd)        ;11 now read PEN
        and       00100000b        ; 7  mask out others than PEN
        jr        z,SwepX1         ;1/7 reloop if not +PEN
        call      HPInit           ;reset ADA-950225
        jp        Home
;
;
; SAHCHOP - Sample and Hold Chop samples Y- and X-inputs in chop mode,
;           then displays memory content in chop mode until PEN.
;           LED is /3 bright during scan.
;
; Syntax: aSaHChop.
;---------------------------------------------------------------------------
;
SAHChp: dw        SAHALT
        db        'SAHCHOp'
        ld        a,1              ;flag Hold after scan
        ld        (SysByt + 8),a
SamCh0: call      HPInit
        PAM3I                      ;PIO-A to input
        ld        hl,ADABuX        ;start of X-buffer
SamCh1: dec       h                ; 4 previous page
        ld        a,StrtXY         ; 7 start X and Y, LED on
        out       (piobd),a        ;11
        ld        a,TrigOn         ; 7 deselect all
        out       (piobd),a        ;11
SamCh2: in        a,(piobd)        ;11 get interrupts
        and       11000000b        ; 7 INT-X and INT-Y
        jr        nz,SamCh2        ;1/7
        ld        a,ReadY          ; 7 enable ADC-Y
        out       (piobd),a        ;11
        in        a,(pioad)        ;11 get data
        ld        (hl),a           ; 4 store data byte
        ld        a,TrigOn         ; 7 deselect devices
        out       (piobd),a        ;11
        inc       h                ; 4 next page
        ld        a,ReadX          ; 7 enable ADC-X
        out       (piobd),a        ;11
        in        a,(pioad)        ;11 get data
        ld        (hl),a           ; 4 store data byte
        ld        a,DeSlct         ; 7 deselect devices
        out       (piobd),a        ;11
        inc       l                ; 4 next address and flag if 256
        jr        nz,SamCh1        ;1/7 if not yet 256, repeat
HldTst: ld        a,(SysByt + 8)   ;get Hold flag
        dec       a                ;A=1=0: Hold true
        jp        z,SwpCh0         ;End of scans: goto SweepChop
        call      HPInit           ;reset ADA-950225
        jp        Home
;
;
; SAHALT - Sample and Hold Y- and X-channel alternately
;          Takes 256 reads on each channel and maximal speed. LED is on
;          while in sweep mode: bright for Y, half bright for X
;
;  Syntax: aSaHAlt.
;---------------------------------------------------------------------------
;
SAHALT: dw        SAHY
        db        'SAHALt'
        ld        a,1              ;flag Hold after scan
        ld        (SysByt + 8),a
SamAl0: call      HPInit
        PAM3I                      ;PIO-A to input
        ld        hl,ADABuY        ;start of Y-buffer
SAHAY1: ld        a,StartY         ; 7 start Y ---- YYYY
        out       (piobd),a        ;11
        ld        a,TrigOn         ; 7 deselect all
        out       (piobd),a        ;11
SAHAY2: in        a,(piobd)        ;11 get interrupts
        and       01000000b        ; 7 INT-Y
        jr        nz,SAHAY2        ;1/7
        ld        a,ReadY          ; 7 enable ADC-Y
        out       (piobd),a        ;11
        in        a,(pioad)        ;11 get data
        ld        (hl),a           ; 4 store data byte
        ld        a,TrigOn         ; 7 deselect devices, LED on
        out       (piobd),a        ;11
        inc       l                ; 4 next address
        jr        nz,SAHAY1        ;1/7 256 repeats
        inc       h                ; 4 next page, X-memory ---- XXXX
SAHAX1: ld        a,StartX         ; 7 start X, LED on
        out       (piobd),a        ;11
        ld        a,TrigOn         ; 7 deselect all
        out       (piobd),a        ;11
SAHAX2: in        a,(piobd)        ;11 get interrupts
        and       10000000b        ; 7 INT-X
        jr        nz,SAHAX2        ;1/7
        ld        a,ReadX          ; 7 enable ADC-X
        out       (piobd),a        ;11
        in        a,(pioad)        ;11 get data
        ld        (hl),a           ; 4 store data byte
        ld        a,DeSlct         ; 7 deselect devices, LED off
        out       (piobd),a        ;11
        inc       l                ; 4 next address
        jr        nz,SAHAX1        ;1/7 256 repeats
        jp        HldTst           ;End of scans: Test hold flag
;
;
; SAHY - Sample and Hold Y-channel. After one max-speed scan, displays
;        memory until PEN. During Scan, LED lights half bright.
;
;  Syntax: aSaHY.
;---------------------------------------------------------------------------
;
SAHY:   dw        SAHX
        db        'SAHy'
        call      HPInit           ;initialize ADA-950225
        PAM3I
        ld        hl,ADABuY        ;Y-buffer
SAHY1:  ld        a,StartY         ; 7 start Y only, LED on
        out       (piobd),a        ;11
        ld        a,TrigOn         ; 7 deselect all
        out       (piobd),a        ;11
SAHY2:  in        a,(piobd)        ;11 get interrupts
        and       01000000b        ; 7 INT-Y
        jr        nz,SAHY2         ;1/7
        ld        a,ReadY          ; 7 enable ADC-Y
        out       (piobd),a        ;11
        in        a,(pioad)        ;11 get data
        ld        (hl),a           ; 4 store data byte
        ld        a,DeSlct         ; 7 deselect devices
        out       (piobd),a        ;11
        inc       l                ; 4 next address and flag if 256
        jr        nz,SAHY1         ;1/7 if not yet 256, repeat
        jp        SwepY0           ;continue with sweep
;
;
; SAHX - Sample and Hold X-channel. After one max-speed scan, displays
;        memory until PEN. During Scan, LED lights half bright.
;
;  Syntax: aSaHX.
;---------------------------------------------------------------------------
;
SAHX:   dw        SCNCHP
        db        'SAHx'
        call      HPInit           ;initialize ADA-950225
        PAM3I
        ld        hl,ADABuX        ;X-buffer
SAHX1:  ld        a,StartX         ; 7 start X only, LED on
        out       (piobd),a        ;11
        ld        a,TrigOn         ; 7 deselect all
        out       (piobd),a        ;11
SAHX2:  in        a,(piobd)        ;11 get interrupts
        and       10000000b        ; 7 INT-X
        jr        nz,SAHX2         ;1/7
        ld        a,ReadX          ; 7 enable ADC-X
        out       (piobd),a        ;11
        in        a,(pioad)        ;11 get data
        ld        (hl),a           ; 4 store data byte
        ld        a,DeSlct         ; 7 deselect devices
        out       (piobd),a        ;11
        inc       l                ; 4 next address and flag if 256
        jr        nz,SAHX1         ;1/7 if not yet 256, repeat
        jp        SwepX0           ;continue with sweep
;
;
; SCANCHOP - Reads Y- and X-channel in chop mode. If input is not ready,
;            displays Y- and X-channel in chop mode
;
;  Syntax: aScanChop.
;---------------------------------------------------------------------------
;
ScnChp: dw        SCANY
        db        'SCANCHOp'
        call      HPInit           ;initialize ADA-950225
        ld        hl,ADABuX        ;start of buffer
        ld        d,h
        ld        e,l
ScnCh1: dec       h                ; 4 previous page ---- LOOP ----
        ld        a,StrtXY         ; 7 start X and Y, LED on
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7 deselect all
        out       (piobd),a        ;11
ScnCh2: in        a,(piobd)        ;11 get interrupts
        and       11000000b        ; 7 INT-X and INT-Y
        jr        nz,ScnCh3        ;1/7
        PAM3I                      ;54 PIO-A to Input
        ld        a,ReadY          ; 7 enable ADC-Y
        out       (piobd),a        ;11
        in        a,(pioad)        ;11 get data
        ld        (hl),a           ; 4 store data byte
        ld        a,DeSlct         ; 7 deselect devices
        out       (piobd),a        ;11
        inc       h                ; 4 next page
        ld        a,ReadX          ; 7 enable ADC-X
        out       (piobd),a        ;11
        in        a,(pioad)        ;11 get data
        ld        (hl),a           ; 4 store data byte
        ld        a,DeSlct         ; 7 deselect devices
        out       (piobd),a        ;11
        inc       l                ; 4 next address
        PAM3O                      ;54 PIO-A to output
        jr        ScnCh1           ;12 if read, restart ADCs
ScnCh3: dec       d                ; 4 previous page for Y-data ---- DISPLAY
        ld        a,(de)           ; 7 get Y-data from memory (DE)
        out       (pioad),a        ;11 put Y onto bus
        ld        a,EnablY         ; 7 enable DAC-Y
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7 deselect all devices
        out       (piobd),a        ;11
        inc       d                ; 4 next page for X-data
        ld        a,(de)           ; 7 get X-data from memory (DE)
        out       (pioad),a        ;11 put X onto bus
        ld        a,EnablX         ; 7 enable DAC-X
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7 deselect all devices
        out       (piobd),a        ;11
        inc       e                ; 4 next address
        in        a,(piobd)        ;11 now read PEN
        and       00100000b        ; 7  mask out others than PEN
        jr        z,ScnCh2         ;1/7 reloop if not +PEN
        call      HPInit           ;reset ADA-950225
        jp        Home
;
;
; SCANY - Scans Y-channel and displays it
;
;  Syntax: aScanY.
;---------------------------------------------------------------------------
;
ScanY:  dw        SCANX
        db        'SCANy'
        call      HPInit           ;initialize ADA-950225
        ld        hl,ADABuY        ;start of buffer
        ld        d,h
        ld        e,l              ;DE=ADABufY
ScanY1: ld        a,StartY         ; 7 start Y
        out       (piobd),a        ;11
        ld        a,TrigOn         ; 7  deselect all
        out       (piobd),a        ;11
ScanY2: in        a,(piobd)        ;11 get interrupt
        and       01000000b        ; 7 INT-Y
        jr        nz,ScanY3        ;1/7
        PAM3I                      ;54 PIO-A to input
        ld        a,ReadY          ; 7 enable ADC-Y
        out       (piobd),a        ;11
        in        a,(pioad)        ;11 get data
        ld        (hl),a           ; 4 store data
        ld        a,DeSlct         ; 7 deselect devices
        out       (piobd),a        ;11
        inc       l                ; 6 next address
        PAM3O                      ;54 PIO-A to output
        jr        ScanY1           ;12 restart ADC-Y
ScanY3: ld        a,(de)           ; 4 get data ---- DISPLAY ----
        out       (pioad),a        ;11 put X onto bus
        ld        a,EnablY         ; 7 enable DAC-Y
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7 deselect all devices
        out       (piobd),a        ;11
        inc       e                ; 4 next address
        in        a,(piobd)        ;11 now read PEN ---- PEN ABORT
        and       00100000b        ; 7  mask out others than PEN
        jr        z,ScanY2         ;1/7 reloop if not +PEN
        call      HPInit           ;reset ADA-950225
        jp        Home
;
;
; SCANX - Scans X-channel and displays it
;
;  Syntax: aScanX.
;---------------------------------------------------------------------------
;
ScanX:  dw        RECMON
        db        'SCANx'
        call      HPInit           ;initialize ADA-950225
        ld        hl,ADABuX        ;start of buffer
        ld        d,h
        ld        e,l              ;DE=ADABufX
ScanX1: ld        a,StartX         ; 7 start X
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7  deselect all
        out       (piobd),a        ;11
ScanX2: in        a,(piobd)        ;11 get interrupt
        and       10000000b        ; 7 INT-X
        jr        nz,ScanX3        ;1/7
        PAM3I                      ;54 PIO-A to input
        ld        a,ReadX          ; 7 enable ADC-X
        out       (piobd),a        ;11
        in        a,(pioad)        ;11 get data
        ld        (hl),a           ; 4 store data
        ld        a,DeSlct         ; 7 deselect devices
        out       (piobd),a        ;11
        inc       l                ; 6 next address
        PAM3O                      ;54 PIO-A to output
        jr        ScanX1           ;12 restart ADC-Y
ScanX3: ld        a,(de)           ; 4 get data ---- DISPLAY ----
        out       (pioad),a        ;11 put X onto bus
        ld        a,EnablX         ; 7 enable DAC-X
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7 deselect all devices
        out       (piobd),a        ;11
        inc       e                ; 4 next address
        in        a,(piobd)        ;11 now read PEN ---- PEN ABORT
        and       00100000b        ; 7  mask out others than PEN
        jr        z,ScanX2         ;1/7 reloop if not +PEN
        call      HPInit           ;reset ADA-950225
        jp        Home
;
;
;  Syntax: aRecordMono.
;---------------------------------------------------------------------------
;
RecMon: dw        RECORD
        db        'RECORDMONo'
        jr        Recor0
;
;
; RECORD - Records input of channel-Y for 31680 bytes from 31768 hence
;          This gives about 8 seconds worth of data
;
;  Syntax: aRecord.
;---------------------------------------------------------------------------
;
Record: dw        RECDST
        db        'RECORd'
Recor0: call      HPInit           ;initialize ADA-950225
        ld        hl,ADABuY        ;start of buffer
        ld        bc,ADAMo         ;length of buffer
        PAM3I                      ;54 PIO-A to input
Recor1: ld        a,StartY         ; 7 start Y
        out       (piobd),a        ;11
        ld        a,TrigOn         ; 7  deselect all
        out       (piobd),a        ;11
Recor2: in        a,(piobd)        ;11 get interrupt
        and        01000000b       ; 7 INT-Y
        jr        nz,Recor2        ;1/7
        ld        a,ReadY          ; 7 enable ADC-Y
        out       (piobd),a        ;11
        in        a,(pioad)        ;11 get data
        ld        (hl),a           ; 4 store data
        ld        a,DeSlct         ; 7 deselect devices
        out       (piobd),a        ;11
        inc       hl               ; 6 next address
        dec       bc               ; 6 counter-1
        ld        a,b              ; 4
        or        c                ; 4 Test end
        jr        nz,Recor1        ;1/7 not yet 31680, repeat
        call      HPInit           ;reset ADA-950225
        jp        Home
;
;
; RECORDSTEREO - Records input of channel-Y and channel-X in chop mode, each
;                for 15840 bytes from 31768/48608 hence
;                This gives about 4 seconds worth of data per channel
;
;  Syntax: aRecordStereo.
;---------------------------------------------------------------------------
;
RecdSt: dw        PLAYMO
        db        'RECORDSTEREo'
        call      HPInit           ;initialize ADA-950225
        ld        hl,ADABuY        ;start of buffer Y
        ld        de,ADARec        ;start of buffer X
        ld        bc,ADASt         ;length of buffer
        PAM3I                      ;54 PIO-A to input
RecSt1  ld        a,StrtXY         ; 7 start X and Y
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7 deselect all
        out       (piobd),a        ;11
RecSt2: in        a,(piobd)        ;11 get interrupts
        and       11000000b        ; 7 INT-X and INT-Y
        jr        nz,RecSt2        ;1/7
        ld        a,ReadY          ; 7 enable ADC-Y
        out       (piobd),a        ;11
        in        a,(pioad)        ;11 get data
        ld        (hl),a           ; 4 store data byte
        ld        a,DeSlct         ; 7 deselect devices
        out       (piobd),a        ;11
        inc       hl               ; 4 next address for Y
        ld        a,ReadX          ; 7 enable ADC-X
        out       (piobd),a        ;11
        in        a,(pioad)        ;11 get data
        ld        (de),a           ; 4 store data byte
        ld        a,DeSlct         ; 7 deselect devices
        out       (piobd),a        ;11
        inc       de               ; 6 next address for X
        dec       bc               ; 6 one scan done ---- CHECK END OF SCAN
        ld        a,b              ; 4
        or        c                ; 4 check end
        jr        nz,RecSt1        ;1/7 if not yet 15840, repeat
        call      HPInit           ;reset ADA-950225
        jp        Home
;
;
; PLAYMONO - Outputs 31680 bytes of data on Y- and X-channel parallel
;            until PEN. Alternate name for PLAYBACK.
;
;  Syntax: aPlayMono.
;---------------------------------------------------------------------------
;
PlayMo: dw        PLAYBK
        db        'PLAYMONo'
        jr        Playb0
;
;
; PLAYBACK - Outputs 31680 bytes of data on Y- and X-channel parallel
;            until PEN.
;
;  Syntax: aPlayBack.
;---------------------------------------------------------------------------
;
PlayBk: dw        PLAYST
        db        'PLAYBACk'
Playb0: call      HPInit           ;initialize ADA-950225
        ld        hl,ADABuY        ;start of buffer
        ld        bc,ADAMo         ;length of buffer
        ld        a,EnabXY         ; 7 enable DAC-Y and X, stay so
        out       (piobd),a        ;11
Playb1: ld        a,(hl)           ; 7 get X-data from memory (HL)
        out       (pioad),a        ;11 put X onto bus
        inc       hl               ; 6 next address
        dec       bc               ; 6 one byte done
        ld        a,b              ; 4  ---- END OF SWEEP
        or        c                ; 4 check end
        jr        nz,Playb1        ;1/7 continue if not completed
        ld        hl,ADABuY        ;reset buffer ---- ABORT REQUEST
        ld        bc,ADAMo         ;reset buffer size
        in        a,(piobd)        ;11 now read PEN
        and       00100000b        ; 7  mask out others than PEN
        jr        z,Playb1         ;1/7 reloop if not +PEN
        call      HPInit           ;reset ADA-950225
        jp        Home
;
;
; PLAYSTEREO - Plays back on channel -Y memory from 32768 to 48607 and
;              channel-Y from 48608 for 31680 bytes in chop mode until PEN
;
;  Syntax: aPlayStereo.
;---------------------------------------------------------------------------
;
PlaySt: dw        LOGMO
        db        'PLAYSTEREo'
        call      HPInit           ;initialize ADA-950225
        ld        hl,ADABuY        ;start of Y-buffer
        ld        de,ADARec        ;start of X-buffer
        ld        bc,ADASt         ;length of buffer
PlayS1: ld        a,(hl)           ; 7 get Y-data from memory (HL)
        out       (pioad),a        ;11 put Y onto bus
        ld        a,EnablY         ; 7 enable DAC-Y
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7 deselect all devices
        out       (piobd),a        ;11
        inc       hl               ; 6 next address for Y
        ld        a,(de)           ; 7 get X-data from memory (DE)
        out       (pioad),a        ;11 put X onto bus
        ld        a,EnablX         ; 7 enable DAC-X
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7 deselect all devices
        out       (piobd),a        ;11
        inc       de               ; 6 next address for X
        dec       bc               ; 6 one double byte output
        ld        a,b              ; 4  ---- CHECK END OF SWEEP
        or        c                ; 4 check end
        jr        nz,PlayS1        ;1/7 continue if not completed
        ld        hl,ADABuY        ;reset Y-buffer ---- CHECK ABORT REQUEST
        ld        de,ADARec        ;reset X-buffer
        ld        bc,ADAMo         ;reset buffer size
        in        a,(piobd)        ;11 now read PEN
        and       00100000b        ; 7  mask out others than PEN
        jr        z,PlayS1         ;1/7 reloop if not +PEN
        call      HPInit           ;reset ADA-950225
        jp        Home
;
;
; LOGSINGLE - Logs input of channel-Y for 31680 bytes from 31768 hence. The
;             delay between 2 samples can be set with either 6.5Ms or 426ms
;             resolution.
;       t=[0;65535]
;       If m=S: delay between logs = t x   6.5 Ms
;               Log time: 206 ms to 3h 44m 52s
;       If m=L: delay between logs = t x 425.9 ms
;               Log time: 3h 55m to 10d 5h 5m
;       (CAcntr) holds remaining loops if aborted prematurely using PEN
;
;  Syntax: aLogSingle,m,t.
;---------------------------------------------------------------------------
;
LogMo:  dw        LOGST
        db        'LOGSINGLe'
        call      DlyMod           ;get delay mode and number of loops
        call      HPInit           ;initialize ADA-950225
        ld        hl,ADABuY        ;start of buffer
        ld        bc,ADAMo         ;length of buffer
        PAM3I                      ;54 PIO-A to input
LogMo1: ld        a,StartY         ; 7 start Y
        out       (piobd),a        ;11
        ld        a,TrigOn         ; 7  deselect all
        out       (piobd),a        ;11
LogMo2: in        a,(piobd)        ;11 get interrupt
        and       01000000b        ; 7 INT-Y
        jr        nz,LogMo2        ;1/7
        ld        a,ReadY          ; 7 enable ADC-Y
        out       (piobd),a        ;11
        in        a,(pioad)        ;11 get data
        ld        (hl),a           ; 4 store data
        ld        a,DeSlct         ; 7 deselect devices
        out       (piobd),a        ;11
        inc       hl               ; 6 next address
        call      LogDly           ;produce delay
        in        a,(piobd)        ;11 now read PEN ---- CHECK ABORT
        and       00100000b        ; 7  mask out others than PEN
        jr        nz,LogMo3        ;1/7 exit if -PEN
        dec       bc               ; 6 counter-1
        ld        a,b              ; 4
        or        c                ; 4 Test end
        jr        nz,LogMo1        ;1/7 not yet 31680, repeat
LogMo3: ld        hl,Sysbuf + 62   ;point to delay time
        ld        (hl),c
        inc       hl
        ld        (hl),b           ;store remaining loops
        call      HPInit           ;reset ADA-950225
        jp        Home
;
;
;  Delay Mode SUBROUTINE gets delay mode (CApntr) and cycles in (CAcntr)
;    HL and AF are destroyed on exit.
;---------------------------------------------------------------------------
;
DlyMod: ld        hl,(SysWrd + 70) ;get pointer
        inc       hl
        ld        a,(hl)           ;get char m (S or L)
        res       5,a              ;convert to upper case
        ld        (SysWrd + 60),a  ;(CApntr)="S" or "L"
        inc       hl               ;point to delimiter
        ld        a,1              ;parameter 1
        call      FetPar           ;(param1)=t
        ld        hl,(SysWrd + 64) ;get (param1)
        ld        (SysWrd + 62),hl ;(CAcntr)=loop counter
        ret
;
;
; Log Delay SUBROUTINE finds selected delay and produces it by calling the
;    appropriate delay subroutine.
;    The AF register is destroyed.
;---------------------------------------------------------------------------
;
LogDly: push      hl               ;save HL
        ld        hl,(SysWrd + 62) ;get delay t
        ld        a,(SysWrd + 60)  ;get mode S(hort or L(ong
        cp        'S'
        call      z,SDelay         ;short delay
        cp        'L'
        call      z,LDelay         ;Long delay
        pop       hl               ;restore HL
        ret
;
;
; LOGDOUBLE - Records input of channel-Y and channel-X in chop mode, each
;             for 15840 bytes from 31768/48608 hence. The delay between
;             2 samples can be set with either 6.5Ms or 426ms resolution.
;       t=[0;65535]
;       If m=S: delay between logs = t x   6.5 Ms
;               Log time: 206 ms to 1h 52m
;       If m=L: delay between logs = t x 425.9 ms
;               Log time: 1h 52m to 5d 2h 32m
;       (CAcntr) holds remaining loops if aborted prematurely using PEN
;
;  Syntax: aLogDouble,m,t.
;---------------------------------------------------------------------------
;
LogSt:  dw        PENBIT
        db        'LOGDOUBLe'
        call      DlyMod           ;get delay mode and number of loops
        call      HPInit           ;initialize ADA-950225
        ld        hl,ADABuY        ;start of buffer Y
        ld        de,ADARec        ;start of buffer X
        ld        bc,ADASt         ;length of buffer
        PAM3I                      ;54 PIO-A to input
LogSt1  ld        a,StrtXY         ; 7 start X and Y
        out       (piobd),a        ;11
        ld        a,DeSlct         ; 7 deselect all
        out       (piobd),a        ;11
LogSt2: in        a,(piobd)        ;11 get interrupts
        and       11000000b        ; 7 INT-X and INT-Y
        jr        nz,LogSt2        ;1/7
        ld        a,ReadY          ; 7 enable ADC-Y
        out       (piobd),a        ;11
        in        a,(pioad)        ;11 get data
        ld        (hl),a           ; 4 store data byte
        ld        a,DeSlct         ; 7 deselect devices
        out       (piobd),a        ;11
        inc       hl               ; 4 next address for Y
        ld        a,ReadX          ; 7 enable ADC-X
        out       (piobd),a        ;11
        in        a,(pioad)        ;11 get data
        ld        (de),a           ; 4 store data byte
        ld        a,DeSlct         ; 7 deselect devices
        out       (piobd),a        ;11
        inc       de               ; 6 next address for X
        call      LogDly           ;produce delay
        in        a,(piobd)        ;11 now read PEN ---- CHECK ABORT
        and       00100000b        ; 7  mask out others than PEN
        jp        nz,LogSt3        ;1/7 exit if -PEN
        dec       bc               ; 6 one scan done ---- CHECK END OF SCAN
        ld        a,b              ; 4
        or        c                ; 4 check end
        jr        nz,LogSt1        ;1/7 if not yet 15840, repeat
LogSt3: ld        hl,Sysbuf + 62   ;point to delay time
        ld        (hl),c
        inc       hl
        ld        (hl),b           ;store remaining loops
        call      HPInit           ;reset ADA-950225
        jp        Home
;
;
; PENBIT reads PEN-bit and stores each 8 into a byte.
;   4096 bits can be read and stored in 33280 in 512 bytes
;
;  Syntax: aPenBit.
;---------------------------------------------------------------------------
;
PenBit: dw        TRGBIT
        db        'PENBIt'
        call      HPInit           ;initialize ADA-950225
        ld        hl,ADAPen        ;buffer start
        ld        e,2              ;512 byte counter
PenBi1: ld        b,8              ; 7 8 bits
PenBi2: in        a,(piobd)        ;11 read PEN
        rla                        ; 4 bit 5 to bit 6
        rla                        ; 4 bit 6 to bit 7
        rla                        ; 4 bit 7 into carry
        rl        c                ; 8 CY into bit 0 of C, all bits left
        djnz      PenBi2           ;13/8 get 8 bits
        ld        (hl),c           ; 7 store 8 bits
        inc       l                ; 4 next address
        jr        nz,PenBi1        ;1/7 repeat 256 times
        inc       h                ; 4 next page
        dec       e                ; 4 256 bytes done
        jr        nz,PenBi1        ;1/7 do another 2,048kbit
        call      HPInit           ;reset ADA-950225
        jp        Home
;
;
; TRGBIT outputs Y-channel memory on TRG output. 1 byte as 8 bits
;   After 4096 bits = 512 bytes eternal loop can be stopped with PEN.
;
;  Syntax: aTrgBit.
;---------------------------------------------------------------------------
;
TrgBit: dw        COPYXY
        db        'TRGBIt'
        call      HPInit           ;initialize ADA-950225
TrgBi0: ld        hl,ADAPen        ;buffer start
        ld        e,2              ;256 byte counter
TrgBi1: ld        b,8              ;8 bits
        ld        c,(hl)           ;get 8 bits
TrgBi2: rl        c                ;Bit 7 to CY, other bits left
        jr        nc,TrgBi3
        ld        a,TrigOn         ;bit is set
        jr        TrgBi4
TrgBi3: ld        a,DeSlct         ;bit is reset
TrgBi4: out       (piobd),a
        djnz      TrgBi2           ;do 8 bits
        inc       l                ;next address
        jr        nz,TrgBi1        ;repeat, next 8 bits
        inc       h                ;next page
        dec       e                ;2048 bits done
        jr        nz,TrgBi1        ;output another 2048 bits
        in        a,(piobd)        ;11 now read PEN
        and       00100000b        ; 7  mask out others than PEN
        jr        z,TrgBi0         ;1/7 reloop if not +PEN
        call      HPInit           ;reset ADA-950225
        jp        Home
;
;
; CopyXY - Copies ADABuY to ADABuX.
;
;  Syntax: aCopyXY.
;--------------------------------------------------------------------------
;
CopyXY: dw        COPYYX
        db        'COPYXy'
        ld        hl,ADABuY        ;source
        ld        de,ADABuX        ;destination
        ld        bc,256           ;bytes
        ldir                       ;copy
        jp        Home
;
;
; CopyYX - Copies ADABuX to ADABuY.
;
;  Syntax: aCopyYX.
;--------------------------------------------------------------------------
;
CopyYX: dw        SWAPXY
        db        'COPYYx'
        ld        hl,ADABuX        ;source
        ld        de,ADABuY        ;destination
        ld        bc,256           ;bytes
        ldir                       ;copy
        jp        Home
;
;
; SwapXY - Swaps ADABuY with ADABuX.
;
;  Syntax aSwapXY.
;---------------------------------------------------------------------------
;
SwapXY: dw        SINE
        db        'SWAPXy'
        ld        hl,ADABuX        ;X-buffer
        ld        de,ADABuX + 256  ;auxilliary buffer
        ld        bc,256           ;bytes
        ldir                       ;copy X-data to auxilliary buffer
        ld        hl,ADABuY        ;source
        ld        de,ADABuX        ;dest
        inc       b                ;BC=256
        ldir                       ;Y data to X
        ld        hl,ADABuX + 256  ;source=aux-buffer
        ld        de,ADABuY        ;dest
        inc       b                ;BC=256
        ldir                       ;X-data to Y
        jp        Home
;
;
; SINE - Copies sinewave data of 1 Hz full swing to Y-channel memory
;
;  Syntax: aSine.
;---------------------------------------------------------------------------
;
Sine:   dw        RAMP
        db        'SINe'
        ld        hl,SinDat        ;sine wave data
        ld        de,ADABuY        ;Y-buffer
        ld        bc,256           ;bytes
        ldir                       ;copy
        jp        Home
;
;
; SINEWAVE Data. f=1Hz
;---------------------------------------------------------------------------
;
SINDAT: db       127,123,120,117,114,111,108,105,101, 98, 95, 92, 89, 86, 83
        db        80, 77, 74, 72, 69, 66, 63, 61, 58, 55, 53, 50, 48, 45, 43
        db        40, 38, 36, 34, 31, 29, 27, 25, 24, 22, 20, 18, 17, 15, 13
        db        12, 11,  9,  8,  7,  6,  5,  4,  3,  2,  2,  1,  0,  0,  0
        db         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  2,  2
        db         3,  4,  5,  6,  7,  9, 10, 11, 12, 14, 15, 17, 19, 20, 22
        db        24, 26, 28, 30, 32, 34, 37, 39, 41, 44, 46, 48, 51, 54, 56
        db        59, 61, 64, 67, 70, 73, 75, 78, 81, 84, 87, 90, 93, 96, 99
        db       103,106,109,112,115,118,121,124,128,131,134,137,140,143,146
        db       149,153,156,159,162,165,168,171,174,177,179,182,185,188,191
        db       193,196,199,201,204,206,209,211,213,216,218,220,222,224,226
        db       228,230,232,234,235,237,239,240,241,243,244,245,246,248,249
        db       249,250,251,252,252,253,253,254,254,254,254,254,254,254,254
        db       254,254,253,253,252,252,251,250,249,248,247,246,245,244,243
        db       241,240,239,237,235,234,232,230,228,226,224,222,220,218,216
        db       213,211,209,206,204,201,199,196,193,191,188,185,182,179,177
        db       174,171,168,165,162,159,156,153,149,146,143,140,137,134,131
        db       128
;
;
; RAMP - Copies ramp data of 1 Hz full swing to Y-channel memory
;
;  Syntax: aRamp.
;---------------------------------------------------------------------------
;
Ramp:   dw        TRIANG
        db        'RAMp'
        ld        hl,ADABuY        ;Y-buffer
        xor       a                ;A=data
Ramp1:  ld        (hl),a           ;insert byte
        inc       hl               ;next address
        inc       a                ;next data
        jr        nz,Ramp1         ;until A=256=0
        jp        Home
;
;
; TRIANGLE - Copies triangle data of 1 Hz full swing to Y-channel memory
;
;  Syntax: aTriangle.
;---------------------------------------------------------------------------
;
Triang: dw        SQUARE
        db        'TRIANGLe'
        ld        hl,ADABuY        ;Y-buffer
        xor       a                ;A=data
Trian1: ld        (hl),a           ;insert byte
        inc       hl               ;next address
        inc       a
        inc       a                ;next data
        jr        nz,Trian1        ;do up leg
        dec       a
        dec       a
Trian2: ld        (hl),a
        inc       hl
        dec       a
        dec       a
        jr        nz,Trian2        ;do downleg
        jp        Home
;
;
; SQUARE - Copies square data of 1 Hz full swing to Y-channel memory
;
;  Syntax: aSquare.
;---------------------------------------------------------------------------
;
Square: dw        PULSE
        db        'SQUARe'
        ld        b,128            ;high leg counter
        ld        c,128            ;low leg counter
        jr        Pulse0           ;same procedure
;
;
; PULSE - Copies pulse data of 1 Hz full swing to Y-channel memory
;         Duty cycle is 10%.
;
;  Syntax: aPulse.
;---------------------------------------------------------------------------
;
Pulse:  dw        INVDAY
        db        'PULSe'
        ld        b,26             ;high leg counter
        ld        c,230            ;low leg counter
Pulse0: ld        hl,ADABuY        ;Y-buffer
        ld        a,255            ;A=data
Pulse1: ld        (hl),a           ;insert byte
        inc       hl               ;next address
        djnz      Pulse1           ;do high leg
        ld        b,c              ;get low leg counter
        inc       a                ;A=0
Pulse2: ld        (hl),a
        inc       hl
        djnz      Pulse2           ;do high leg
        jp        Home
;
;
; INVERTY - Inverts data in Y-buffer
;
;  Syntax: aInvertY.
;---------------------------------------------------------------------------
;
InvDaY: dw        INVDAX
        db        'INVERTy'
        ld        hl,ADABuY        ;Y-buffer
        jr        InvDa0           ;continue at InvertY
;
;
; INVERTX - Inverts data in X-buffer
;
;  Syntax: aInvertX.
;---------------------------------------------------------------------------
;
InvDaX: dw        DUMMY
        db        'INVERTx'
        ld        hl,ADABuX        ;X-buffer
InvDa0: ld        b,0              ;256 bytes
InvDa1: ld        a,(hl)           ;get current data
        xor       255              ;invert
        ld        (hl),a           ;store inverted data
        inc       hl               ;next address
        djnz      InvDa1           ;repeat
        jp        Home
;
;
; DUMMY - 1st undefined word in list.
;---------------------------------------------------------------------------
;
Dummy:  dw        65535            ;First undefined
        db        255              ;name=255
;
;
;========================== 951030 --- HoroSoft ============================
;
end

Notes on the above Listing

The assemblable source code, the hex-intel files and the rom-code can be found under Projects > Resources.

This is the originally typed Z80 assembler listing, not the output of the Cromemco Macro Assembler v.03.04 which was used to create the ROMable code.

The numbers in the remarks column right of the semicolon (;) are the number of t-cycles the processor needs to execute the instruction. If there are 2 numbers, e.g. 1/7, the first are the needed t-cycles when looping back to the label, the second to continue when the loop is done. A Z80 t-cycle for a 4 MHz clock is 250 ns. The execution speed of a command can be calculatd. There are no interrupts if no new commands are downloaded to UZE computer.

The commands are named and connected by a linked list. The 'DW' (define word) at the beginning of a named command points to the start of the next command. The 'DW' is followed by a 'DB' (define byte) sequence that contains the name of the command in upper case. To be able to omit the length of the command name or to circumvent the necessity for fixed-length command names, the last character of the name is in lower case to signal the end of the command name.

If you study the code and think you are missing something, you are perfectly right. The macros referenced and some subroutines called belong to the UZE operating system, so do the command parsing routines. Look at the UZE Source for all that is missing here.

Z80 mnemonics are different but (in my opinion) more obvious than the iAPX 80x86 Intel ones, there are some similarities, however. After much of assembler programming — the only programming that really is fun and challenging — I came to prefer the Zilog mnemonics and appreciate the powerful instruction set not found on Intel processors.

 
  © 2004 - 2018 by Horo Wernli.