例題:加算用アセンブリプログラム
.proc pr1, 0x0000 .text 0x000 ld TOP mv ixr,acc in st ixr,0 in st ixr,1 ld ixr,0 add ixr,1 st ixr,2 halt .data WORK: .word 0 .word 0 .word 0 .const TOP: .word WORK .pend
%kite2asm sample2
Process_name pr1 segment : 00000000 Text segment : 00000000 Data segment : 00000400 BSS segment : 00000600 Const segment : 00000700 Input file : sample2.asm Output file : sample2.hex Segment file : sample2.seg PRG : pr1 #TEXT BASE : 0 #TEXT SIZE : 1 #DATA BASE : 400 #DATA SIZE : 1 #STACK BASE : 600 #STACK SIZE : 0 ramsize = 65536
%cat sample2.hex
:100000000700F008C800C600C800C601C20082018F :10001000C602F800FFFFFFFFFFFFFFFFFFFFFFFF2C :10080000000000000000FFFFFFFFFFFFFFFFFFFFF2 :100E00000400FFFFFFFFFFFFFFFFFFFFFFFFFFFFEC :00000001FF
%
%kite2sim -d sample2
%kite2simkite2sim を実行すると,以下のようなメッセージが出力された後,サブコ マンドの入力待ち状態となります.オブジェクト・ファイルを指定 し'-d'オプション付きで立ち上げた場合は,KITE マイクロプロセッサの メモリ空間にオブジェクトファイルをロードした状態になります.
KITE Simulator v1.05, Copyright (C) 1992-95 KITE microprocessor project KITE Simulator comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions; show `copying' file for details. Debug mode. [ ? for help ] No execute program. ---- acc=0000 ixr=000 ssp=000 out=0000 pc=000 0000 ld 0x000 >・`>'はkite2sim のプロンプトです.これに引続きkite2sim のサブコ マンドを入力します.
> r sample2 Ok. > u 0 000 0700 ld 0x700 001 F008 mv ixr, acc 002 C800 in 0x00 003 C600 st ixr, 0x00 004 C800 in 0x00 005 C601 st ixr, 0x01 006 C200 ld ixr, 0x00 007 8201 add ixr, 0x01 008 C602 st ixr, 0x02 009 F800 halt 00A FFFF undefined 00B FFFF undefined 00C FFFF undefined 00D FFFF undefined 00E FFFF undefined 00F FFFF undefined > u 010 0000 ld 0x000 011 0000 ld 0x000 012 0000 ld 0x000 013 0000 ld 0x000 014 0000 ld 0x000 015 0000 ld 0x000 016 0000 ld 0x000 017 0000 ld 0x000 018 0000 ld 0x000 019 0000 ld 0x000 01A 0000 ld 0x000 01B 0000 ld 0x000 01C 0000 ld 0x000 01D 0000 ld 0x000 01E 0000 ld 0x000 01F 0000 ld 0x000 > d 0 000|0700 F008 C800 C600 C800 C601 C200 8201 ................ 008|C602 F800 FFFF FFFF FFFF FFFF FFFF FFFF ................ 010|0000 0000 0000 0000 0000 0000 0000 0000 ................ 018|0000 0000 0000 0000 0000 0000 0000 0000 ................ 020|0000 0000 0000 0000 0000 0000 0000 0000 ................ 028|0000 0000 0000 0000 0000 0000 0000 0000 ................ 030|0000 0000 0000 0000 0000 0000 0000 0000 ................ 038|0000 0000 0000 0000 0000 0000 0000 0000 ................ 040|0000 0000 0000 0000 0000 0000 0000 0000 ................ 048|0000 0000 0000 0000 0000 0000 0000 0000 ................ 050|0000 0000 0000 0000 0000 0000 0000 0000 ................ 058|0000 0000 0000 0000 0000 0000 0000 0000 ................ 060|0000 0000 0000 0000 0000 0000 0000 0000 ................ 068|0000 0000 0000 0000 0000 0000 0000 0000 ................ 070|0000 0000 0000 0000 0000 0000 0000 0000 ................ 078|0000 0000 0000 0000 0000 0000 0000 0000 ................ > t 100 ---- acc=0400 ixr=000 sp=000 out=0000 pc=001 f008 mv ixr, acc ---- acc=0400 ixr=400 sp=000 out=0000 pc=002 c800 in 0x00 in = 3 ---- acc=0003 ixr=400 sp=000 out=0000 pc=003 c600 st ixr, 0x00 ---- acc=0003 ixr=400 sp=000 out=0000 pc=004 c800 in 0x00 in = 5 ---- acc=0005 ixr=400 sp=000 out=0000 pc=005 c601 st ixr, 0x01 ---- acc=0005 ixr=400 sp=000 out=0000 pc=006 c200 ld ixr, 0x00 ---- acc=0003 ixr=400 sp=000 out=0000 pc=007 8201 add ixr, 0x01 ---- acc=0008 ixr=400 sp=000 out=0000 pc=008 c602 st ixr, 0x02 ---- acc=0008 ixr=400 sp=000 out=0000 pc=009 f800 halt Program terminated > d 700 700|0400 FFFF FFFF FFFF FFFF FFFF FFFF FFFF ................ 708|0000 0000 0000 0000 0000 0000 0000 0000 ................ 710|0000 0000 0000 0000 0000 0000 0000 0000 ................ 718|0000 0000 0000 0000 0000 0000 0000 0000 ................ 720|0000 0000 0000 0000 0000 0000 0000 0000 ................ 728|0000 0000 0000 0000 0000 0000 0000 0000 ................ 730|0000 0000 0000 0000 0000 0000 0000 0000 ................ 738|0000 0000 0000 0000 0000 0000 0000 0000 ................ 740|0000 0000 0000 0000 0000 0000 0000 0000 ................ 748|0000 0000 0000 0000 0000 0000 0000 0000 ................ 750|0000 0000 0000 0000 0000 0000 0000 0000 ................ 758|0000 0000 0000 0000 0000 0000 0000 0000 ................ 760|0000 0000 0000 0000 0000 0000 0000 0000 ................ 768|0000 0000 0000 0000 0000 0000 0000 0000 ................ 770|0000 0000 0000 0000 0000 0000 0000 0000 ................ 778|0000 0000 0000 0000 0000 0000 0000 0000 ................ > d 400 400|0003 0005 0008 FFFF FFFF FFFF FFFF FFFF ................ 408|0000 0000 0000 0000 0000 0000 0000 0000 ................ 410|0000 0000 0000 0000 0000 0000 0000 0000 ................ 418|0000 0000 0000 0000 0000 0000 0000 0000 ................ 420|0000 0000 0000 0000 0000 0000 0000 0000 ................ 428|0000 0000 0000 0000 0000 0000 0000 0000 ................ 430|0000 0000 0000 0000 0000 0000 0000 0000 ................ 438|0000 0000 0000 0000 0000 0000 0000 0000 ................ 440|0000 0000 0000 0000 0000 0000 0000 0000 ................ 448|0000 0000 0000 0000 0000 0000 0000 0000 ................ 450|0000 0000 0000 0000 0000 0000 0000 0000 ................ 458|0000 0000 0000 0000 0000 0000 0000 0000 ................ 460|0000 0000 0000 0000 0000 0000 0000 0000 ................ 468|0000 0000 0000 0000 0000 0000 0000 0000 ................ 470|0000 0000 0000 0000 0000 0000 0000 0000 ................ 478|0000 0000 0000 0000 0000 0000 0000 0000 ................ > q・ここで実行は修了しました.ここで気をつけて見て欲しい箇所は,メモリ アドレスの[400h]番地から[402h]番地の値です.
[400h] = [0003h] : 加数 [401h] = [0005h] : 被加数 [402h] = [0008h] : 計算結果途中で入力した値(加数,被加数)もきちんとセットされていますし,実行を 終了した段階で,結果も[402h]番地に格納されています.つまり.計算が確 実に行なわれたことが示されています.
.proc pr1, 0x0000 .text 0x000 ld BASE mv ixr,acc in and ixr,0 jpz EVEN jp ODD EVEN: ld EVDA jp OUTPUT ODD: ld ODDA OUTPUT: out st ANSWER FINISH: halt .data MASK: .word 0x0001 EVDA: .word 0x0000 ODDA: .word 0xFFFF ANSWER: .word 0 BASE: .word MASK .pend
%kite2asm sample3
Process_name pr1 segment : 00000000 Text segment : 00000000 Data segment : 00000400 BSS segment : 00000600 Const segment : 00000700 Input file : sample3.asm Output file : sample3.hex Segment file : sample3.seg PRG : pr1 #TEXT BASE : 0 #TEXT SIZE : 1 #DATA BASE : 400 #DATA SIZE : 1 #STACK BASE : 600 #STACK SIZE : 0 ramsize = 65536
%cat sample3.hex
:100000000404F008C8009A005006300804013009C2 :100010000402CC001403F800FFFFFFFFFFFFFFFF07 :1008000000010000FFFF00000400FFFFFFFFFFFFEB :00000001FF
%
This is my e-mail address: