Author Topic: How does B_CALLs know which page to look at?  (Read 8473 times)

0 Members and 1 Guest are viewing this topic.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: How does B_CALLs know which page to look at?
« Reply #15 on: April 16, 2011, 06:27:03 pm »
Because the bcall for the app is bcall(0216h) instead of bcall(4216h) even though they are still the same address. Once the routine figures out that it is less than 4000h, it realises it is from an APP and then adds 4000h to the address :)

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: How does B_CALLs know which page to look at?
« Reply #16 on: April 16, 2011, 06:28:55 pm »
But if the application runs from $4000, how can it run from $0216?  If indeed $4000 is subtracted, why isn't $4000 subtracted from

B_CALL _OP2ExOP5   ;EQU 4216h

whenever it is in the application?

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: How does B_CALLs know which page to look at?
« Reply #17 on: April 16, 2011, 06:30:04 pm »
Because it isn't run from that :) The bcall sees it is from an app so it takes the address and adds 4000h to it then jumps to the correct address

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: How does B_CALLs know which page to look at?
« Reply #18 on: April 16, 2011, 06:34:44 pm »
Hold it:

I should have looked at my S.A.D. code.  What was I thinking?  Values are defined as less than $4000 from the start!   40 * 3 is NOT $4000 + (40 * 3)

:banghead:   :banghead:

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: How does B_CALLs know which page to look at?
« Reply #19 on: April 16, 2011, 06:36:52 pm »
Hehe, I was making this post waiting for a response, so I will just post anyway...

This is why I like hex.... it makes much more sense...

EF1602

Step1:
calls 0028h which jumps to another location

Step2:
analyses address. Sees  that 0216 does not have bit 14 or bit 15 set so it handles it as an app bcall

Step3:
Adds 4000h to 0216h and stores it to HL. Then it fetches the call info at that address.

Step3:
stores address elsewhere, gets the current app page and uses the offset page to adjust

Step4:
Calls the call.

Step5:
Restore the page and rets to return.

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: How does B_CALLs know which page to look at?
« Reply #20 on: April 16, 2011, 06:38:41 pm »
Also a ninja for me. So here's my explanation.

Ok, I'll break this down all the way.

bcall(_OP2ExOP5) is actually bcall($4216) which is actually

Code: [Select]
rst 28h
.dw $4216

my previous bcall(killCalculator) is actually bcall($0083) which is actually

Code: [Select]
rst 28h
.dw $0083

When the calculator encounters the rst 28h, it goes to $0028, which takes the next two bytes and parses them.

If the next two bytes are in the $4000 - $7FFF range: It looks on page $1B/$3B/$7B for the location data.
If the next two bytes are in the $0000 - $3FFF range: It looks on the first page of the app that is running for the location data.

The data that it is looking for is going to have this format:
Code: [Select]
.dw address
.db page

So when bcall(_OP2ExOP5) is executed. The OS is going to look on page $7B at $4216 for the data, which happens to be (in 2.53) $C8, $1D, $00. So the calculator is now going to call $1DC8 on page 0.

When bcall(killCalculator) is executed. The OS is going to look at the current app page ($69) at $4083 for the data. Which might be: $00, $40, $01. So the calculator is now going to call $4000 on app page 1, (which might be $68).
« Last Edit: April 16, 2011, 06:40:01 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 Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: How does B_CALLs know which page to look at?
« Reply #21 on: April 16, 2011, 06:41:52 pm »
Well no more explinations needed.  I simply forgot that the branch table consists of equates less than $4000.  I got confused thinking they were $4000 or more.
« Last Edit: April 16, 2011, 06:42:18 pm by Hot_Dog »