Jump to content
BNE Jeff

How to put op codes in RAM

Recommended Posts

Good Morning,

 

Can anyone please tell me a good way to get Dasm to put op codes and operands in RAM?  I'll be running some code there for speed but looking up the op codes and then storing that number seems like it might be more difficult than it has to be.  Best I can think of is defining some op codes as constants and then loading and storing them such as:

 

LDAImmediate     = $A9  ; Load the accumulator with an immediate

 

And then to write lda #20 in the RAM code, my ROM code would be something like:

 

lda #LDAImmediate

sta $80

lda #20

sta $81

 

Is this a decent method or is there something better?

 

Share this post


Link to post
Share on other sites

Note: I noticed a crucial bit of code was missing - the ROM copy (ZProutineROM) and size calculation (ZPsize).  I added that while you were reading the blog post.

Share this post


Link to post
Share on other sites

Thanks!  So that looks really straight forward if I understand it correctly.  Like this?:

 

ZProutineRAM    ds 16

    ldy #15
InitZP  
    lda ZProutineROM,y
    sta ZProutineRAM,y
    dey
    bpl InitZP

ZProutineROM:

;read 3 bytes of garbage from here up.  Be careful about the jump to RAM 
;address because it can change.  I think I might use iny and cpy #15 instead.
	lda #SomeNumber		; 2 bytes
	sta SomeRegister	; 2 bytes
	lda ($44,X)		; 6 bytes
	jmp KernelEnd		; 3 bytes

 

Share this post


Link to post
Share on other sites

OK yeah I fixed it- Thanks...  And I see the ZPsize too which would eliminate the jmp issue I mentioned.  Though that looks like it can be risky if I don't manage RAM appropriately.

Share this post


Link to post
Share on other sites
2 hours ago, BNE Jeff said:

Thanks!  So that looks really straight forward if I understand it correctly.  Like this?:

 

ZProutineRAM    ds 16

    ldy #15
InitZP  
    lda ZProutineROM,y
    sta ZProutineRAM,y
    dey
    bpl InitZP

ZProutineROM:

;read 3 bytes of garbage from here up.  Be careful about the jump to RAM 
;address because it can change.  I think I might use iny and cpy #15 instead.
	lda #SomeNumber		; 2 bytes
	sta SomeRegister	; 2 bytes
	lda ($44,X)		; 6 bytes
	jmp KernelEnd		; 3 bytes

 

edit never mind

Edited by bogax
I goofed

Share this post


Link to post
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
Reply to this topic...

×   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.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...