More help please gentlemen.
More help please gentlemen.
I recently asked for some help with a problem in M/C and you guys responded superbly so I wonder if you could help me once more with another problem?
The problem.
Imagine a REM containing exactly 100 random BYTES.
1 REMxxxxxxx....(100)
Now a second REM with 800 BYTES.
2 REMxxxxxxx....(800)
What I need to do is to take a BYTE one at a time from the first REM, convert it into binary then poke the 8 successive binary digits into the second REM then move onto the next until all 100 BYTES of the first REM are converted then poked into the 800 BYTES of the second REM.
For example if the first BYTE of REM 1 is 255...
1 REM COPY....
then the first 8 positions of REM 2 should look like..
2 REM 11111111....
A third REM should hold the code to achieve this.
3 REM (code for the routine)
I can do this in BASIC but it is taking far too long.
Any help or pointers in the right direction would be much appreciated but it has to be kept simple as I’m not the brightest when it comes to programming.
Many thanks in advance.
The problem.
Imagine a REM containing exactly 100 random BYTES.
1 REMxxxxxxx....(100)
Now a second REM with 800 BYTES.
2 REMxxxxxxx....(800)
What I need to do is to take a BYTE one at a time from the first REM, convert it into binary then poke the 8 successive binary digits into the second REM then move onto the next until all 100 BYTES of the first REM are converted then poked into the 800 BYTES of the second REM.
For example if the first BYTE of REM 1 is 255...
1 REM COPY....
then the first 8 positions of REM 2 should look like..
2 REM 11111111....
A third REM should hold the code to achieve this.
3 REM (code for the routine)
I can do this in BASIC but it is taking far too long.
Any help or pointers in the right direction would be much appreciated but it has to be kept simple as I’m not the brightest when it comes to programming.
Many thanks in advance.
Re: More help please gentlemen.
Hi i had to retrieve my ASM code to convert a byte to a 8 binary value… somewhere on this forum…
But, to diet your code, delete the first REM line… the random table array…
Just get a random ROM offset, and get the byte from this offset.
You will keep 105 bytes !
But, to diet your code, delete the first REM line… the random table array…
Just get a random ROM offset, and get the byte from this offset.
You will keep 105 bytes !
Last edited by XavSnap on Mon Nov 09, 2020 11:01 pm, edited 1 time in total.
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: More help please gentlemen.
Hi Xav.
I'm not trying to create any RND numbers. The RND numbers in the first REM are very important and it is those specific numbers I need to convert to binary and then using the other routines you and the guys supplied I can check the frequency of zeros and ones.
I'm not trying to create any RND numbers. The RND numbers in the first REM are very important and it is those specific numbers I need to convert to binary and then using the other routines you and the guys supplied I can check the frequency of zeros and ones.
Re: More help please gentlemen.
Code: Select all
FOR A=16514 TO 16514+100
POKE A,256*RND
NEXT A
Code: Select all
LET D=16514
FOR A=50+RND*1000 TO 4E4 STEP RND*4
POKE D,PEEK A
LET D=D+1
IF D<16615 THEN NEXT A
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: More help please gentlemen.
Again I don't need to create any RND numbers they are already done in another program and are important.
I just need something that will turn these 100 RND numbers into 800 bits of binary then poke it to the second REM.
I just need something that will turn these 100 RND numbers into 800 bits of binary then poke it to the second REM.
Re: More help please gentlemen.
this is the lottery number ?another program and are important
Cool…
I had to retrieve my working Byte>Binary routine…
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: More help please gentlemen.
Not lottery but RND numbers created by outside sources then manually entered into the ZX81 for use in encryption.
The frequency of ones and zeros is checked to see the quality/weight of the RND number generator used and so far the 81's own RND generator is performing better that a Mersenne twister!
The frequency of ones and zeros is checked to see the quality/weight of the RND number generator used and so far the 81's own RND generator is performing better that a Mersenne twister!
Re: More help please gentlemen.
Code: Select all
#RANDOM VALUES.
0 REM [HEX:\
00,FF,00,FF,00,FF,00,FF,\
00,FF,00,FF,00,FF,00,FF,\
00,FF,00,FF,00,FF,00,FF,\
00,FF,00,FF,00,FF,00,FF,\
00,FF,00,FF,00,FF,00,FF,\
00,FF,00,FF,00,FF,00,FF,\
00,FF,00,FF,00,FF,00,FF,\
00,FF,00,FF,00,FF,00,FF,\
00,FF,00,FF,00,FF,00,FF,\
00,FF,00,FF,00,FF,00,FF,\
00,FF,00,FF,00,FF,00,FF,\
00,FF,00,FF,00,FF,00,FF,\
00,FF,00,FF ]
#BINARY BUFFER
1 REM [HEX:\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00 ]
#COUNTER ROUTINE
2 REM [HEX:\
21,EC,40,01,00,00,3E,1D,\
BE,20,01,03,23,3E,76,BE,\
20,F4,C9 ]
#GET LINE 0 VALUES AND STORE BINARY VALUES IN LINE 1.
3 REM [HEX:\
21,82,40,11,EC,40,01,64,\
08,06,08,79,FE,00,C8,7E,\
CB,7F,EB,28,04,36,1D,18,\
02,36,1C,EB,13,CB,07,10,\
EF,23,0D,18,E4 ]
#FILL THE LINE 1.
5 FOR A=16514 TO 16514+99
6 POKE A,255*RND
7 NEXT A
#CONVERT
10 LET N=USR 17451
#COUNT
20 LET N=USR 17426
30 PRINT "1=";N,"0=";800-N
Code: Select all
.ORG 16514
LD HL,16514
LD DE,16514+106 ;Target
LD BC,$0864
NEXTBYTE:
LD B,8
LD A,C
CP 0
RET Z
LD A,(HL)
NXTBIT:
BIT 7,A
EX DE,HL
JR Z,GET0
LD (HL),$1D
JR NEXT
GET0:
LD (HL),$1C
NEXT:
EX DE,HL
INC DE
RLC A
DJNZ NXTBIT
INC HL
DEC C
JR NEXTBYTE
.end
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: More help please gentlemen.
Hi,
25 bytes for the 3rd REM.
Zsolt
Code: Select all
; 3 REM
.org 17426 ; 16514+106+806
ld de,16514 ; 1 REM (100 bytes)
ld hl,16620 ; 2 REM (800 bytes)
ld c,100 ; 100 bytes to convert
nxt_byte
ld a,(de) ; a byte to convert
ld b,8 ; 8 bits in a byte
next_bit
ld (hl),$1C ; code "0"
rla ; test bit 7
jr nc,equ_zero ; skip if zero
inc (hl) ; else set "1"
equ_zero
inc hl ; set bit pointer
djnz next_bit ; last bit in byte?
inc de ; set byte pointer
dec c ; set byte counter
jr nz,nxt_byte ; back until done
ret ;
.end
Zsolt
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]
Re: More help please gentlemen.
Thank you Gentlemen you have helped me once again , how I wish I had your skills.
The people on this forum never cease to amaze me especially with their helpfulness.
The people on this forum never cease to amaze me especially with their helpfulness.