ZXpand-AY Sound Module (Two 8 bit I/O ports control)
- 1024MAK
- Posts: 5123
- Joined: Mon Sep 26, 2011 10:56 am
- Location: Looking forward to summer in Somerset, UK...
Re: ZXpand-AY Sound Module (Two 8 bit I/O ports control)
Sounds like you are having fun
Good work
Mark
Good work
Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
Re: ZXpand-AY Sound Module (Two 8 bit I/O ports control)
The program that I posted appears to be the start of something. I think my intention was to make one port an input and continuously read its vale and display it on-screen in binary. The other port would continuously count up for investigation using a logic probe, 'scope or analyser. I have to admit that I haven't run it in a long time and it appears to exit immediately after displaying the port state.
It would be a great service to the community if you wouldn't mind matching up what I posted with the data sheet and reporting on your findings - I don't have the spare time to play at the moment.
Good luck
C
Sir Morris,
I ran your ASM code but it had a problem with 'countup'. I set it to 0 in the beginning of the program with an EQU statement and at least it compiled.
The input section worked great and read my 8 input dip switch but the output LEDs seemed not to do anything (some were on and some off) 10101100 pattern. What was the intention for 'countup'? Trying to learn Z80 assembly...
Code: Select all
10 REM _asm
DFILE EQU $400c
IOPORT EQU $ef
REGSEL EQU $cf
REGVAL EQU $0f
countup EQU 0 'added this line to allow it to compile
// org 16514
start:
push af
push hl
push bc
ld hl,(DFILE)
inc hl
ld a,7 ; register 7 - enables
out (REGSEL),a ; set register
ld a,%10111111 ; port a is input, b is output, noise is off
out (REGVAL),a ; set value
ld a,14 ; read from reg 14 - i/o port A
out (REGSEL),a ; set register
in a,(IOPORT) ; read the port
ld c,a
ld b,8
loopin:
ld a,$1c ; '0'
rlc c
adc a,0
ld (hl),a
inc hl
djnz loopin
ld a,15 ; write to reg 15 - i/o port b
out (REGSEL),a ; set register
ld a,(countup)
inc a
ld (countup),a
out (REGVAL),a ; set register
pop bc
pop hl
pop af
ret
END _asm
Re: ZXpand-AY Sound Module (Two 8 bit I/O ports control)
countup is just a counter.
You should use a variable for it, not a constant.
This can be compiled but doesn't make sense.
So A register is read from address "0" and incremented and written to address "0".
This is occupied by ROM and doesn't has an effect but in a system with RAM at this address or even EEPROM your program could crash.
This is a definition for an assembly variable:
You should place the variable definitions in your assembly section, maybe at the end (after ret but before END _asm).
Definitions with EQU are handled as constants.
So check up the differences between constants and variables.
This code will be compiled to:
So the byte at address 0 is read ($D3), incremented to $D4 and this is written as output (always the same value).
If you use a variable instead, the output will be incremented from 0 to $FF in 256 steps (8 bit).
You should use a variable for it, not a constant.
This can be compiled but doesn't make sense.
So A register is read from address "0" and incremented and written to address "0".
This is occupied by ROM and doesn't has an effect but in a system with RAM at this address or even EEPROM your program could crash.
This is a definition for an assembly variable:
Code: Select all
countup db 0 // byte
countupw dw 0 // word
Definitions with EQU are handled as constants.
So check up the differences between constants and variables.
Code: Select all
ld a,(countup)
inc a
ld (countup),a
out (REGVAL),a ; set register
Code: Select all
ld a,(0)
inc a
ld (0),a
out (REGVAL),a ; set register
If you use a variable instead, the output will be incremented from 0 to $FF in 256 steps (8 bit).
Re: ZXpand-AY Sound Module (Two 8 bit I/O ports control)
Thanks PokeMon - That fixed it. The LED/resistor outputs are binary counting and the input switches are displaying on the screen. DONE !
Code: Select all
10 REM _asm
DFILE EQU $400c
IOPORT EQU $ef
REGSEL EQU $cf
REGVAL EQU $0f
// org 16514
start:
push af
push hl
push bc
ld hl,(DFILE)
inc hl
ld a,7 ; register 7 - enables
out (REGSEL),a ; set register
ld a,%10111111 ; port a is input, b is output, noise is off
out (REGVAL),a ; set value
ld a,14 ; read from reg 14 - i/o port A
out (REGSEL),a ; set register
in a,(IOPORT) ; read the port
ld c,a
ld b,8
loopin:
ld a,$1c ; '0'
rlc c
adc a,0
ld (hl),a
inc hl
djnz loopin
ld a,15 ; write to reg 15 - i/o port b
out (REGSEL),a ; set register
ld a,(countup)
inc a
ld (countup),a
out (REGVAL),a ; set register
pop bc
pop hl
pop af
ret
countup db 0 // byte
END _asm