Page 1 of 2
KB$BREK causing trap
Posted: Tue Apr 11, 2023 8:44 pm
by Bumblemittens
Hey guys, im new to organiser and struggling a bit, i was hoping someone could through some light on this?
Code: Select all
0001 START:
0000 4F CLRA
0001 5F CLRB
+
0002 C6 03 LDAB #PAKD
0004 3F 62 OS PK$SETP ; SELECT TOP SLOT
+
0006 C6 03 LDAB #03h ; 11111111b
0008 D7 01 STAB POB_DDR2 ; PORT 2 ALL OUTPUT
+
000A 71 BF 17 BCLR 6,POB_PORT6 ; SET CS3 LOW
000D 72 08 17 BSET 3,POB_PORT6 ; SET SOE_B HIGH
+
0001 INIT:
0010 86 00 LDAA #00h ; INITIAL VALUE
0012 36 PSHA
+
0001 LOOP:
0013 32 PULA ; GET A
0014 97 03 STAA POB_PORT2 ; SEND TO PORT 2
0016 4C INCA ; A+=1
0017 36 PSHA ; SAVE A
0018 3F 46 OS KB$BREK ; ON/CLR PRESSED?
001A 24 F7 BCC LOOP ; IF NOT
001C 20 00 BRA EXIT ; IF PRESSED
+
0001 EXIT:
001E 71 F7 17 BCLR 3,POB_PORT6 ; SET SOE_B LOW
0021 72 40 17 BSET 6,POB_PORT6 ; SET CS3 HIGH
0024 39 RTS
i've tried these two routines seperate and they work, port 2 counts, keyboad breaks and returns to system, but this program as a whole works until on/clr is pressed then causes a trap, for the life of me i cant see where but think it might have something to do with flags, i've tried the key part of it seperately and it returns to system fine
thanks in advance
ATB Shaun
Re: KB$BREK causing trap
Posted: Wed Apr 12, 2023 4:58 am
by amenjet
With a very quick look and not knowing much about this, your PSHA and then a jump to a RTN loops suspicious...
Regards
Andrew
Re: KB$BREK causing trap
Posted: Wed Apr 12, 2023 12:32 pm
by Bumblemittens
amenjet wrote: ↑Wed Apr 12, 2023 4:58 am
With a very quick look and not knowing much about this, your PSHA and then a jump to a RTN loops suspicious...
Regards
Andrew
Ok here's the situation, I want to utilise the top slot, to learn how to do that I built the latch circuit example on jaap's site, all the code above is doing is sending a number to port2, incrementing that number, checking to see if on/clr pressed, if not then it send the incremented number to port2, and so on in an endless loop of which you cannot escape unless on/clr is pressed.
I've tested the on/clr loop separately and it breaks out of the loop, I've tested the port2 incrementing and that works but obviously leaves you in a loop you can't get out of, putting the two parts together works fine until on/clr is pressed then causes a trap.
I realise the code above might be a bit shady, I'm trying to learn 6303 nmonics blind with no experience, I'm used to Z80 assembly and Im finding 6303 couldn't be any more different, I have a 6502 trainer board and I think it's closer to 6502 than z80
Shaun
Re: KB$BREK causing trap
Posted: Wed Apr 12, 2023 1:39 pm
by amenjet
Yes the 6303 is closer to 6502/6800 code than Z80.
The problem I think you have it that you are pushing A before you enter your loop then puls it off the stack, use it and push it back on the stack. Then, later if ON/CLEAR is pressed you exit with a RTS. But, you still have A on the stack from the last PSHA. So the RTS will pop the return address off the stack, part of which will be the A that you pushed and jump to a corrupt return address. A PULA just before you RTS should fix that problem.
Unforgiving, assembly language is.
Regards
Andrew
Re: KB$BREK causing trap
Posted: Wed Apr 12, 2023 4:19 pm
by Bumblemittens
amenjet wrote: ↑Wed Apr 12, 2023 1:39 pm
Yes the 6303 is closer to 6502/6800 code than Z80.
The problem I think you have it that you are pushing A before you enter your loop then puls it off the stack, use it and push it back on the stack. Then, later if ON/CLEAR is pressed you exit with a RTS. But, you still have A on the stack from the last PSHA. So the RTS will pop the return address off the stack, part of which will be the A that you pushed and jump to a corrupt return address. A PULA just before you RTS should fix that problem.
Unforgiving, assembly language is.
Regards
Andrew
Thanks Andrew, ok I admit your a genious lol, i'm trying too hard, putting a PULA after the BCC solved it, code now breaks back to system
Code: Select all
OS KB$BREK ; ON/CLR PRESSED?
BCC LOOP ; IF NOT
PULA ; RELEASE A OFF STACK
BRA EXIT ; IF PRESSED
Cheers, all the best
Shaun
Re: KB$BREK causing trap
Posted: Wed Apr 12, 2023 5:01 pm
by amenjet
No problem. It's just several decades of doing this sort of stuff...
Andrew
Re: KB$BREK causing trap
Posted: Wed Apr 12, 2023 11:29 pm
by Zenerdiode
Bumblemittens wrote: ↑Wed Apr 12, 2023 12:32 pm
I have a 6502 trainer board…
Is it an EMMA II by any chance?
Re: KB$BREK causing trap
Posted: Thu Apr 13, 2023 4:50 am
by amenjet
Zenerdiode wrote: ↑Wed Apr 12, 2023 11:29 pm
Bumblemittens wrote: ↑Wed Apr 12, 2023 12:32 pm
I have a 6502 trainer board…
Is it an EMMA II by any chance?
Fancy having a go at a weird 6502 SBC? I have a few of these PCBs somewhere:
https://www.youtube.com/watch?v=gca-PwKa4d8
or if you want to do a Z80 version then there's this:
https://studio.youtube.com/video/5vLokyCIKPk/edit
i have some of those PCBs somewhere too, although they weren't done in KICAD so are harder to access nowadays.
Andrew
Re: KB$BREK causing trap
Posted: Thu Apr 13, 2023 10:25 am
by Bumblemittens
Zenerdiode wrote: ↑Wed Apr 12, 2023 11:29 pm
Bumblemittens wrote: ↑Wed Apr 12, 2023 12:32 pm
I have a 6502 trainer board…
Is it an EMMA II by any chance?
Yes Emma II
Re: KB$BREK causing trap
Posted: Thu Apr 13, 2023 10:37 am
by Bumblemittens
I've built a few z80 systems already, can never have enough though lol, also have a microprofessor pro but the vfd is dead and very likely irreplaceable, shame, on day I might find one