83Plus:OS:How BCALLs work

From WikiTI
Revision as of 20:07, 9 September 2005 by 144.131.13.168 (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

How BCALLS work. Sorry, this article isn't very well written. It would be good if someone else could maybe look at the TI-OS code a bit and explain this better.

BCALLs are the way to call TI-OS ROM routines, and also the way that the branch table works in multi-page apps. A BCALL is the RST 28h instruction, with a 16-bit number after it which is used to identify which routine it is calling.

If the first bit (bit 15) of the number is set, this is what the OS does:

-It resets bit 15 -It adds 0x4000 to the number -It maps page 1F into memory space 4000-7FFF

Otherwise, if bit 15 is reset and bit 14 is set, this is what the OS does:

-It resets bit 14 -It adds 0x4000 to the number -It maps page 1B into memory space 4000-7FFF

Otherwise, if bit 15 and 14 are both reset, it is treated as a multipage app branch, which is explained in the TI developer's guide.

Once the OS has mapped the appropriate page into 4000-7FFF, it uses the number in memory as a pointer into this page. In page 1B and 1F there are lists of vectors for the actual ROM routines. The vectors are 3 bytes, the first two bytes are a memory address and the next byte is the page that the routine is on.