For my asm program I am writing, I need to know how to add to copy one program into another. This is my code so far:

Code:

 ld hl,Prog
 bcall Mov9toOP1
 bcall ChkFindSym
 jp c, nf ;if not found
 xor a
ex de,hl
Loop:
 inc a
 push hl
 ;copy byte from (hl+a) to (appBackupscreen+a)
 ;cp a,(the size of program)
 jp z,end
 jp nz,Loop

nf:
 ;store 10 in Ans
 ret

end:
 ret

Prog:
 .db ProgObj,"TEMP",0
Aight, let's take a look. My first impression is that you don't have a program to copy _to_, so we'll deal with that:


Code:
   ld hl,SourceProgram
   rst 20h      ;same as bcall(_Move9ToOp1), saves 2 bytes
   bcall ChkFindSym
   jp c, nf ;if not found
   ex de,hl
   ld c,(hl)
   inc hl
   ld b,(hl)
   inc hl
   ;now hl is at first data byte of source program
   ;and bc has its size.
   push hl
       push bc
           push bc
               pop hl    ;move bc->hl
           bcall(_EnoughMem)
           jr c,nf     ;if (FreeMem) < hl, we have a problem
           ld hl,DestProgram
           rst 20h
           bcall(_chkfindsym)
           jr nc,nf    ;should not exist!
           pop hl
        push hl
           bcall(_createprotprog)
           pop bc
        pop hl
    inc de
    inc de
    ldir      ;copy bc bytes from hl to de.
nf:
   ;store 10 in Ans
   ld a,10
   bcall(_xxtoop1)
   bcall(_StoAns)
   ret

SourceProgram:
    .db ProgObj,"BLAH",0
DestProgram:
    .db ProgObj,"TEMP",0
Note that this could easily have errors; I'll double-check it shortly.
Ok, I'll try that and see if it works. What if my basic program needed to change the names of the programs, how would I do that?
souvik1997 wrote:
Ok, I'll try that and see if it works. What if my basic program needed to change the names of the programs, how would I do that?
If you mean choose non-fixed program names on-the-fly, you could easily, for example, using a name in Str1 for the source and in Str2 for the destination. We can deal with that once you've tested out this code and see how it works.
Kerm, it worked! The only problem is that if the program already exists, it gives a ram clear.

Also, I noticed things like push hl/push bc/push bc/pop hl. How does that move bc into hl?
Ooooh, sorry. Change:


Code:
           jr c,nf     ;if (FreeMem) < hl, we have a problem
           ld hl,DestProgram
           rst 20h
           bcall(_chkfindsym)
           jr nc,nf    ;should not exist!
to


Code:
           jr c,nf2     ;if (FreeMem) < hl, we have a problem
           ld hl,DestProgram
           rst 20h
           bcall(_chkfindsym)
           jr nc,nf2    ;should not exist!
and at the end add:

Code:
nf2:
           pop hl
       pop hl
   jr nf


Pushing piles numbers onto the stack, which you can envision like a stack of books. Popping similarly removes books from that stack. If you push hl, it becomes a number on the top of the stack, but we don't know that it came from hl anymore. Then we can pop it: pop hl, pop bc, pop de, pop ix, it doesn't matter. Whichever we choose will become the new container for the number we took off of the top of the stack, so push hl \ pop bc essentially moves hl into bc. An alternative (and slightly faster) method is:

Code:
ld b,h
ld c,l
Update:

Installer can now search for all files (programs) starting with $BB1A (the header for Installer files) and it can display them in a nice GUIMenu.
souvik1997 wrote:
Update:

Installer can now search for all files (programs) starting with $BB1A (the header for Installer files) and it can display them in a nice GUIMenu.
That sounds awesome! Can you show us a screenshot, perhaps?
Oh, sorry, I haven't checked this topic in a while. I will get the screenshot as soon as I get on my computer with TiLP.

Do you know any good compression algorithms for compressing programs, preferably something that doesn't run too slowly??

Edit: this may be a DCS or tios bug:

When I make the GUImenu, I use my Find and Replace routine which replaces the spaces in the string given by det(9) with the + plot style token. However, when I Rcl the string after it has been parsed by my
routine the + tokens show up as question marks. A quick analysis with
Calcsys reveals the question marks to be $00 whereas the regular question marks are $AF.
That sounds like a bug in your Find and Replace routine to me, no? Can you present some code that introduces the bug?
Sure, here's my routine:
Note: (+) is the plot style token +

Code:

If A=1 //Checks if user pressed Unpack button
Then
det(9,"geometcdf("->Str1 //Finds programs with a $BBA1 header
If Ans=".6"
Then
sum(7,2,8,8,"F8888888F8","Error"
sum(7,4,10,10,"No files found"
sum(7,7,10,20,"Ok"
sum(12
sum(8,3
End
If Str1=".6
Goto ST  //jumps to beginning of program
//Beginning of Find/replace routine
sub(Str1,1,length(Str1)-1)+"(+)"->Str1 //To avoid DIM errors
For(X,1,length(Str1)-1
If sub(Str1,X,1)=" //One space
sub(Str1,1,X-1)+"(+)"+sub(Str1,X+1,length(Str1)-X->Str1
End
//End of Find/Replace routine
sum(13,8,8,"Open file...","F8888888F8",Str1 //GUIMenu


If I Rcl Str1 right before the GUIMenu, its contents are:
"AB(+)DCOOLFIL(+)" because there are two programs with names AB and DCOOLFIL with a $BBA1 header

After the GUIMenu, the contents of Str1 are
"AB?DCOOLFIL?". The menu still works normally though.

This is present in DCS 7.0.1
Ah, that's not a bug, that's just Doors CS chopping up the string into zero-terminated strings for display. Smile
Oh, okay.
souvik1997 wrote:
Oh, okay.
I hope that this behavior is not too much of an inconvenience to your program? If it was vital, I could make DCS 7.1 switch them back to stats pluses, but if it's not vital, then I'd rather save the space. Smile
No, it isn't. I just store Str1 to Str2 before the menu, then I switch it back.
souvik1997 wrote:
No, it isn't. I just store Str1 to Str2 before the menu, then I switch it back.
Ah, fair enough. On the subject of compression algorithms, Wikipedia has some choice words on lossless data compression algorithms, which is what you need:

http://en.wikipedia.org/wiki/Data_compression#Lossless
Would LZ77 be fast enough on a calculator?
http://en.wikipedia.org/wiki/Lempel-Ziv
souvik1997 wrote:
Would LZ77 be fast enough on a calculator?
http://en.wikipedia.org/wiki/Lempel-Ziv
With the amount of data that you're dealing with, namely a few dozen KB at best, I don't think that speed will be too much of a limiting factor. However, having sufficient memory buffers to do something like LZ77 might be awkward.
Right now I'm adding password functionality, so an archive can be password-protected. What other features should I add?
souvik1997 wrote:
Right now I'm adding password functionality, so an archive can be password-protected. What other features should I add?
What about presenting the default folder name that the programmer suggested for the files to be unpacked into, but allowing the user to choose an alternate folder name? I dunno, I'm grasping at straws here.
  
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
» Goto page Previous  1, 2, 3, 4, 5, 6  Next
» View previous topic :: View next topic  
Page 3 of 6
» 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