6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 8:13 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Using IRQ/NMI functions
PostPosted: Wed Jul 18, 2018 7:57 pm 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1385
Now that I have EhBasic running on my SBC, I'm wondering how useful the IRQ and NMI functions are going to be.

My SBC has a Panic button that triggers a NMI. A ROM based routine handles a minimal restore to the I/O and BIOS/Monitor. I also use IRQ to support the UART's transmit and receive (w/128-byte circular buffers), received break (from terminal) and a 10ms jiffy clock for elapsed time since cold start and for accurate delays. So interrupts are endlessly being triggered at a minimum of 100 per second, plus any send/receive for the console (which is running 38.4K baud rate).

I'm debating removing them from the code and saving the ROM space, as I'm not really sure they will be of much use in the long run. Has anyone else using EhBasic made good use of the interrupt functions with EhBasic? I guess I'm looking for some reasons to keep one or both within the code.

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
PostPosted: Wed Jul 18, 2018 9:25 pm 
Offline
User avatar

Joined: Wed Mar 01, 2017 8:54 pm
Posts: 660
Location: North-Germany
I assume that these functions become handy if one is going to use EhBasic for standalone solutions. After reset you simply load your previously saved Basic program back into RAM, do a warmstart and simulate a RUN command. Then this application is doing everything. Being able to handle IRQs without assembly subroutines or together would greatly expand the possible applications.

Regards,
Arne


Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 19, 2018 6:22 am 
Offline

Joined: Sat Jul 28, 2012 11:41 am
Posts: 442
Location: Wiesbaden, Germany
From my EhBASIC bugs and quirks list:
Quote:
1. The interrupt system is severely broken.

When an IRQ occurs and IRQ_vec is called in min_mon.asm the interrupt is only
registered with IRQbase but the interrupt source is not serviced nor is the
interrupt disable bit set at RTI. As a consequence the interrupt is immediately
called again and again and IRQbase is trashed until the interrupt is serviced
by the ON IRQ handler in basic.

The problem is discussed in viewtopic.php?f=5&t=2411
How I solved the problem for my emulator:
https://github.com/Klaus2m5/AVR_emulate ... er/EhBASIC

However, you should keep in mind that the interrupt service capacity in EhBASIC
is very limited. In a 2MHz system more than 100 interrupts per second or
interrupts requiring less than 10ms service time should be handled in machine
language. The numbers are worse if the interrupt handler gets more complex.

Of course, a hybrid solution is always possible. You could service the interrupt
in machine language and flag an interrupt to basic only after a buffer is
filled/emptied or a count is reached.

_________________
6502 sources on GitHub: https://github.com/Klaus2m5


Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 19, 2018 3:59 pm 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1385
Thanks Arne and Klaus!

So I've decided to remove the interrupt related functions, for both IRQ and NMI, which also includes the removal of RETIRQ, RETNMI and OFF. This saved quite a few bytes of code overall.

I also went through the entire code listing and was able to replace about 19 JMP opcodes with BRA, saving some additional bytes of space and some clock cycles as well. I also managed to leverage some additional CMOS instructions/addressing modes which has resulted in a version which now occupies 9931 bytes of ROM space, which includes Klaus' recent IF patch.

I still need to change the Page Zero definitions and remove the IRQ/NMI bytes used... but the code execution is measurably quicker using some of the test programs that others have been kind enough to share. I'll work on posting some of that soon.

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 60 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron