NO.1004:命令名を省略するマクロ その2
TACKが命令を作成する時はいつも長くなります
命令の衝突防止と
命令の名前を考えるのがめんどくさいので
だいたい。適当な命令名_at_モジュール名になってます
前回は命令名補完のmacroでしたが今回は命令名とオブジェクト名を
macroに代入します
FILE名:FILE_macro_shorten.hsp
以下サンプル
サンプルでは
array_exモジュール。と
array_push_popモジュール。を使用しています
サンプル その1
サンプル その2
サンプル その3
サンプル その4
命令の衝突防止と
命令の名前を考えるのがめんどくさいので
だいたい。適当な命令名_at_モジュール名になってます
前回は命令名補完のmacroでしたが今回は命令名とオブジェクト名を
macroに代入します
FILE名:FILE_macro_shorten.hsp
// 英単語の意味 // shorten // …の長さ[距離, 時間など]を短くする, 縮める, 詰める;…を短く見せる // %1をf_sタグへストック #define ctype func_stock_A(%1) %tf_s_A %s1 #define ctype func_stock_B(%1) %tf_s_B %s1 #define ctype func_stock_C(%1) %tf_s_C %s1 #define ctype func_stock_D(%1) %tf_s_D %s1 // %1をo_sタグへストック #define ctype obj_stock_A(%1) %to_s_A %s1 #define ctype obj_stock_B(%1) %to_s_B %s1 #define ctype obj_stock_C(%1) %to_s_C %s1 #define ctype obj_stock_D(%1) %to_s_D %s1 // f_sタグへストックしてたのを展開 #define ctype output_f_A %tf_s_A %p #define ctype output_f_B %tf_s_B %p #define ctype output_f_C %tf_s_C %p #define ctype output_f_D %tf_s_D %p // o_sタグへストックしてたのを展開 #define ctype output_o_A %to_s_A %p #define ctype output_o_B %to_s_B %p #define ctype output_o_C %to_s_C %p #define ctype output_o_D %to_s_D %p // 命令とオブジェクト(引数?)呼び出し #define ctype in_that_A output_f_A() output_o_A() #define ctype in_that_B output_f_B() output_o_B() #define ctype in_that_C output_f_C() output_o_C() #define ctype in_that_D output_f_D() output_o_D() // ()除去 #define that_A in_that_A() #define that_B in_that_B() #define that_C in_that_C() #define that_D in_that_D() // ストックしたのを吐き出す #define ctype that_A_f_end(%1) %tf_s_A %1%o=0 #define ctype that_B_f_end(%1) %tf_s_B %1%o=0 #define ctype that_C_f_end(%1) %tf_s_C %1%o=0 #define ctype that_D_f_end(%1) %tf_s_D %1%o=0 #define ctype that_A_o_end(%1) %to_s_A %1%o=0 #define ctype that_B_o_end(%1) %to_s_B %1%o=0 #define ctype that_C_o_end(%1) %to_s_C %1%o=0 #define ctype that_D_o_end(%1) %to_s_D %1%o=0 |
以下サンプル
サンプルでは
array_exモジュール。と
array_push_popモジュール。を使用しています
array_exモジュール
array_push_popモジュール
サンプル その1
#include "FILE_macro_shorten.hsp" #include "FILE_array_ex.hsp" #include "FILE_array_push_pop.hsp" newmod o,array_push_pop,"M" // 命令名とオブジェクト名をストックへ代入 func_stock_A(add_at_array_push_pop) obj_stock_A(o) // 省略した命令とオブジェクトを利用 repeat 32,1 that_A ,cnt loop // 命令名とオブジェクト名をストックへ代入 func_stock_B(get_add_index_at_array_push_pop) obj_stock_B(o) // 省略した命令とオブジェクトを利用 repeat 32 r=0 that_B ,r logmes "var : "+str(r) loop goto *@f // ストックしたのを吐き出す that_A_f_end(hoge) that_A_o_end(piyo) that_B_f_end(hoge) that_B_o_end(piyo) *@ logmes "" newmod o2,array_push_pop,"M" // 命令名とオブジェクト名をストックへ代入 func_stock_A(add_at_array_push_pop) obj_stock_A(o2) // 省略した命令とオブジェクトを利用 repeat 32,1 that_A ,(cnt*2) loop // 命令名とオブジェクト名をストックへ代入 func_stock_B(get_add_index_at_array_push_pop) obj_stock_B(o2) // 省略した命令とオブジェクトを利用 repeat 32 r=0 that_B ,r logmes "var : "+str(r) loop stop // ストックしたのを吐き出す that_A_f_end(hoge) that_A_o_end(piyo) that_B_f_end(hoge) that_B_o_end(piyo) |
サンプル その2
#include "FILE_macro_shorten.hsp" #include "FILE_array_ex.hsp" #include "FILE_array_push_pop.hsp" newmod o,array_push_pop,"M" // 命令名とオブジェクト名をストックへ代入 func_stock_A(add_at_array_push_pop) obj_stock_A(o) // 省略した命令とオブジェクトを利用 repeat 32,1 that_A ,cnt loop // 命令名とオブジェクト名をストックへ代入 func_stock_B(get_add_index_at_array_push_pop) obj_stock_B(o) // 省略した命令とオブジェクトを利用 repeat 32 r=0 that_B ,r logmes "var : "+str(r) loop logmes "" newmod o2,array_push_pop,"M" // 命令名とオブジェクト名をストックへ代入 func_stock_C(add_at_array_push_pop) obj_stock_C(o2) // 省略した命令とオブジェクトを利用 repeat 32,1 that_C ,(cnt*2) loop // 命令名とオブジェクト名をストックへ代入 func_stock_D(get_add_index_at_array_push_pop) obj_stock_D(o2) // 省略した命令とオブジェクトを利用 repeat 32 r=0 that_D ,r logmes "var : "+str(r) loop stop // ストックしたのを吐き出す that_A_f_end(hoge) that_A_o_end(piyo) that_B_f_end(hoge) that_B_o_end(piyo) that_C_f_end(hoge) that_C_o_end(piyo) that_D_f_end(hoge) that_D_o_end(piyo) |
サンプル その3
#include "FILE_array_ex.hsp" #include "FILE_array_push_pop.hsp" // 命令名の省略 #define add add_at_array_push_pop #define get get_add_index_at_array_push_pop newmod o,array_push_pop,"M" repeat 32,1 add o,cnt loop repeat 32 r=0 get o,r logmes "var : "+str(r) loop logmes "" newmod o2,array_push_pop,"M" repeat 32,1 add o2,(cnt*2) loop repeat 32 r=0 get o2,r logmes "var : "+str(r) loop stop |
サンプル その4
#include "FILE_macro_shorten.hsp" #include "FILE_array_ex.hsp" #include "FILE_array_push_pop.hsp" // 命令名の省略 #define add add_at_array_push_pop #define get get_add_index_at_array_push_pop newmod o,array_push_pop,"M" // 命令名とオブジェクト名をストックへ代入 func_stock_A(add) obj_stock_A(o) // 省略した命令とオブジェクトを利用 repeat 32,1 that_A ,cnt loop // 命令名とオブジェクト名をストックへ代入 func_stock_B(get) obj_stock_B(o) // 省略した命令とオブジェクトを利用 repeat 32 r=0 that_B ,r logmes "var : "+str(r) loop // ストックしたのを吐き出す goto *@f that_A_f_end(hoge) that_A_o_end(piyo) that_B_f_end(hoge) that_B_o_end(piyo) *@ logmes "" newmod o2,array_push_pop,"M" // 命令名とオブジェクト名をストックへ代入 func_stock_A(add) obj_stock_A(o2) // 省略した命令とオブジェクトを利用 repeat 32,1 that_A ,(cnt*2) loop // 命令名とオブジェクト名をストックへ代入 func_stock_B(get) obj_stock_B(o2) // 省略した命令とオブジェクトを利用 repeat 32 r=0 that_B ,r logmes "var : "+str(r) loop stop // ストックしたのを吐き出す that_A_f_end(hoge) that_A_o_end(piyo) that_B_f_end(hoge) that_B_o_end(piyo) |