Jump to content
  • 0

How (in)correct are these? ("Blind Kernal")


rje
 Share

Question

I wrote these from scratch.  I want to write them without ever seeing the actual kernal.

Easy-sounding ones first.

How close are these routines to being correct?

  1. I'm a kernal virgin.  Michael's pagetable site has the commentaries.
  2. I might be misusing opcodes.
  3. Error and boundary conditions might need handling.

 

Quote

 

; MEMTOP - get/set top of memory
; on carry set, loads MEMTOP into accumulator.
; on carry clear, sets MEMTOP as stored in X and Y (and loads MEMTOP into accumulator).
BCS memtop-load
STX MEMTOPADDR
STY MEMTOPADDR+1
RTS

memtop-load:
LDX MEMTOPADDR
LDY MEMTOPADDR+1
RTS

 

MEMBOT is virtually identical to MEMTOP.

SETTIM and RDTIM.  I think I'm going off the rails here with the indirect loading.  Now I'm thinking these are all direct, which would greatly shrink the code...

Quote

; SETTIM
STA TIMADDR
STX TIMADDR+1
STY TIMADDR+2
RTS


; RDTIM
LDA TIMADDR
LDX TIMADDR+1
LDY TIMADDR+2
RTS

 

In for a penny, in for a pound.  Here's UPTIM, and I suspect there's edge cases here I'm not seeing.

Quote

 

; UPTIM - update time
INC TIMADDR; low byte 
BCC uptim-done ; edge case handling?
INC TIMADDR+1; middle byte
BCC uptim-done ; edge case handling?
INC TIMADDR+2; high byte

uptim-done:

RTS

 

And SCREEN and PLOT.

Quote

 

; SCREEN
; There must be something I'm not seeing here.  Surely this is more complicated than that.
LDX MAXCOLADDR
LDY MAXROWADDR
RTS

; PLOT - get/set cursor position
; There must be something I'm not seeing here. 
; Do I need to do boundary checks?  Wrap?
BCC plot-move
LDX CURCOLADDR
LDY CURROWADDR
RTS

plot-move:
STX CURROWADDR
STY CURCOLADDR
RTS

 

 

 

Edited by rje
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

I suppose I can answer my own questions by calling the KERNAL routine on the X16 emulator, checking the result, clearing the registers, then calling these routines, and checking the result...

Edited by rje
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

Please review our Terms of Use