a21_txt02_9
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
開始行:
* 「10日くらいでできる!プログラミング言語自作入門」の続...
-(by [[K]], 2021.05.11)
** (1) HL-19
-さてなんだかんだとJITコンパイラ対応をしているうちに、あ...
-[1]sub_関数群の宣言を以下の記述と差し替え
clock_t t0;
AWindow *win;
int toExit;
void sub_print(AInt i) { printf("%d\n", ...
void sub_time() { printf("time: %...
AInt sub_aRgb8(AInt r, AInt g, AInt b) { return aRgb8(r,...
AInt sub_XorShift() { return aXorShif...
AInt sub_aGetPix(AInt x, AInt y) { return aGetPix(...
AInt sub_f16Sin(AInt x) { return (AInt) (...
AInt sub_f16Cos(AInt x) { return (AInt) (...
AInt sub_aInkey(AInt opt) { return aInkey(w...
void sub_prints(char *s) { printf("%s\n", ...
void sub_aSetPix0(AInt x, AInt y, AInt c) { aSetPix0(win...
void sub_aFilRct0(AInt xsz, AInt ysz, AInt x0, AInt y0, ...
void sub_aDrwStr0(AInt x, AInt y, AInt c, AInt b, char *...
void sub_gprDec(AInt x, AInt y, AInt w, AInt c, AInt b, ...
AInt sub_OpnWin(AInt xsz, AInt ysz, char *s)
{
if (win != 0) {
if (win->xsiz < xsz || win->ysiz < ysz) {
printf("openWin error\n");
return 1;
}
} else {
win = aOpenWin(xsz, ysz, s, 0);
}
return 0;
}
AInt sub_aWait(AInt msec)
{
if (msec == -1) {
if (win != 0) {
aFlushAll(win);
}
return 1;
}
aWait(msec);
return 0;
}
void sub_bitblt(AInt xsz, AInt ysz, AInt x0, AInt y0, AI...
{
AInt32 *p32 = &win->buf[x0 + y0 * win->xsiz];
int i, j;
for (j = 0; j < ysz; j++) {
for (i = 0; i < xsz; i++) {
p32[i] = a[i];
}
a += xsz;
p32 += win->xsiz;
}
}
void initTcSub()
{
var[TcSubPrint] = (AInt) sub_print;
var[TcSubTime] = (AInt) sub_time;
var[TcSubRgb8] = (AInt) sub_aRgb8;
var[TcSubXorShift] = (AInt) sub_XorShift;
var[TcSubGetPix] = (AInt) sub_aGetPix;
var[TcSubF16Sin] = (AInt) sub_f16Sin;
var[TcSubF16Cos] = (AInt) sub_f16Cos;
var[TcSubInkey] = (AInt) sub_aInkey;
var[TcSubPrints] = (AInt) sub_prints;
var[TcSubSetPix0] = (AInt) sub_aSetPix0;
var[TcSubFilRct0] = (AInt) sub_aFilRct0;
var[TcSubDrwStr0] = (AInt) sub_aDrwStr0;
var[TcSubGprDec] = (AInt) sub_gprDec;
var[TcSubOpnWin] = (AInt) sub_OpnWin;
var[TcSubWait] = (AInt) sub_aWait;
var[TcSubBitBlt] = (AInt) sub_bitblt;
}
-[2]exprSub1()関数の直前のプロトタイプ宣言に、以下の行を...
int phrCmpPutIcX64(int pid, String phr, int pc, int *pi,...
-[3]exprSub()関数内の記述を差し替え
! } else if (phrCmp(72, "mul64shr(!!**0, !!**1, !!**2)...
+ e0 = expr(0);
+ e1 = expr(1);
+ int e2 = expr(2);
+ i = tmpAlloc();
+ putIcX64("%R_8b_%2m1; %R_8b_%0m0; %R_0f_af_%1m0;...
+ tmpFree(e2);
+ if (e2 < 0) {
+ e0 = -1;
+ }
! } else if (phrCmpPutIcX64(73, "aRgb8(!!**0, !!**1, !...
! } else if (phrCmpPutIcX64(74, "aOpenWin(!!**0, !!**1...
+ putIcX64("%R_85_c0; 0f_85_%0l;", &var[toExit], 0...
i = Tc0;
! } else if (phrCmpPutIcX64(75, "aXorShift32()", ...
! } else if (phrCmpPutIcX64(76, "aGetPix(!!**8, !!**0,...
! } else if (phrCmpPutIcX64(77, "ff16sin(!!**0)", ...
! } else if (phrCmpPutIcX64(78, "ff16cos(!!**0)", ...
! } else if (phrCmpPutIcX64(79, "aInkey(!!***8 , !!**0...
-[4]ifgoto()関数を以下の記述と交換
int condCode[6] = { 0x84, 0x85, 0x8c, 0x8d, 0x8e, 0x8f }...
void ifgoto(int i, int not, int label)
{
int j = wpc[i];
if (j + 3 == wpc1[i] && TcEEq <= tc[j + 1] && tc[j +...
! putIcX64("%R_8b_%2m0; %R_3b_%3m0; 0f_%0c_%1l;", ...
} else {
i = expr(i);
! putIcX64("%R_8b_%2m0; %R_85_c0; 0f_%0c_%1l;", (I...
tmpFree(i);
}
}
-[5]compile()関数に1行追加(1)
tmpLabelNo = 0;
bd = lbd = 0;
+ toExit = tmpLabelAlloc();
for (pc = 0; pc < pc1; ) { // コンパイル開始.
-[6]compile()関数内の記述を差し替え(1)
} else if (phrCmp( 5, "goto !!*0;", pc)) { // g...
! putIcX64("e9_%0l;", &var[tc[wpc[0]]], 0, 0, ...
-[7]compile()関数内の記述を差し替え(2)
} else if (phrCmp(12, "} else {", pc) && binf[bd...
binf[bd + IfLabel1] = tmpLabelAlloc(); // el...
! putIcX64("e9_%0l;", &var[binf[bd + IfLabel1]...
! defLabel(binf[bd + IfLabel0]); // ラベルに対...
} else if (phrCmp( 13, "}", pc) && binf[bd] == B...
if (binf[bd + IfLabel1] == 0) {
! defLabel(binf[bd + IfLabel0]); // ラベル...
} else {
! defLabel(binf[bd + IfLabel1]); // ラベル...
}
bd -= BInfSiz;
} else if (phrCmp(14, "for (!!***0; !!***1; !!**...
bd += BInfSiz;
binf[bd] = BlkFor; // ブロックのタイプ.
binf[bd + ForLopBgn] = tmpLabelAlloc(); // ...
binf[bd + ForCont ] = tmpLabelAlloc(); // c...
binf[bd + ForBrk ] = tmpLabelAlloc(); // b...
binf[bd + ForLbd0 ] = lbd; // 古い値を保存.
binf[bd + ForWpc01 ] = wpc [1];
binf[bd + ForWpc11 ] = wpc1[1];
binf[bd + ForWpc02 ] = wpc [2];
binf[bd + ForWpc12 ] = wpc1[2];
lbd = bd;
e0 = expr(0);
if (wpc[1] < wpc1[1]) { // !!***1に何らかの...
ifgoto(1, IfFalse, binf[bd + ForBrk]); /...
}
! defLabel(binf[bd + ForLopBgn]); // ラベルに...
} else if (phrCmp(15, "}", pc) && binf[bd] == Bl...
! defLabel(binf[bd + ForCont]); // ラベルに対...
i = binf[bd + ForWpc01];
j = binf[bd + ForWpc02];
if (i + 3 == binf[bd + ForWpc11] && j + 2 ==...
// !!***1が「i < ?」かつ、!!***2が「i++...
! putIcX64("%R_8b_%1m0; %R_ff_c0; %R_89_%1...
} else {
wpc [1] = binf[bd + ForWpc01];
wpc1[1] = binf[bd + ForWpc11];
wpc [2] = binf[bd + ForWpc02];
wpc1[2] = binf[bd + ForWpc12];
e2 = expr(2);
if (wpc[1] < wpc1[1]) { // !!***1に何ら...
ifgoto(1, 0, binf[bd + ForLopBgn]);
} else {
! putIcX64("e9_%0l;", &var[binf[bd + F...
}
}
! defLabel(binf[bd + ForBrk]); // ラベルに対応...
lbd = binf[bd+ ForLbd0]; // 以前の値を復元.
bd -= BInfSiz;
} else if (phrCmp(16, "continue;", pc) && lbd > ...
! putIcX64("e9_%0l;", &var[binf[lbd + ForCont]...
} else if (phrCmp(17, "break;", pc) && lbd > 0) {
! putIcX64("e9_%0l;", &var[binf[lbd + ForBrk ]...
-[8]compile()関数内の記述を差し替え(3)
! } else if (phrCmpPutIcX64(20, "prints !!**0;", p...
-[9]compile()関数内の記述を差し替え(4)
! } else if (phrCmpPutIcX64(23, "aSetPix0(!!***8, ...
! } else if (phrCmpPutIcX64(24, "aWait(!!**0);", ...
+ putIcX64("%R_85_c0; 0f_85_%0l;", &var[toExit...
! } else if (phrCmpPutIcX64(25, "aFillRect0(!!***8...
! } else if (phrCmpPutIcX64(26, "aDrawStr0(!!***8,...
! } else if (phrCmpPutIcX64(27, "gprintDec(!!***8,...
! } else if (phrCmpPutIcX64(28, "bitblt(!!***8, !!...
! } else if (phrCmpPutIcX64(29, "printTime();", ...
-[10]compile()関数に1行追加(2)
if (bd > 0) {
printf("block nesting error (bd=%d, lbd=%d, pc=%...
return -1;
}
! defLabel(toExit);
dump1 = icq;
putIcX64("%R_81_c4_f8_01_00_00;", 0, 0, 0, 0);
putIcX64("58; 59; 5a; 5b; 5c; 5d; 5e; 5f; 41_58; 41_...
putIcX64("41_5a; 41_5b; 41_5c; 41_5d; 41_5e; 41_5f; ...
icq1 = icq;
for (i = 0; i < jp; i++) { // ジャンプ命令の最適化.
-[11]run()関数に3行追加
int run(String s)
{
if (compile(s) < 0)
return 1;
if (codedump == 0) {
void (*func)() = (void (*)()) ic;
t0 = clock();
func();
+ if (win != 0) {
+ aFlushAll(win);
+ }
} else {
int i, i1 = dump1 - dump0;
for (i = 0; i < i1; i++) {
printf("%02x ", dump0[i]);
}
printf("\n(len=%d)\n", i1);
}
return 0;
}
----
-以上すべての改造を終えると、プログラムは893行になります。
-これで[[a21_txt01_9a]]で紹介した、mandel.cやmaze.cが動く...
-特にmandel.cはすごいです。HL-9aのころと比べて3.86倍くら...
||32bit|64bit|
|gcc-O3|RIGHT:3.71秒|RIGHT:3.25秒|
|HL-9a|RIGHT:25.63秒|RIGHT:25.25秒|
|HL-13|RIGHT:7.56秒||
|HL-19||RIGHT:6.54秒|
** (2) 今回新出の機械語
|0f_80_%l ~ 0f_8f_%l|条件分岐命令。|アセンブラではJcc命令|
|%R_85_c0|RAXを0と比較。|アセンブラではTEST命令|
** (3) HL-9aとHL-19を比較してみる
-これがあれば、何が何に対応しているかわかりやすいでしょう...
単純代入:
(HL-9a) putIc (OpCpy, &var[tc[wp...
(HL-19) putIcX64("%R_8b_%1m0; %R_89_%0m0;", &var[tc[wp...
print命令:
(HL-9a) phrCmpPutIc ( 4, "print !!**0;", pc, 0, 1, O...
(HL-19) phrCmpPutIcX64( 4, "print !!**0;", pc, 0, 1, T...
+1する命令:
(HL-9a) putIc (OpAdd1, ...
(HL-19) putIcX646("%R_8b_%0m0; %R_ff_c0; %R_89_%0m0;",...
各種二項演算子:
いずれも基本形は以下の通り
(HL-9a) putIc (op, &var[tc[wpc[0]]], &var[tc[wpc[1...
(HL-19) putIcX64(op, &var[tc[wpc[0]]], &var[tc[wpc[1...
演算子 (HL-9a) (HL-19)
+ OpAdd "%R_8b_%1m0; %R_03_%2m0; %R_89_%0m0;"
- OpSub "%R_8b_%1m0; %R_2b_%2m0; %R_89_%0m0;"
* OpMul "%R_8b_%1m0; %R_0f_af_%2m0; %R_89_%0m...
/ OpDiv "%R_8b_%1m0; %R_99; %R_f7_%2m7; %R_89...
% OpMod "%R_8b_%1m0; %R_99; %R_f7_%2m7; %R_89...
& OpAnd "%R_8b_%1m0; %R_23_%2m0; %R_89_%0m0;"
>> OpShr "%R_8b_%1m0; %R_8b_%2m1; %R_d3_f8; %R...
== OpCeq "%R_8b_%1m0; %R_3b_%2m0; 0f_94_c0; 0f...
!= OpCne "%R_8b_%1m0; %R_3b_%2m0; 0f_95_c0; 0f...
< OpClt "%R_8b_%1m0; %R_3b_%2m0; 0f_9c_c0; 0f...
>= OpCge "%R_8b_%1m0; %R_3b_%2m0; 0f_9d_c0; 0f...
<= OpCle "%R_8b_%1m0; %R_3b_%2m0; 0f_9e_c0; 0f...
> OpCgt "%R_8b_%1m0; %R_3b_%2m0; 0f_9f_c0; 0f...
ループ命令:
(HL-9a) putIc (OpLop, ...
(HL-19) putIcX64("%R_8b_%1m0; %R_ff_c0; %R_89_%1m0; %R...
-(未完成)
** 次回に続く
-次回: [[a21_txt02_9a]]
*こめんと欄
#comment
終了行:
* 「10日くらいでできる!プログラミング言語自作入門」の続...
-(by [[K]], 2021.05.11)
** (1) HL-19
-さてなんだかんだとJITコンパイラ対応をしているうちに、あ...
-[1]sub_関数群の宣言を以下の記述と差し替え
clock_t t0;
AWindow *win;
int toExit;
void sub_print(AInt i) { printf("%d\n", ...
void sub_time() { printf("time: %...
AInt sub_aRgb8(AInt r, AInt g, AInt b) { return aRgb8(r,...
AInt sub_XorShift() { return aXorShif...
AInt sub_aGetPix(AInt x, AInt y) { return aGetPix(...
AInt sub_f16Sin(AInt x) { return (AInt) (...
AInt sub_f16Cos(AInt x) { return (AInt) (...
AInt sub_aInkey(AInt opt) { return aInkey(w...
void sub_prints(char *s) { printf("%s\n", ...
void sub_aSetPix0(AInt x, AInt y, AInt c) { aSetPix0(win...
void sub_aFilRct0(AInt xsz, AInt ysz, AInt x0, AInt y0, ...
void sub_aDrwStr0(AInt x, AInt y, AInt c, AInt b, char *...
void sub_gprDec(AInt x, AInt y, AInt w, AInt c, AInt b, ...
AInt sub_OpnWin(AInt xsz, AInt ysz, char *s)
{
if (win != 0) {
if (win->xsiz < xsz || win->ysiz < ysz) {
printf("openWin error\n");
return 1;
}
} else {
win = aOpenWin(xsz, ysz, s, 0);
}
return 0;
}
AInt sub_aWait(AInt msec)
{
if (msec == -1) {
if (win != 0) {
aFlushAll(win);
}
return 1;
}
aWait(msec);
return 0;
}
void sub_bitblt(AInt xsz, AInt ysz, AInt x0, AInt y0, AI...
{
AInt32 *p32 = &win->buf[x0 + y0 * win->xsiz];
int i, j;
for (j = 0; j < ysz; j++) {
for (i = 0; i < xsz; i++) {
p32[i] = a[i];
}
a += xsz;
p32 += win->xsiz;
}
}
void initTcSub()
{
var[TcSubPrint] = (AInt) sub_print;
var[TcSubTime] = (AInt) sub_time;
var[TcSubRgb8] = (AInt) sub_aRgb8;
var[TcSubXorShift] = (AInt) sub_XorShift;
var[TcSubGetPix] = (AInt) sub_aGetPix;
var[TcSubF16Sin] = (AInt) sub_f16Sin;
var[TcSubF16Cos] = (AInt) sub_f16Cos;
var[TcSubInkey] = (AInt) sub_aInkey;
var[TcSubPrints] = (AInt) sub_prints;
var[TcSubSetPix0] = (AInt) sub_aSetPix0;
var[TcSubFilRct0] = (AInt) sub_aFilRct0;
var[TcSubDrwStr0] = (AInt) sub_aDrwStr0;
var[TcSubGprDec] = (AInt) sub_gprDec;
var[TcSubOpnWin] = (AInt) sub_OpnWin;
var[TcSubWait] = (AInt) sub_aWait;
var[TcSubBitBlt] = (AInt) sub_bitblt;
}
-[2]exprSub1()関数の直前のプロトタイプ宣言に、以下の行を...
int phrCmpPutIcX64(int pid, String phr, int pc, int *pi,...
-[3]exprSub()関数内の記述を差し替え
! } else if (phrCmp(72, "mul64shr(!!**0, !!**1, !!**2)...
+ e0 = expr(0);
+ e1 = expr(1);
+ int e2 = expr(2);
+ i = tmpAlloc();
+ putIcX64("%R_8b_%2m1; %R_8b_%0m0; %R_0f_af_%1m0;...
+ tmpFree(e2);
+ if (e2 < 0) {
+ e0 = -1;
+ }
! } else if (phrCmpPutIcX64(73, "aRgb8(!!**0, !!**1, !...
! } else if (phrCmpPutIcX64(74, "aOpenWin(!!**0, !!**1...
+ putIcX64("%R_85_c0; 0f_85_%0l;", &var[toExit], 0...
i = Tc0;
! } else if (phrCmpPutIcX64(75, "aXorShift32()", ...
! } else if (phrCmpPutIcX64(76, "aGetPix(!!**8, !!**0,...
! } else if (phrCmpPutIcX64(77, "ff16sin(!!**0)", ...
! } else if (phrCmpPutIcX64(78, "ff16cos(!!**0)", ...
! } else if (phrCmpPutIcX64(79, "aInkey(!!***8 , !!**0...
-[4]ifgoto()関数を以下の記述と交換
int condCode[6] = { 0x84, 0x85, 0x8c, 0x8d, 0x8e, 0x8f }...
void ifgoto(int i, int not, int label)
{
int j = wpc[i];
if (j + 3 == wpc1[i] && TcEEq <= tc[j + 1] && tc[j +...
! putIcX64("%R_8b_%2m0; %R_3b_%3m0; 0f_%0c_%1l;", ...
} else {
i = expr(i);
! putIcX64("%R_8b_%2m0; %R_85_c0; 0f_%0c_%1l;", (I...
tmpFree(i);
}
}
-[5]compile()関数に1行追加(1)
tmpLabelNo = 0;
bd = lbd = 0;
+ toExit = tmpLabelAlloc();
for (pc = 0; pc < pc1; ) { // コンパイル開始.
-[6]compile()関数内の記述を差し替え(1)
} else if (phrCmp( 5, "goto !!*0;", pc)) { // g...
! putIcX64("e9_%0l;", &var[tc[wpc[0]]], 0, 0, ...
-[7]compile()関数内の記述を差し替え(2)
} else if (phrCmp(12, "} else {", pc) && binf[bd...
binf[bd + IfLabel1] = tmpLabelAlloc(); // el...
! putIcX64("e9_%0l;", &var[binf[bd + IfLabel1]...
! defLabel(binf[bd + IfLabel0]); // ラベルに対...
} else if (phrCmp( 13, "}", pc) && binf[bd] == B...
if (binf[bd + IfLabel1] == 0) {
! defLabel(binf[bd + IfLabel0]); // ラベル...
} else {
! defLabel(binf[bd + IfLabel1]); // ラベル...
}
bd -= BInfSiz;
} else if (phrCmp(14, "for (!!***0; !!***1; !!**...
bd += BInfSiz;
binf[bd] = BlkFor; // ブロックのタイプ.
binf[bd + ForLopBgn] = tmpLabelAlloc(); // ...
binf[bd + ForCont ] = tmpLabelAlloc(); // c...
binf[bd + ForBrk ] = tmpLabelAlloc(); // b...
binf[bd + ForLbd0 ] = lbd; // 古い値を保存.
binf[bd + ForWpc01 ] = wpc [1];
binf[bd + ForWpc11 ] = wpc1[1];
binf[bd + ForWpc02 ] = wpc [2];
binf[bd + ForWpc12 ] = wpc1[2];
lbd = bd;
e0 = expr(0);
if (wpc[1] < wpc1[1]) { // !!***1に何らかの...
ifgoto(1, IfFalse, binf[bd + ForBrk]); /...
}
! defLabel(binf[bd + ForLopBgn]); // ラベルに...
} else if (phrCmp(15, "}", pc) && binf[bd] == Bl...
! defLabel(binf[bd + ForCont]); // ラベルに対...
i = binf[bd + ForWpc01];
j = binf[bd + ForWpc02];
if (i + 3 == binf[bd + ForWpc11] && j + 2 ==...
// !!***1が「i < ?」かつ、!!***2が「i++...
! putIcX64("%R_8b_%1m0; %R_ff_c0; %R_89_%1...
} else {
wpc [1] = binf[bd + ForWpc01];
wpc1[1] = binf[bd + ForWpc11];
wpc [2] = binf[bd + ForWpc02];
wpc1[2] = binf[bd + ForWpc12];
e2 = expr(2);
if (wpc[1] < wpc1[1]) { // !!***1に何ら...
ifgoto(1, 0, binf[bd + ForLopBgn]);
} else {
! putIcX64("e9_%0l;", &var[binf[bd + F...
}
}
! defLabel(binf[bd + ForBrk]); // ラベルに対応...
lbd = binf[bd+ ForLbd0]; // 以前の値を復元.
bd -= BInfSiz;
} else if (phrCmp(16, "continue;", pc) && lbd > ...
! putIcX64("e9_%0l;", &var[binf[lbd + ForCont]...
} else if (phrCmp(17, "break;", pc) && lbd > 0) {
! putIcX64("e9_%0l;", &var[binf[lbd + ForBrk ]...
-[8]compile()関数内の記述を差し替え(3)
! } else if (phrCmpPutIcX64(20, "prints !!**0;", p...
-[9]compile()関数内の記述を差し替え(4)
! } else if (phrCmpPutIcX64(23, "aSetPix0(!!***8, ...
! } else if (phrCmpPutIcX64(24, "aWait(!!**0);", ...
+ putIcX64("%R_85_c0; 0f_85_%0l;", &var[toExit...
! } else if (phrCmpPutIcX64(25, "aFillRect0(!!***8...
! } else if (phrCmpPutIcX64(26, "aDrawStr0(!!***8,...
! } else if (phrCmpPutIcX64(27, "gprintDec(!!***8,...
! } else if (phrCmpPutIcX64(28, "bitblt(!!***8, !!...
! } else if (phrCmpPutIcX64(29, "printTime();", ...
-[10]compile()関数に1行追加(2)
if (bd > 0) {
printf("block nesting error (bd=%d, lbd=%d, pc=%...
return -1;
}
! defLabel(toExit);
dump1 = icq;
putIcX64("%R_81_c4_f8_01_00_00;", 0, 0, 0, 0);
putIcX64("58; 59; 5a; 5b; 5c; 5d; 5e; 5f; 41_58; 41_...
putIcX64("41_5a; 41_5b; 41_5c; 41_5d; 41_5e; 41_5f; ...
icq1 = icq;
for (i = 0; i < jp; i++) { // ジャンプ命令の最適化.
-[11]run()関数に3行追加
int run(String s)
{
if (compile(s) < 0)
return 1;
if (codedump == 0) {
void (*func)() = (void (*)()) ic;
t0 = clock();
func();
+ if (win != 0) {
+ aFlushAll(win);
+ }
} else {
int i, i1 = dump1 - dump0;
for (i = 0; i < i1; i++) {
printf("%02x ", dump0[i]);
}
printf("\n(len=%d)\n", i1);
}
return 0;
}
----
-以上すべての改造を終えると、プログラムは893行になります。
-これで[[a21_txt01_9a]]で紹介した、mandel.cやmaze.cが動く...
-特にmandel.cはすごいです。HL-9aのころと比べて3.86倍くら...
||32bit|64bit|
|gcc-O3|RIGHT:3.71秒|RIGHT:3.25秒|
|HL-9a|RIGHT:25.63秒|RIGHT:25.25秒|
|HL-13|RIGHT:7.56秒||
|HL-19||RIGHT:6.54秒|
** (2) 今回新出の機械語
|0f_80_%l ~ 0f_8f_%l|条件分岐命令。|アセンブラではJcc命令|
|%R_85_c0|RAXを0と比較。|アセンブラではTEST命令|
** (3) HL-9aとHL-19を比較してみる
-これがあれば、何が何に対応しているかわかりやすいでしょう...
単純代入:
(HL-9a) putIc (OpCpy, &var[tc[wp...
(HL-19) putIcX64("%R_8b_%1m0; %R_89_%0m0;", &var[tc[wp...
print命令:
(HL-9a) phrCmpPutIc ( 4, "print !!**0;", pc, 0, 1, O...
(HL-19) phrCmpPutIcX64( 4, "print !!**0;", pc, 0, 1, T...
+1する命令:
(HL-9a) putIc (OpAdd1, ...
(HL-19) putIcX646("%R_8b_%0m0; %R_ff_c0; %R_89_%0m0;",...
各種二項演算子:
いずれも基本形は以下の通り
(HL-9a) putIc (op, &var[tc[wpc[0]]], &var[tc[wpc[1...
(HL-19) putIcX64(op, &var[tc[wpc[0]]], &var[tc[wpc[1...
演算子 (HL-9a) (HL-19)
+ OpAdd "%R_8b_%1m0; %R_03_%2m0; %R_89_%0m0;"
- OpSub "%R_8b_%1m0; %R_2b_%2m0; %R_89_%0m0;"
* OpMul "%R_8b_%1m0; %R_0f_af_%2m0; %R_89_%0m...
/ OpDiv "%R_8b_%1m0; %R_99; %R_f7_%2m7; %R_89...
% OpMod "%R_8b_%1m0; %R_99; %R_f7_%2m7; %R_89...
& OpAnd "%R_8b_%1m0; %R_23_%2m0; %R_89_%0m0;"
>> OpShr "%R_8b_%1m0; %R_8b_%2m1; %R_d3_f8; %R...
== OpCeq "%R_8b_%1m0; %R_3b_%2m0; 0f_94_c0; 0f...
!= OpCne "%R_8b_%1m0; %R_3b_%2m0; 0f_95_c0; 0f...
< OpClt "%R_8b_%1m0; %R_3b_%2m0; 0f_9c_c0; 0f...
>= OpCge "%R_8b_%1m0; %R_3b_%2m0; 0f_9d_c0; 0f...
<= OpCle "%R_8b_%1m0; %R_3b_%2m0; 0f_9e_c0; 0f...
> OpCgt "%R_8b_%1m0; %R_3b_%2m0; 0f_9f_c0; 0f...
ループ命令:
(HL-9a) putIc (OpLop, ...
(HL-19) putIcX64("%R_8b_%1m0; %R_ff_c0; %R_89_%1m0; %R...
-(未完成)
** 次回に続く
-次回: [[a21_txt02_9a]]
*こめんと欄
#comment
ページ名: