Autor
| New program: Analyze Z80 databus safely!
| NYYRIKKI msx master Mensajes: 1533 | Publicado: Septiembre 28 2004, 01:52   |
Ok, here is once again something that you really don't need!
This program will read value from Z80 databus during one SINGLE interrupt. This means, that you can now safely monitor databus with any hardware without worry of your computer hanging.
This program might not be size optimized too well, but I'm pretty proud of the result anyway. Feel free to use it how ever you like, but what ever you do, do not ask how it works. :9
Good thing is, that this needs only about 5KB of memory because of very tight fitted self generating code.
; DATABUS.GEN Ver 2.0 for MSX homecomputers (Made By: NYYRIKKI)
;
; This program reads a value from databus when Z80 leaves databus control to peripherals.
;
; Usage from MSX-BASIC:
;
; BLOAD "DATABUS.BIN",R:PRINT USR(0)
;
;
; Ps. Unmodifyed MSX should give value #FF allways. (according to my knowledge)
;
; Changes:
;
; This new version will need only one interrupt.
; You can not hang your computer anymore by changeing databus value between interrupts.
;-----------------------------------------------------------------------------------------
USR: EQU #F7F8
USR0: EQU #F39A
DEFB #FE
DEFW BEGIN
DEFW END
DEFW START
ORG #B000
BEGIN:
START:
LD HL,CODE
LD (USR0),HL
RET
CODE:
DI
LD HL,#BF00
LD BC,0
NEXT:
LD A,C
ADD A,B
CP #10
JP NC,NOMORE
LD (HL),A
INC HL
CP #F
JP Z,SKIP
LD (HL),B
INC HL
SKIP:
INC C
LD A,C
CP #10
JP NZ,NEXT
NOMORE:
LD C,0
INC B
LD A,B
CP #10
JP NZ,NEXT
LD (HL),#C0
LD HL,#BF00
LD DE,#BE00
LD BC,0
FIXL:
LD A,(HL)
LD C,A
OR #C0
LD (HL),A
INC HL
LD A,(HL)
RLCA
RLCA
RLCA
RLCA
OR C
LD E,A
EX DE,HL
LD A,E
DEC A
LD (HL),A
EX DE,HL
DJNZ FIXL
LD HL,#C0C0
LD DE,#C0C1
LD B,#F
MAKEPROG:
PUSH BC
LD BC,#F
PUSH HL
PUSH DE
LD (HL),4 ;INC B
LDIR
LD (HL),#CD ;CALL
INC HL
LD DE,CALCUT
LD (HL),E
INC HL
LD (HL),D
POP DE
POP HL
POP BC
INC H
INC D
DJNZ MAKEPROG
LD A,#BF
LD I,A
IM 2
EI
NOP
HALT ; Any interrupt will be accepted.
IM 1
LD L,A
LD H,#BE
LD A,(HL)
LD (USR),A
XOR A
LD (USR+1),A
RET
CALCUT:
POP AF
AND #F
RLCA
RLCA
RLCA
RLCA
OR B
XOR #F
RETI
END:
| | ricbit msx lover Mensajes: 116 | Publicado: Septiembre 28 2004, 01:58   | Nice program!
Quote:
|
; Ps. Unmodifyed MSX should give value #FF allways. (according to my knowledge)
|
Some models don't give #FF always. This is only true for machines with pull-up resistores in their data bus. The Expert 1.0, for instance, doesn't have, so values as random. I have seen some programs using IM 2 lock due to this bug/feature of Expert. | | NYYRIKKI msx master Mensajes: 1533 | Publicado: Septiembre 28 2004, 20:28   |
Oh, I didn't know that, but cool, then there is at least one usage for this program. You can record noice from Expert databus :-9
I think, that there should be competition, who makes most advanced software, that is totally useless and has practically no entertaining or educational value. I think, that I would have plenty of good candidates. :-)
| | GuyveR800 msx guru Mensajes: 3048 | Publicado: Septiembre 29 2004, 00:36   | Quote:
| Oh, I didn't know that, but cool, then there is at least one usage for this program. You can record noice from Expert databus :-9
|
Sounds like a great source for random numbers  | | ricbit msx lover Mensajes: 116 | Publicado: Septiembre 29 2004, 06:33   | Quote:
| Sounds like a great source for random numbers 
|
Or, at least, a way to detect if a machine is an Expert 1.0 or not. | | ro msx guru Mensajes: 2353 | Publicado: Julio 15 2006, 15:28   | not really sure if I understand this... hmmmz
| | NYYRIKKI msx master Mensajes: 1533 | Publicado: Julio 16 2006, 13:24   | ro: I know that this program is small but quite a complicated to understand. I don't think that you can "solve" this by looking at the code. I think it is better to take some memory monitor (like Super-x) and check out the tables that this code generates. This is more like solution to a big Sudoku puzzle.
The idea is that the code generates a set of bytes where low nibbles in bytes following each other make a pointer to 16*16 table so that each 0-255 value made by combining these low nibbles appear only once. In other words there is only one pointer to each shell in the 16*16 table no matter was the nibble hi or low. There exists no many possibilitys to order bytes like this.
The result is, that when this pointer table is used in IM2 mode the Z80 will jump somewhere in to the 16*16 table. This table is full of INC B operations and end of each table row there is CALL to CALCUT routine that uses the address where the routine was called from and the register B to get X and Y coordinates. After this these coordinates are converted to databus value by using another generated table.
~NYYRIKKI
| | AuroraMSX
 msx master Mensajes: 1277 | Publicado: Julio 17 2006, 13:40   | Quote:
| I think, that there should be competition, who makes most advanced software, that is totally useless and has practically no entertaining or educational value.
|
That's already out there. It's called Windows XP  | |
| |
| |