1) what i meant was, do i directly copy and place the subroutines you listed, or call them as subroutine where the remark is in these...

Code:
HandleTimer1:
   in a, (03h)
   res 1, a
   out (03h), a
   set 1, a
   out (03h), a
   ; Timer one interrupt (might be best to merge with timer 2)
   jr InterruptDone


2) *restart* ok. does a stack exist and just the routines push hl and whatnot dont?I may need a little more explanation otherwise
2) It exists, but you cannot be sure of where it points to at boot time. It could point at ROM, for all we know. You should make sure it points somewhere safe.
1) Sorry, I didn't fully understand you. Here's an interrupt routine with Timer1 and Timer2 merged:

Code:
; System Interrupt Routines
SysInterrupt:
   exx
   ex af, af'
   in a, (04h)
   bit 0, a
   jr nz, HandleON
   bit 1, a
   jr nz, HandleTimer1
   bit 2, a
   jr nz, HandleTimer2
   bit 4, a
   jr nz, HandleLink
   jr InterruptDone
HandleON:
   in a, (03h)
   res 0, a
   out (03h), a
   set 0, a
   out (03h), a
   ; ON interrupt
   jr InterruptDone
HandleTimer1:
   in a, (03h)
   res 1, a
   out (03h), a
   set 1, a
   out (03h), a
   ; Timer one interrupt (might be best to merge with timer 2)
   jr TimerInterrupt
HandleTimer2:
   in a, (03h)
   res 2, a
   out (03h), a
   set 2, a
   out (03h), a
TimerInterrupt:
   ; Timer two interrupt
   jr InterruptDone
HandleLink:
   in a, (03h)
   res 4, a
   out (03h), a
   set 4, a
   out (03h), a
   ; Link interrupt
InterruptDone:
   ex af, af'
   exx
   ei
   ret
This page should help you a lot with interrupts, Anak; it certainly helped me a lot:

http://wikiti.brandonw.net/index.php?title=83Plus:Ports:03
*restart* I understand the interrupt, I'm trying to understand where to put these (>_< im just braindead today)

Quote:
Simple code to set up the LCD so you can draw on it:

Code:
Code:
   ld a, 40h
   out (10h), a
   ld a, 05h
   call LCDDelay
   out (10h), a
   ld a, 01h
   call LCDDelay
   out (10h), a
   ld a, 3
   call LCDDelay
   out (10h), a
   ld a, 0F6h
   call LCDDelay
   out (10h), a



And to set up memory (ROM 00\ROM 01\RAM 01\RAM 00):

Code:
Code:
    ld a, 1    ; Set flash page 1 in bank 1.
    out (6), a
    in a, (2)    ;get calc version
    rlca ;Roll bit 7 into carry.
    ld a, 41h ; Set ram page 1 in bank 2.
    jr nc, LowerModel
HigherModel:
    out (5),a
    ld a,81h
    out (7),a
    jr Done
LowerModel:
    out (6), a
    out (7),a
Done:
Set up memory at boot up, it should probably be the first thing. The LCD code should come after.
>_< aye, ok so here's everything you need to start right...


Code:
.org $0000

OSHeader:
  jr Boot
  .db 0,0,0,0,0,0
  .db 0,0      ; rst 08h
  .db 0,0,0,0,0
  .db 0,0      ; rst 10h
  .db 0,0,0,0,0
  .db 0,0      ; rst 18h
  .db 0,0,0,0,0
  .db 0,0      ; rst 20h
  .db 0,0,0,0,0
  .db 0,0      ; rst 28h
  .db 0,0,0,0,0
  .db 0,0      ; rst 30h
  .db 0,0,0,0,0,0,0
  .dw SysInterrupt   ; rst 38h / System Interrupt
  .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  .db 0,0,0,0,0,0,0,0,0
  jp Boot
  .dw 0A55Ah
Boot:
  jr Start_Of_OS
SysInterrupt:
   exx
   ex af, af'
   in a, (04h)
   bit 0, a
   jr nz, HandleON
   bit 1, a
   jr nz, HandleTimer1
   bit 2, a
   jr nz, HandleTimer2
   bit 4, a
   jr nz, HandleLink
   jr InterruptDone
HandleON:
   in a, (03h)
   res 0, a
   out (03h), a
   set 0, a
   out (03h), a
   ; ON interrupt
   jr InterruptDone
HandleTimer1:
   in a, (03h)
   res 1, a
   out (03h), a
   set 1, a
   out (03h), a
   ; Timer one interrupt (might be best to merge with timer 2)
   jr TimerInterrupt
HandleTimer2:
   in a, (03h)
   res 2, a
   out (03h), a
   set 2, a
   out (03h), a
TimerInterrupt:
   ; Timer two interrupt
   jr InterruptDone
HandleLink:
   in a, (03h)
   res 4, a
   out (03h), a
   set 4, a
   out (03h), a
   ; Link interrupt
InterruptDone:
   ex af, af'
   exx
   ei
   ret
Start_Of_OS:
SetupMem:
  ld a, 1    ; Set flash page 1 in bank 1.
  out (6), a
  in a, (2)    ;get calc version
  rlca ;Roll bit 7 into carry.
  ld a, 41h ; Set ram page 1 in bank 2.
  jr nc, LowerModel
HigherModel:
  out (5),a
  ld a,81h
  out (7),a
  jr Done
