┌---------------------------------------┐
│░░░░░░░░░░░░ Programming ░░░░░░░░░░│
└---------------------------------------┘
(C) SpaceS
Hi, world! I'm back in Lprint'e! (and where is the
loud applause?)
Well, it’s okay, and without them I can write something...
something. So now I will share with you
the fruits of his perversions over the demo...
But I won’t say its name, otherwise I’ll swear
you will. In general, we ourselves are in the process of reading
you will understand.
1) How to determine how many kilobytes you have
neck cars:
MEMORY ld bc,32765
ld hl,49152
ld de,4113 ;#1011
out (c),d
ld(hl),l
out(c),e
ld(hl),c
out (c),dld a,(hl)
or a
jr z,128kb
This is easy to figure out, so let's go yes-
more:
2) Determination of whether the computer has music. fees:
Muzak ld bc,65533
ld a,0
out(c),a
ld b,191
ld a,64
out(c),a
ld b,255
in a,(c)
cp 64
jr z, yes
Everything is simple here too.
3) If music. the board was still found
following procedure, it is now possible to determine
pour her type:
Tip ld bc,65533
ld a,16
out (c),a
in a,(c)
cp 255
jr nz,AY-8910/12
JR YAMAHA 2149F
4) And now the most interesting thing:
Determines the number of clock cycles of a computer
tera for 1 interruption.
TAKTS org #8055
di
ld hl,30720;creation of pro-
ld a,121 ;treatment procedures
LABAO5 ld (hl),a ;boots
inc l ;interrupts
jr nz, LABAO5 ;
inc h ;Address of the
ld (hl),a ;procedures:
dec a ;31097
ld i,a ;
im 2
ld a,201 ;201=ret
ld(31097),a
ld hl,LABAO7ld (31098),hl
ld de,0 ;counter=0
ld hl,LABAOb
ld a,195 ;195=jp
ei;
halt ;2 times empty-
ei; thuyu
halt;
ei;
ld(31097),a ; let's go!
LABAOb inc de ;de=de+1
jp (hl) ;jp LABAOb
;inc de=btacts
;jp (hl)=Tak.
LABAO7 di ;will go here
;execution
;after counting
;beats
;(from 2nd prev.)
pop af ;remove from
;stack address in-
;return
inc de
inc de ;in de-quantity
;cycles, divided-
;noe by 10
Well, then it’s a matter of technology. To withdraw co-
number of clock cycles you can use al-
the same demo (meaning
output in 1Otical system)
1) Immediately print zero in the last digit
de.
2) divide de by 10 4 times (the remainder is
there will be a next level)
3) All
But the question is: how to divide?
Here's how:
Input: de-number1 (2 bytes)
:bc-65536-number2 (2 bytes)
Output: a-remainder of division
:de=number1/number2
DELENIE ld hl,0
ld a,e
add a,a
rl d
adc hl,hl
add hl,bc
jr c,NABAS7sbc hl,bc
NABAS7 rla
rl d
NABAS8 adc hl, hl
add hl,bc
jr c,NABAбO
NABAS9 sbc hl,bc
NABAбO rla
rl d
NABA1 adc hl,hl
add hl,bc
jr c,NABAб2
sbc hl,bc
NABA2 rla
rl d
adc hl,hl
add hl,bc
jr c,NABAбЗ
sbc hl,bc
NABAбЗ rla
rl d
adc hl,hl
add hl,bc
jr c,NABAбЧ
sbc hl,bc
NABAбЧ rla
rl d
adc hl,hl
add hl,bc
jr c,NABAб5
sbc hl,bc
NABA 5 rlarl d
adc hl,hl
add hl,bc
jr c,NABAбб
sbc hl,bc
NABAбб rla
rl d
adc hl,hl
add hl,bc
jr c,NABAб7
sbc hl,bc
NABAб7 rla
rl d
adc hl,hl
add hl,bc
jr c,NABAб8
sbc hl,bc
NABAб8 rla
rl d
adc hl,hl
add hl,bc
jr c,NABAб9
sbc hl,bc
NABAб9 rla
rl d
adc hl,hl
add hl,bc
jr c,NABA70
sbc hl,bc
NABA70 rla
rl d
adchl,hl
add hl,bc
jr c,NABA71
sbc hl,bc
NABA71 rla
rl d
adc hl,hl
add hl,bc
jr c,NABA72
sbc hl,bc
NABA72 rla
rl d
adc hl,hl
add hl,bc
jr c,NABA73
sbc hl,bc
NABA73 rla
rl d
adc hl,hl
add hl,bc
jr c,NABA74
sbc hl,bc
NABA74 rla
rl d
adc hl,hl
add hl,bc
jr c,NABA75
sbc hl,bc
NABA75 rla
rl d
ld e,a
ret Did you figure it out? If not, then think about it. If
I don’t think so, then sort out the pro-
multiplication procedure from MOVE#10, and then
with this everything will become clear.
And finally, I’ll say that all this is an impudent
at once (or rather, by STS) torn from ACTION
MEGADEMO, I hope that VAV will forgive me, because.
K. without his demo I’m up to all of the above
I wouldn't have thought of it.
Alex> I read everything written above and re-
I thought I'd add something of my own.
First I want to give a little advice SPA-
CES - switch to the HEX system. I used to
wrote to DEC, but then, realizing the advantages
HEX, gradually moved into it (between 32765
and #7FFD there may be no difference, but between
4113 and #1011 are available. Or compare 16384.16640,
16896, 17152, 17408, 17664, 17290, 18176 and
#4000, #4100, #4200, #4300, #4400, #4500,
#4600, #4700 - which is easier to remember?).
Well, a few more words aboutabout it now
my programs. They don't all belong
me, I also “pulled” some from de-
mock (for example ECSTASY). Also in my pro-
In grammar you can see commands like
LD HL,KB_128 and CALL PRINT are just about
turning to the text printing subroutine, but
this subroutine itself, as well as the texts,
will not be given here (write it yourself -
not small :). And one last thing. In my pro-
gah You will find almost no comments -
They are not that complicated.
5,4,3,2,1,0,-1,-2,-3 Start...
First, another program to check for
availability of 128Kb (if you want to check
having more memory and using it
in your program, then it’s better to use
procedure from the appendix to ZX-FORMAT #05
/aka in SPECTROFON #22/).
LD HL,#C000
LD BC,#7FFD
LD A,#10
OUT(C),A
LD(HL),A
INC A
OUT(C),A
LD(HL),A
DEC A
OUT(C),ACP(HL)
LD HL,KB_128
JR Z,$+4
LD HL,KB_48
CALL PRINT
And here is another original test of mine -
ka:
ORG <#8000 ; the address must be
LD BC,#7FFD ; less than #8000
LD A,#15
OUT(C),A
LD (LABEL+#8000),A
LABEL RST 0 ; at 48Kb - reset
LD A,#10 ; at 128Kb continued
OUT (C),A ; we are pressing for work
Can you guess how it works?
Since SPACES has resulted in a verification procedure
If AY is available in DEC form, then I decided to
enter it again, but in HEX form (it
a little different from the above, but
not significant, since I looked at it myself
rel in ACTION /At first I had a music
cal coprocessor AY-3-8910 and I somehow
didn't pay attention to the fact that ACTION
informed me that I have the 10th so-processor. But one day I replaced it with
YM2148F and running ACTION I was surprised
I saw messages that I now have
YMAHA. Until this moment I had no idea
that it is possible to programmatically determine the type of station
music coprocessor running on your computer.
Then I also got into ACTION and looked
how is it determined/.
LD BC,#FFFD
XOR A
OUT(C),A
LD B,#BF
LD A,#40
OUT(C),A
LD B,#FF
IN A,(C)
CP #40
LD HL,ABSENT
JR NZ,CONT
LD A,#10
OUT(C),A
IN A,(C)
CP#FF
LD HL,AY_3
JR NZ,CONT
LD HL,YM2149F
CONT CALL PRINT Program for determining the presence of shadow
RAM (SHADOW RAM). Defines two types of sub-
inclusions.
D.I.
IN A,(#FB) ; enable shadow RAM
CALL CHECK
IN A,(#7B) ; turn off RAM
JR NC,CNT ; if there is, then there is a way out
LD BC,#FFЗE
LD A,#C7
OUT (C),A ; enable shadow RAM
PUSH BC
CALL CHECK
POP B.C.
LD A,#C0
OUT (C),A ; turn off RAM
LD HL,ABSENT
JR C,EXT
CNT CALL CONV ; converting a number from A to
; symbolic view in HL
EXT CALL PRINT
...
CHECK LD BC,#7FFD
LD DE,#1000
LD HL,0
LD A,(HL)
DEC (HL)
CP(HL)SCF
RET Z ; Refund if no RAM
OUT(C),E
LD A,32; 32Kb
LD (#ЗFFF),A
OUT(C),D
LD A,16; 1bKb
LD (#ЗFFF),A
RRCA; 8Kb
LD(#1FFF),A
RRCA ; CHKb
LD (#OFFF),A
RRCA ; 2Kb
LD (#07FF),A
OUT(C),E
LD A,(#ЗFFF) ; In reg A result
OUT(C),D
AND A ; reset CARRY
RET
Checking the presence of port #FF
LD HL,#5800 ; put in attributes
LD DE,#5801 ; number #FF
LD BC,#02FF
LD (HL),#40
LDIR
EI
LD BC,#0800 ; In BC counter
HALT
LD HL,FF_YES
LOOP_0 IN A,(#FF)
CP #40
JRZ,LAB_X
DEC B.C.
LD A,B
OR C
JR NZ,LOOP_0
LD HL,ABSENT
LAB_X CALL PRINT
This program WILL NOT DETERMINE incorrectly
made #FF port!
I’ll also revise the program to determine
reducing the number of clock cycles between interrupts
computer.
ORG >#7FFF
D.I.
LD HL,#FEOO ; Regime organization
LD A,H ; IM 2
LD I,A
DEC A
LD(HL),A
INC L
JR NZ,$-2
INC H
LD(HL),A
LD A,#C9 ; Temporarily blocked
LD (#FDFD),A ; return program
LD HL,RETURN ; Enter the return address
LD(#FDFE),HL; rata from counting
IM 2
LD DE,0 ; Resetting the counter to zeroLD HL,CYC
LD A,#C3
EI
HALT ; idle run
EI
HALT ; idle run
EI
LD (#FDFD),A ; Unlock refund
CYC INC DE ; counting bars
JP(HL)
RETURN DI
POP AF ; reset the stack to the original
INC DE ; condition
INC DE
In the DE register, the number of clock cycles divided
by ten (for example 7166 is 71660
beats).
Determining the presence of slow memory
(SLOW RAM) i.e. machine type - single-field
or two-field.
LD A,3 ; idle counter interrupt.
LD HL,INT_1 ; return address
LD (#FDFE),HL
LD BC,0 ; reset the counter
EI
HALT
HALT
LOOP_1 LD HL,(#4000) ; working with SLOW RAM
LD (#4000),HLINC B.C.
JR LOOP
INT_1 DEC A
EI
RET NZ; return from idle INT
D.I.
POP HL; restoring the stack
PUSH BC; save the result
LD HL,INT_2 ; return address
LD (#FDFE),HL
LD A,3 ; idle counter interrupt.
LD BC,0 ; reset the counter
EI
HALT
HALT
LOOP_2 LD HL,(#FEOO) ; working with FAST RAM
LD (#FEOO),HL
INC B.C.
JR LOOP_2
INT_2 DEC A
EI
RET NZ ; return from idle INT
D.I.
POP HL ; restoring the stack
POP HL; having recovered old result
XOR A
SBC HL,BC ; check both results
LD HL,ABSENT ; SLOW RAM ABSENT
JR Z,$+5
LD HL,PRESENT ; SLOW RAM PRESENT
CALL PRINT Well, the last program. Definition of CDOS-
modem and the port to which it is connected.
I want to warn you right away that I am this program
wrote for the ARS modem and will it be
I don’t know how to identify Moscow modems
The fact is that Minsk modems connect -
with incomplete addressing, to port number
which contains one or two reset bits
changed to zero, and the remaining bits are equal to
face. The search starts from port #FC and further
down. The handset on the modem must be in
on.
LD B,#FC
LL_1 LD C,B ;Enter the port address in C
IN A,(C) ;read the port value and
CP #DF ;check it with #DF
JR Z,CL_1 ;if equal, then additional prv.
RL DJNZ LL_1 ;otherwise continue searching
LD HL,ABSENT ; modem not found!
J.R.E.L.
CL_1 LD E,0 ;reset the counter
LD B,8 ;number of bits to be checked
LD A,C ;in reg. A - port address
LL_3 RRA ;check bit to zero
JR C,LL_2
INC E ; if the bit is 0, then E=E+1
LL_2 DJNZ LL_3 ; Are all bits checked?
LD B,C ; restore register B
DEC E ; there is one bit in the port number
; equal to zero?
JR Z,$+5 ; if yes, then there is a modem
DEC E; the port number has two bits
; equal to zero?
JR NZ,RL ; if not, then continue
; search
LD A,#10 ; standard procedure
OUT (C),A ; availability checks
IN A,(C) ; modem from CDOS
AND #20
JR Z,EL
XOR A
OUT(C),A
IN A,(C)
AND #20
JR NZ,EL
LD HL,PRESENT
EL CALL PRINT; There is a modem. in reg. C
; port number.
That's all for today.
P.S. If in the above program
there were some shortcomings or
errors, then excuse me - this text is being typed -
was from memory.
Share your thoughts about the article