GBDKライブラリドキュメント
GBDK libraries documentation |
||
---|---|---|
前
Prev |
3章
ハードウェアへのアクセス
Chapter 3.Accessing hardware |
次
Next |
GBは、バンクスイッチング方法の使用により1.5mb以内とRAMの32kb以内のROMをサポートします。
ROMのバンク0は、領域に常に0000h位置します-3FFFh、また交換できない、しかし、他のバンクも7FFFhに4000hの間の高いROM領域へ交換できます。
不運にも、部分的には水平なアドレス空間を仮定するlccによるGBDKはちょうど今32kbより大きなプログラムをサポートしません。
しかしながら、switch_rom_bankとswitch_ram_bankの関数(UBYTE)を使用して、手動で他方のバンクにアクセスできます。
例に関しては、banks.cを参照してください。
The GB supports ROMS of up to 1.5MB and up to 32kB of RAM by using a bank switching method.Bank 0 of the ROM is always located in the region 0000h - 3FFFh and cannot be swapped but any other bank can be swapped into the high ROM region between 4000h to 7FFFh.Unfortunately GBDK doesn't support programs bigger than 32kB at the moment which is partly due to lcc assuming a flat address space.However you can manually access the other banks using the switch_rom_bank(UBYTE) and switch_ram_bank functions.See banks.c for an example.
コードが存在したほうがよいROMとRAMバンクは指定されます、xが1と31の間のバンク番号である場合-Wf-ボックスと-Wf-baxコンパイラオプションを使用して、時間をコンパイルします。
あなたが1冊のコードファイル内のスイッチバンクを信心ぶった物言いをするが多数のファイルが同じバンクで存在できることをこれが意味することに注意してください。
どちらの-浮浪者や-めえオプションもそのとき与えられなければ、デフォルト_CODEと_BSSセグメントは使用されています。
Dont、ローカルの変数が_BSSの内部のスタックに割り付けられると怠る。
The ROM and RAM bank that the code should exist in is specified at compile time using the -Wf-box and -Wf-bax compiler options where x is the bank number between 1 and 31.Note that this means that you cant switch banks within one code file but multiple files can exist in the same bank.If neither the -bo or -ba options are given then the default _CODE and _BSS segments are used.Dont forget that local variables are allocated on the stack inside _BSS.
例えば、コードを推測します:
For example, suppose the code:
int silly_fun( int a ) { printf("%i times %i is ", a, a, a*a+1 ); return 0; }そのとき-Wf-bo1コンパイラオプションでコンパイルされた、コードはセグメント_CODE_1に格納されます。 使用するメインルーチンからこの関数を呼ぶこと:
int main(void) { switch_rom_bank( 1 ); /* Select bank 1 with segment _CODE_1 */ silly_fun(5); /* Prints "5 times 5 is 26" */ return 0; }そうでなければ、あなた自身を切り替えるとともに、switch_rom_bankをobviousallyにもたらすことができないノートは内部から任意のセグメントだが_CODEを呼びます。 さらにprintfのようにバンク0から制限のある16k以内にグローバルルーチンがすべて適合しなければならないことに注意してください。
オブジェクトファイルをすべてともにリンクする場合、使用されるバンクの数は、-Wlyoxと-Wlyaxフラグ、と-Wlytxフラグを備えたMCBタイプで指定されたほうがよい。
-Wlytxの中のxに対する電流にサポートされた値は次のとおりです:
When linking all the object files together the number of banks used should be specified with the -Wl-yox and -Wl-yax flags and the MCB type with the -Wl-ytx flag.The current supported values for x in -Wl-ytx are:
0 : ROM ONLY 1 : ROM+MBC1 2 : ROM+MBC1+RAM 3 : ROM+MBC1+RAM+BATTERY 5 : ROM+MBC2 6 : ROM+MBC2+BATTERY
前
Prev |
ホーム
Home |
次
Next |
割り込み
Interrupts |
上
Up |
RAMの中の関数
Functions in RAM |