LowerModel:
  out (6), a
  out (7),a
SetupLCD:
   ld a, 40h
   out (10h), a
   ld a, 05h
   call LCDDelay
   out (10h), a
   ld a, 01h
   call LCDDelay
   out (10h), a
   ld a, 3
   call LCDDelay
   out (10h), a
   ld a, 0F6h
   call LCDDelay
   out (10h), a 

;PROGRAM CODE HERE
Fixed.

Code:
.org $0000

OSHeader:
  jr Boot
  .db 0,0,0,0,0,0
  .db 0,0      ; rst 08h
  .db 0,0,0,0,0
  .db 0,0      ; rst 10h
  .db 0,0,0,0,0
  .db 0,0      ; rst 18h
  .db 0,0,0,0,0
  .db 0,0      ; rst 20h
  .db 0,0,0,0,0
  .db 0,0      ; rst 28h
  .db 0,0,0,0,0
  .db 0,0      ; rst 30h
  .db 0,0,0,0,0,0,0
  .dw SysInterrupt   ; rst 38h / System Interrupt
  .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  .db 0,0,0,0,0,0,0,0,0
  jp Boot
  .dw 0A55Ah
Boot:
  jr Start_Of_OS
SysInterrupt:
   exx
   ex af, af'
   in a, (04h)
   bit 0, a
   jr nz, HandleON
   bit 1, a
   jr nz, HandleTimer1
   bit 2, a
   jr nz, HandleTimer2
   bit 4, a
   jr nz, HandleLink
   jr InterruptDone
HandleON:
   in a, (03h)
   res 0, a
   out (03h), a
   set 0, a
   out (03h), a
   ; ON interrupt
   jr InterruptDone
HandleTimer1:
   in a, (03h)
   res 1, a
   out (03h), a
   set 1, a
   out (03h), a
   ; Timer one interrupt (might be best to merge with timer 2)
   jr TimerInterrupt
HandleTimer2:
   in a, (03h)
   res 2, a
   out (03h), a
   set 2, a
   out (03h), a
TimerInterrupt:
   ; Timer two interrupt
   jr InterruptDone
HandleLink:
   in a, (03h)
   res 4, a
   out (03h), a
   set 4, a
   out (03h), a
   ; Link interrupt
InterruptDone:
   ex af, af'
   exx
   ei
   ret
Start_Of_OS:
SetupMem:
  ld a, 1    ; Set flash page 1 in bank 1.
  out (6), a
  in a, (2)    ;get calc version
  rlca ;Roll bit 7 into carry.
  ld a, 41h ; Set ram page 1 in bank 2.
  jr nc, LowerModel
HigherModel:
  out (5),a
  ld a,81h
  out (7),a
  jr Done
LowerModel:
  out (6), a
  out (7),a
Done:             <-----
SetupLCD:
   ld a, 40h
   out (10h), a
   ld a, 05h
   call LCDDelay
   out (10h), a
   ld a, 01h
   call LCDDelay
   out (10h), a
   ld a, 3
   call LCDDelay
   out (10h), a
   ld a, 0F6h
   call LCDDelay
   out (10h), a

;PROGRAM CODE HERE
Hmm, that's actually quite a nice template to have for very very basic OS projects. From that I bet PongOS would be nearly trivial. Smile
Ok, i got now. (i dont see why the Done label was so important...)
KermMartian, you should glance through the first post, it has it laid out pretty well. The attached KnightKernelBasic is basically the above code, plus some extra routines for LCD access, keyboard stuff, and the like. KnightKernelBasic was intended to be a simple framework to build upon.
Anak, that line was important because this line was in the code:
jr Done
ah der Razz didnt catch that. I'd change that SetupMem_End to prevent an commonly used label issue later on though

or maybe just jump to setuplcd
Oh snap, I remember reading your original post, but I didn't think that it handled interrupts at all. Now I see that it does. Razz
Well, I don't think this is really the best way of setting it up, honestly. I have it a bit differently, as you can see if you look through the code in KnightKernelBasic.
I think it works pretty well.I might save it as OSHeader.inc and just use it as a header...


Code:
#include OSHeader.inc
;blah blah blah


skips the bull
Perhaps, but I would be careful about that. With an OS, your code really needs to be organized carefully.
I already can see that i need to work from hardware lvl up. For routines, ill start with iFastCopy and my CheckKey routines.

There isnt any special things you have to do to use the keypad right, (besides direct input that is)
No special things for the keypad Smile

I would advise that you keep KKB as a reference. It is a fully functional framework for an OS, and is organized in a way that is logical and won't get you stuck somewhere later on. I don't mean to self promote, but organization is important in an OS.
Very Happy I planned to anyways. I think once i get everything working, I might release a kit just for making an OS that comes with all the basic routines needed just for people like me
Razz KKB is exactly what you just said. Just saying. It boots up, sets up memory and the LCD, and has a bit comment that says "your code here." It also contains basic routines for manipulating the LCD, displaying text, and accessing the keyboard.
I meant for people who'd rather not use ZDS and whatnot. Actually, I think I'll add wabbitsign in the package and have 3 makefiles Make8xp, Make8xk, and Make8xu. perhaps even add a registry key to associate .z80 and .asm files with them so you can compile from the context menu
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 5
» All times are UTC - 5 Hours
 
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 vote in polls in this forum

 

Advertisement