Author Topic: Some basic questions  (Read 9923 times)

0 Members and 2 Guests are viewing this topic.

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Some basic questions
« Reply #15 on: November 07, 2012, 07:59:06 pm »
The calculator does indeed use dynamic memory allocation for user data. And BASIC programs don't get moved before execution; the parser is able to parse BASIC programs from where ever they're located in memory. However, the Z80 CPU doesn't well-support doing that for assembly programs. In particular, the JP and CALL instructions have to know the exact location they're branching to before program execution begins. So the OS always copies assembly programs to the exact same location in RAM so that the assembler can always compute before hand the address to jump to.

In theory, you could have your program store a list of the locations of+ instructions in the program that need to be fiddled with before executing, but that's more complicated solution than anybody so far has been willing to deal with.
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Some basic questions
« Reply #16 on: November 08, 2012, 12:16:04 am »
Not to mention things like jump tables and SMC would be hard to implement.

Offline bored_student

  • LV3 Member (Next: 100)
  • ***
  • Posts: 44
  • Rating: +3/-0
    • View Profile
Re: Some basic questions
« Reply #17 on: November 08, 2012, 09:37:27 am »
By the way:
  Is there a way to store the current value of the PC register somewhere else
Sorry for my bad English, I'm German.

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Some basic questions
« Reply #18 on: November 08, 2012, 11:16:25 am »
If I remember correctly you could do a push pc \ pop hl to store it in hl. You wouldn't want to leave it on the stack because on the next ret it would jump back to it.
If that doesn't work a little hack you could probably do would be
Code: [Select]
  call self
self:
  pop hl
/e

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Some basic questions
« Reply #19 on: November 08, 2012, 02:12:15 pm »
There is no "push pc". The "call $+3 \ pop hl" will work, though. (But just to reiterate, it's not relocatable, which probably isn't a problem for you.)
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline bored_student

  • LV3 Member (Next: 100)
  • ***
  • Posts: 44
  • Rating: +3/-0
    • View Profile
Re: Some basic questions
« Reply #20 on: November 08, 2012, 02:28:11 pm »
It is a problem for me because if I want to add some ASM Code in an Axe Programm with the Asm() command, I don't really know where the ASM code is stored.
Sorry for my bad English, I'm German.

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Some basic questions
« Reply #21 on: November 08, 2012, 02:30:28 pm »
hmm well it depends on what you want to do with the code?
I'm not a nerd but I pretend:

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Some basic questions
« Reply #22 on: November 08, 2012, 02:32:37 pm »
Code: [Select]
ld hl, $E9E1 ;pop hl \ jp (hl)
ld (appBackUpScreen), hl
call appBackUpScreen
here:

This returns with HL = here.


Edit:
   optimized a little


Edit2:
    Here are two other options (with runer's help)

Fastest version:
Code: [Select]
di
call $000F
here:
dec sp
dec sp
pop hl

Smallest version: (destroys BC and DE)
Code: [Select]
di
rst 20h
here:
dec sp
dec sp
pop hl
« Last Edit: November 08, 2012, 02:42:24 pm by thepenguin77 »
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Some basic questions
« Reply #23 on: November 08, 2012, 07:30:32 pm »
It is a problem for me because if I want to add some ASM Code in an Axe Programm with the Asm() command, I don't really know where the ASM code is stored.
In that case, you may want to use an Axiom, since the Axe Axiom parser supports resolving jump references. (More information is in the SDK. The Axe Parser will parse the Axiom's bytestream so it can identify jumps and calls that need references resolved.) If you want to make Axioms on-calc, you can actually just use Mimas. It doesn't support the standard helper macro used for Axiom jump resolution, but there's an easy enough workaround you can use instead.
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Some basic questions
« Reply #24 on: November 08, 2012, 08:34:33 pm »
There is no "push pc". The "call $+3 \ pop hl" will work, though. (But just to reiterate, it's not relocatable, which probably isn't a problem for you.)
I had thought so, I just couldn't quite remember.
/e

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Some basic questions
« Reply #25 on: November 09, 2012, 05:14:28 am »
I agree with DrDnar. Axioms are the best!
I'm not a nerd but I pretend: