Changes

BIOS Kernel Functions

3,288 bytes added, 21:48, 24 January 2010
Created page with '== Low Jump (to BIOS Bank) == RST 08h is used in vectors at [BB00h and up] (official BIOS functions). 0008 KL_LO_JUMP (RST1) ;in: [[SP]]=dest,out: SP=SP+2;\jump dest AND 3FFF…'
== Low Jump (to BIOS Bank) ==
RST 08h is used in vectors at [BB00h and up] (official BIOS functions).
0008 KL_LO_JUMP (RST1) ;in: [[SP]]=dest,out: SP=SP+2;\jump dest AND 3FFFh
000B KL_LO_CALL_HL ;in: HL=dest ;/with ROM cfg = MSBs
RST 28h is used in vectors at [BDxxh] (BASIC sub-functions; EDIT/FLO/INT).
0028 KL_FIRM_JUMP (RST5) ;in: [[SP]]=addr,out:SP=SP+2 ;LO=ON,call addr,LO=OFF
RST 08h and RST 28h act as "JUMPS", ie. they discard the retadr on stack, and return to the function that has called the RST opcode (rather than returning to a location after the RST opcode).
Although they aren't identical, RST 08h and RST 28h have exactly the same purpose, the main difference is that RST 28h is faster.

== Far Call (to Any Bank) ==
0018 KL_FAR_CALL_SP (RST3) ;in: [[[SP]]]=addr/cfg, out:PC=[SP]+2 ;\useful
001B KL_FAR_CALL_C_HL ;in: HL=addr, C=cfg ; for RSX
0023 KL_FAR_CALL_HL ;in: [HL]=addr/cfg ;/commands
The triple-indirect [[[SP]]] means: [SP]=retadr, [retadr]=ptr16bit, [ptr16bit]=ptr24bit (lsb,msb,bank). Using the 16bit pointer (instead of directly storing the 24bit pointer after the RST opcode), has two reasons: One can store the KL_FIND_COMMAND result in DATA region (rather than needing to patch the CODE region), and one can put RST 18h in the 3-byte BIOS vector region (eg. done by AMSDOS to patch the CAS_functions; where the AMSDOS functions do manually remove retadr from stack, so that the FAR_CALL works like a FAR_JUMP in that case).

== Side Call (to another BASIC bank) ==
0010 KL_SIDE_CALL_SP (RST2);in: [[SP]]=dest,out:PC=[SP]+2;\jump dest OR C000h
0013 KL_SIDE_CALL_HL ;in: HL=dest ;/bank=base+DEST/C000h
Rarely useful. Probably intended for future, where BASIC ROM might grow from 16K to up to 64K (=four ROM banks).

== Jump to Register (normal NEAR jumps, without changing memory banks) ==
000E KL_JP_BC ;in: BC=addr
0016 KL_JP_DE ;in: DE=addr
001E KL_JP_HL ;in: HL=addr
Jumps to BC, DE, or HL (either by PUSH BC/DE, RET, or by JP HL opcodes).

== Enable/Disable upper or lower ROM ==
B900 KL_U_ROM_ENABLE ;out: A=old C'
B903 KL_U_ROM_DISABLE ;out: A=old C'
B906 KL_L_ROM_ENABLE ;out: A=old C'
B909 KL_L_ROM_DISABLE ;out: A=old C'
B90C KL_ROM_RESTORE ;in: A=new C' (Bit2,3)
Enables/disables upper or lower ROM (manipulates the BC' register, and writes the result to the Gate Array).

== Upper ROM Bank Number ==
B90F KL_ROM_SELECT ;in: C=upper ROM bank (select, and enable that bank)
B912 KL_CURR_SELECTION ;out: A=upper ROM bank
B915 KL_PROBE_ROM ;in: C=upper ROM bank, out: A=[C000h], HL=[C001h]
B918 KL_ROM_DESELECT ;in: B=new C', C=upper ROM bank, out: B=A, C=old bank
Related to upper ROM bank number, commonly used banks are 00h=BASIC, and 07h=AMSDOS (for details, see Port DFXXh).

== Shadow RAM Read ==
0020 KL_RAM_LD_A_HL (RST4) ;in: HL=src, out: A=[HL]
B91B KL_RAM_LDIR ;in: HL=src, DE=dest, BC=len
B91E KL_RAM_LDDR ;in: HL=src_end, DE=dest_end, BC=len
Temporarily disables ROM, and executes a LD A,[HL], LDIR, or LDDR opcode.

== RAM Bank Selection (6128 only) ==
BD5B KL_RAM_SELECT_6128 ;in: A=new config, out: A=old config (6128 only)
6,388
edits