Hi!
I'm trying to create a simple routine, that is called via NMI, but no luck so far. I followed this posting
viewtopic.php?t=1099#p11462
, but I guess there is something missing.
Thanks in advance for any hint.
Ciao,
Andreas
IRQ Programming
IRQ Programming
- Attachments
-
- irqtest.zip
- (3.03 KiB) Downloaded 134 times
Re: IRQ Programming
You can not just "CALL" $0281. This will never return to the program as it is not a subroutine. Typically the NMI does a JP (IX) and not a call to that routine. So the stack will be overrun over the time. And IX is changed/toggled wether the display has to be generated or the keyboard has to be read. So you won't have a stable picture.
What you can do is
a) set IX to an own routine
b) do your own stuff
c) setup a toggle bit wether video ($0281) or keyboard ($028f) should be called (jumped !!!)
d) do a jump to $0281 or $028f
At the end you will see, that the video timing is incorrect and picture is not shown good.
So at the end you will have to copy the complete code of $0229 - $028f to RAM, set IX to corresponding address ($0281 doubled in RAM for example) and modify the $0292 routine which starts NMI and restore registers and continue user program. You can put then your code after starting NMI but before restoring the register HL/DE/BC/AF.
What you can do is
a) set IX to an own routine
b) do your own stuff
c) setup a toggle bit wether video ($0281) or keyboard ($028f) should be called (jumped !!!)
d) do a jump to $0281 or $028f
At the end you will see, that the video timing is incorrect and picture is not shown good.
So at the end you will have to copy the complete code of $0229 - $028f to RAM, set IX to corresponding address ($0281 doubled in RAM for example) and modify the $0292 routine which starts NMI and restore registers and continue user program. You can put then your code after starting NMI but before restoring the register HL/DE/BC/AF.
Re: IRQ Programming
Have a look to "Monitor" from XavSnap/Nipperroutine:
http://zx81.ordi5.free.fr/xavsnap/download/monitor.zip
Use the « NIPPERROUTINE » to print a Hexadecimal code to the Zxprinter.
http://zx81.ordi5.free.fr/xavsnap/download/monitor.zip
Use the « NIPPERROUTINE » to print a Hexadecimal code to the Zxprinter.
Code: Select all
;------- TASM ASM mnemonics. -------
; Compile this file using:
; Set TASMOPTS = -b
; tasm -80 ThisCode.tas MyBinary.BIN
;-----------------------------------
; Zx81 Program name: VB81 XuR [FPH-BAS-MONITOR.P] : SAVE"FPH-BAS-MONITOR" Line 8
; REM line name: 2 REM: 77 Bytes@4082-40CE
#define ORG .org ; TASM cross-assembler definitions
#define equ .equ
;-----------------------------------
;------------------------------------
;-Basic sub-routine entry. -
;+----------------------------------+
; Lb4084 ; <- USR Basic Enty.
;+----------------------------------+
;------- Rom and Ram Symbols -------
RAM_RAMTOP equ $4004
RAM_SPARE2 equ $407B
RAM_STKEND equ $401C
RAM_ERR_SP equ $4002
ORG $4082 ; [@16514/@h4082]
NOP
NOP
Lb4084: ; <- USR Basic Enty.
LD HL,(RAM_RAMTOP) ; GET RAM-TOP
SBC HL,SP
LD B,H
LD C,L
ADD HL,SP
DEC HL
EX DE,HL
LD HL,(RAM_SPARE2) ; GET UNUSED-16
DEC HL
AND A
SBC HL,DE
JR C, Lb409F ; [$409F:16543]
JR Z, Lb40C7 ; [$40C7:16583]
ADD HL,DE
EX DE,HL
LDDR
JR Lb40B3 ; [$40B3:16563]
Lb409F:
ADD HL,SP
PUSH HL
LD HL,(RAM_STKEND) ; GET STKEND
LD DE,$0080
ADD HL,DE
POP DE
SBC HL,DE
JR NC, Lb40C7 ; [$40C7:16583]
LD HL,$0000
ADD HL,SP
LDIR
Lb40B3:
EX DE,HL
SBC HL,DE
LD D,H
LD E,L
ADD HL,SP
LD SP,HL
RR HL,(RAM_E_SP) ; GET ERR-SP
ADD HL,DE
RR (RAM_E_SP),HL ; SET ERR-SP
LD HL,(RAM_SPARE2) ; GET UNUSED-16
LD (RAM_RAMTOP),HL ; SET RAM-TOP
Lb40C7:
LD BC,(RAM_RAMTOP) ; GET RAM-TOP
RET ; ==========================
Lb40CC: ; <<< Uncharted Entry ]
JP $7A3C ; [31292]
.end
Code: Select all
;------- TASM ASM mnemonics. -------
; Compile this file using:
; Set TASMOPTS = -b
; tasm -80 ThisCode.tas MyBinary.BIN
;-----------------------------------
; Zx81 Program name: VB81 XuR [FPH-BAS-MONITOR.P] : SAVE"FPH-BAS-MONITOR" Line 8
; REM line name: 4 REM: 299 Bytes@40D5-41FF
#define ORG .org ; TASM cross-assembler definitions
#define equ .equ
;-----------------------------------
;------- Rom and Ram Symbols -------
SLOW equ $0F2B
DISPLAY_5 equ $02B5
DISPLAY_3 equ $0292
LOOP_11 equ $0216
RAM_D_FILE equ $400C
COPY equ $0869
CLS equ $0A2A
ORG $40D5 ; [@16597/@h40D5]
NOP
JR C, Lb40E0 ; [$40E0:16608]
ADD HL,SP
CALL SLOW ; [SLOW]
LD IX,$7EE7
Lb40E0:
CALL $7F27 ; [32551]
CALL $7FF4 ; [32756]
RET ; ==========================
Lb40E7: ; <<< Uncharted Entry ]
LD A,R
LD BC,$1901
LD A,$F5
CALL DISPLAY_5 ; [DISPLAY-5]
CALL DISPLAY_3 ; [DISPLAY-3]
CALL LOOP_11+10 ; []*BIOS ROM*
LD IX,$7EE7
LD H,(IY-81)
JP Z, DISPLAY_3+18 ; []*BIOS ROM*
LD H,(IY-81)
LD HL,(RAM_D_FILE) ; GET D-FILE
LD BC,$0318
Lb410A:
LD A,$10
CPIR
Lb410E:
JP PO, DISPLAY_3+18 ; []*BIOS ROM*
LD A,(HL)
CP $76 ; [118]
JR Z, Lb4123 ; [$4123:16675]
CP $11 ; [17-")"]
JR Z, Lb410A ; [$410A:16650]
SET 7,(HL)
LD H,(IY+118)
JR Z, Lb4123 ; [$4123:16675]
RES 7,(HL)
Lb4123:
CPI
JR Lb410E ; [$410E:16654]
CALL $7F2E ; [32558]
CALL $7F2F ; [32559]
RET ; ==========================
Lb412E: ; <<< Uncharted Entry ]
RET ; ==========================
Lb412F: ; <<< Uncharted Entry ]
LD HL,(RAM_D_FILE) ; GET D-FILE
INC HL
INC HL
LD ($7FFD),HL
LD DE,($7FFD)
LD HL,($7ED5)
CALL $7FB8 ; [32696]
LD A,$16
LD (DE),A
INC DE
INC DE
LD ($7FFD),DE
LD A,$08
LD ($7FFF),A
LD DE,($7FFD)
LD HL,($7ED5)
LD A,(HL)
LD HL,$0000
LD L,A
CALL $7FE0 ; [32736]
INC DE
LD ($7FFD),DE
LD HL,($7ED5)
INC HL
LD ($7ED5),HL
LD BC,($7ED7)
INC BC
SBC HL,BC
RET Z
LD A,($7FFF)
DEC A
LD ($7FFF),A
CALL Z,$7F87 ; [32647]
LD A,($7FFF)
CP $08 ; [8]
JP Z,$7F37 ; [32567]
JP $7F53 ; [32595]
LD A,$08
LD ($7FFF),A
LD HL,($7FFD)
LD BC,$0002
ADD HL,BC
LD ($7FFD),HL
LD HL,(RAM_D_FILE) ; GET D-FILE
LD BC,$0318
ADD HL,BC
LD BC,($7FFD)
SBC HL,BC
CALL M,$7FA7 ; [32679]
RET ; ==========================
Lb41A7: ; <<< Uncharted Entry ]
CALL $7FF4 ; [32756]
LD HL,(RAM_D_FILE) ; GET D-FILE
INC HL
INC HL
LD ($7FFD),HL
LD A,$08
LD ($7FFF),A
RET ; ==========================
Lb41B8: ; <<< Uncharted Entry ]
LD BC,$D8F0
CALL $7FD5 ; [32725]
LD BC,$FC18
CALL $7FD5 ; [32725]
LD BC,$FF9C
CALL $7FD5 ; [32725]
LD C,$F6
CALL $7FD5 ; [32725]
LD C,$FF
CALL $7FD5 ; [32725]
RET ; ==========================
Lb41D5: ; <<< Uncharted Entry ]
LD A,$1B
Lb41D7:
INC A
ADD HL,BC
JR C, Lb41D7 ; [$41D7:16855]
SBC HL,BC
LD (DE),A
INC DE
RET ; ==========================
Lb41E0: ; <<< Uncharted Entry ]
LD A,L
CALL $7FE9 ; [32745]
LD A,L
CALL $7FED ; [32749]
RET ; ==========================
Lb41E9: ; <<< Uncharted Entry ]
RRA
RRA
RRA
RRA
AND $0F
ADD A,$1C
LD (DE),A
INC DE
RET ; ==========================
Lb41F4: ; <<< Uncharted Entry ]
LD D,$18
CALL COPY+2 ; []*BIOS ROM*
CALL CLS ; [CLS]
RET ; ==========================
Lb41FD: ; <<< Uncharted Entry ]
.end
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: IRQ Programming
Phew,,,,
Thanks a lot for your hints!
I'm new to the zx81 world, so it seems I have a lot to catch up, before I can write more code...
Thanks a lot for your hints!
I'm new to the zx81 world, so it seems I have a lot to catch up, before I can write more code...