アセンブリ言語を模した何か。ラベルとかはないです。
アセンブリ言語を模した何か。ラベルとかはないです。
#runtime "hsp3cl"#cmpopt varinit 1#include "user32.as"#include "Dictionary.as";Dictionary.as; http://dev.onionsoft.net/seed/info.ax?id=1558; https://github.com/yosgspec/DictionaryOnHSP#module Reg#deffunc local initnew@Dictionary regX,"int",,,{"AX: 0,BX: 0,CX: 0,DX: 0"}return#deffunc local set str a,int bif dcContainsKey(regX,a) {dcSet regX,a,breturn 0}return 1#defcfunc local get str areturn dcItem(regX,a)#globalinit@Reg#module @fun#define setfun %tfun \new@Dictionary funs,"label":\dcAdd funs,"SET",*%i: if 0{*%o: set@Reg a,int(b): return}\dcAdd funs,"CP" ,*%i: if 0{*%o: set@Reg a,get@Reg(b): return}\dcAdd funs,"OUT",*%i: if 0{*%o: mes get@Reg(a): return}\dcAdd funs,"ADD",*%i: if 0{*%o: set@Reg a,get@Reg(a)+get@Reg(b): return}\dcAdd funs,"SUB",*%i: if 0{*%o: set@Reg a,get@Reg(a)-get@Reg(b): return}\dcAdd funs,"MUL",*%i: if 0{*%o: set@Reg a,get@Reg(a)*get@Reg(b): return}\dcAdd funs,"DIV",*%i: if 0{*%o: set@Reg a,get@Reg(a)/get@Reg(b): return}\dcAdd funs,"EXIT",*%i:if 0{*%o :end: return}#deffunc local initdimtype fn,vartype("label")sdim a: sdim bsetfunreturn#deffunc fun str fnName,str _a,str _ba=_a: b=_bif 0=dcContainsKey(funs,fnName): return 1dcRefItem funs,fnName,fngosub fnreturn 0#globalinit@@fun#module#deffunc call str argssargs=argsssplit args," ",argsswitch length(args)case 1: fun args(0),"","": swbreakcase 2: fun args(0),args(1),"": swbreakcase 3: fun args(0),args(1),args(2): swbreakswendreturn stat#global#module#defcfunc spaceParser str _codecode=_codesdim codesstrrep code,"\\\"","__escWQuot__"split code,"\"",codescode=""foreach codes: s=codes.cntif 0=cnt\2 {strrep s,"\t"," "CharUpper varptr(s)while 0<=instr(s,," "): strrep s," "," ": wend}if 0<cnt: code+="\""code+=sloopstrrep code,"__escWQuot__","\\\""#const crCode $0D#const lfCode $0Asdim lf:poke lf,,lfCodestrrep code,"\n",lfstrrep code,"\r",lfsplit code,lf,codescode=""foreach codes: s=codes.cntstrrep s,"\\;","__escSemiColon__"remi=instr(s,,";")if 0<=remi: s=strmid(s,0,remi)strrep s,"__escSemiColon__","\\;"s=strtrim(s,,' ')code+=s+"\n"loopwhile 0<=instr(code,,"\n\n"): strrep code,"\n\n","\n": wendcode=strtrim(code,,crCode)code=strtrim(code,,lfCode)code=strtrim(code,,crCode)return code#global#module#deffunc mainpath=dir_cmdlinepath=strtrim(path,0,' '); ファイル実行if path!="" {sdim codeexist pathif 0<=strsize {notesel codenoteload pathnoteunselcode=spaceParser(code)sdim codessplit code,"\n",codesforeach codescall codes.cntloop}else {mes "Not exist file."mes "\""+path+"\""}}; REPLelse {repeatmes "> ",1sdim s: input s,,2call spaceParser(s)loop}return#globalmain