MIPS架构下的MCU,指令集包含R-Type、I-Type、J-Type三种,在数电课程设计时为了给MCU编写指令集,需要将汇编语言转化成机器代码,这里分享一下自己写的Matlab 的 GUI。

主函数 C2M

  1. function varargout = C2M(varargin)
  2. val = zeros(,);
  3.  
  4. % C2M MATLAB code for C2M.fig
  5. % C2M, by itself, creates a new C2M or raises the existing
  6. % singleton*.
  7. %
  8. % H = C2M returns the handle to a new C2M or the handle to
  9. % the existing singleton*.
  10. %
  11. % C2M('CALLBACK',hObject,eventData,handles,...) calls the local
  12. % function named CALLBACK in C2M.M with the given input arguments.
  13. %
  14. % C2M('Property','Value',...) creates a new C2M or raises the
  15. % existing singleton*. Starting from the left, property value pairs are
  16. % applied to the GUI before C2M_OpeningFcn gets called. An
  17. % unrecognized property name or invalid value makes property application
  18. % stop. All inputs are passed to C2M_OpeningFcn via varargin.
  19. %
  20. % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
  21. % instance to run (singleton)".
  22. %
  23. % See also: GUIDE, GUIDATA, GUIHANDLES
  24.  
  25. % Edit the above text to modify the response to help C2M
  26.  
  27. % Last Modified by GUIDE v2. -Jun- ::
  28.  
  29. % Begin initialization code - DO NOT EDIT
  30. gui_Singleton = ;
  31. gui_State = struct('gui_Name', mfilename, ...
  32. 'gui_Singleton', gui_Singleton, ...
  33. 'gui_OpeningFcn', @C2M_OpeningFcn, ...
  34. 'gui_OutputFcn', @C2M_OutputFcn, ...
  35. 'gui_LayoutFcn', [] , ...
  36. 'gui_Callback', []);
  37. if nargin && ischar(varargin{})
  38. gui_State.gui_Callback = str2func(varargin{});
  39. end
  40.  
  41. if nargout
  42. [varargout{:nargout}] = gui_mainfcn(gui_State, varargin{:});
  43. else
  44. gui_mainfcn(gui_State, varargin{:});
  45. end
  46. % End initialization code - DO NOT EDIT
  47.  
  48. % --- Executes just before C2M is made visible.
  49. function C2M_OpeningFcn(hObject, eventdata, handles, varargin)
  50. % This function has no output args, see OutputFcn.
  51. % hObject handle to figure
  52. % eventdata reserved - to be defined in a future version of MATLAB
  53. % handles structure with handles and user data (see GUIDATA)
  54. % varargin command line arguments to C2M (see VARARGIN)
  55.  
  56. % Choose default command line output for C2M
  57. handles.output = hObject;
  58.  
  59. % Update handles structure
  60. guidata(hObject, handles);
  61.  
  62. % UIWAIT makes C2M wait for user response (see UIRESUME)
  63. % uiwait(handles.figure1);
  64.  
  65. % --- Outputs from this function are returned to the command line.
  66. function varargout = C2M_OutputFcn(hObject, eventdata, handles)
  67. % varargout cell array for returning output args (see VARARGOUT);
  68. % hObject handle to figure
  69. % eventdata reserved - to be defined in a future version of MATLAB
  70. % handles structure with handles and user data (see GUIDATA)
  71.  
  72. % Get default command line output from handles structure
  73. varargout{} = handles.output;
  74.  
  75. function edit1_Callback(hObject, eventdata, handles)
  76. % hObject handle to edit1 (see GCBO)
  77. % eventdata reserved - to be defined in a future version of MATLAB
  78. % handles structure with handles and user data (see GUIDATA)
  79.  
  80. % Hints: get(hObject,'String') returns contents of edit1 as text
  81. % str2double(get(hObject,'String')) returns contents of edit1 as a double
  82.  
  83. % --- Executes during object creation, after setting all properties.
  84. function edit1_CreateFcn(hObject, eventdata, handles)
  85. % hObject handle to edit1 (see GCBO)
  86. % eventdata reserved - to be defined in a future version of MATLAB
  87. % handles empty - handles not created until after all CreateFcns called
  88.  
  89. % Hint: edit controls usually have a white background on Windows.
  90. % See ISPC and COMPUTER.
  91. if ispc && isequal(get(hObject,'BackgroundColor'), get(,'defaultUicontrolBackgroundColor'))
  92. set(hObject,'BackgroundColor','white');
  93. end
  94.  
  95. function edit2_Callback(hObject, eventdata, handles)
  96. % hObject handle to edit2 (see GCBO)
  97. % eventdata reserved - to be defined in a future version of MATLAB
  98. % handles structure with handles and user data (see GUIDATA)
  99.  
  100. % Hints: get(hObject,'String') returns contents of edit2 as text
  101. % str2double(get(hObject,'String')) returns contents of edit2 as a double
  102.  
  103. % --- Executes during object creation, after setting all properties.
  104. function edit2_CreateFcn(hObject, eventdata, handles)
  105. % hObject handle to edit2 (see GCBO)
  106. % eventdata reserved - to be defined in a future version of MATLAB
  107. % handles empty - handles not created until after all CreateFcns called
  108.  
  109. % Hint: edit controls usually have a white background on Windows.
  110. % See ISPC and COMPUTER.
  111. if ispc && isequal(get(hObject,'BackgroundColor'), get(,'defaultUicontrolBackgroundColor'))
  112. set(hObject,'BackgroundColor','white');
  113. end
  114.  
  115. % --- Executes on button press in pushbutton1.
  116. function pushbutton1_Callback(hObject, eventdata, handles)
  117. global val
  118. % hObject handle to pushbutton1 (see GCBO)
  119. % eventdata reserved - to be defined in a future version of MATLAB
  120. % handles structure with handles and user data (see GUIDATA)
  121.  
  122. str1 = get(handles.edit2, 'String'); %??????
  123.  
  124. x = size(str1, ); %????????
  125. y = size(str1, ); %????????
  126. %b = zeros(y, x); %b??????????????????
  127.  
  128. for i = : y
  129.  
  130. opcode1 = str1(i,);
  131. opcode2 = strcat(str1(i,), str1(i,));
  132. opcode3 = strcat(str1(i,), str1(i,), str1(i,));
  133. opcode4 = strcat(str1(i,), str1(i,), str1(i,), str1(i,));
  134. rd = strcat(str1(i, ), str1(i, ));
  135. rs = strcat(str1(i,), str1(i,));
  136. rt = strcat(str1(i,), str1(i,));
  137.  
  138. if (x >= )
  139. imm_sh = strcat(str1(i,), str1(i,), str1(i,), str1(i, ), str1(i, ));
  140. end
  141. rt4 = strcat(str1(i,), str1(i,));
  142. rs4 = strcat(str1(i,), str1(i,));
  143. if (x >= ) imm4 = strcat(str1(i,), str1(i,), str1(i, ), str1(i, ), str1(i, ));
  144. end
  145.  
  146. rd2 = strcat(str1(i, ), str1(i, ));
  147. rs2 = strcat(str1(i,), str1(i,));
  148. rt2 = strcat(str1(i,), str1(i,));
  149. rt_w = strcat(str1(i, ), str1(i, ));
  150. imm_w = strcat(str1(i, ), str1(i, ), str1(i, ), str1(i, ), str1(i, ));
  151. rs_w = strcat(str1(i, ), str1(i, ));
  152.  
  153. switch opcode4
  154. case 'addi'
  155. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  156. b(i, :) = rig_f(rs4); b(i, :) = rig_f(rt4);
  157. b(i, :) = rig_n(imm4);
  158. bq(i,:) = 'this is adi';
  159. %bqq(i,:) = strcat('this is addi ', rs4 , '-', rt4 , '-',imm4);
  160. otherwise
  161. switch opcode3
  162. case 'add'
  163. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  164. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  165. b(i, :) = rig_f(rs); b(i, :) = rig_f(rt); b(i, :) = rig_f(rd); b(i, :) = ;
  166. bq(i,:) = 'this is add';
  167. %bqq(i,:) = strcat('this is add, ', rs , '-', rt , '-',rd);
  168. case 'sub'
  169. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  170. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  171. b(i, :) = rig_f(rs); b(i, :) = rig_f(rt); b(i, :) = rig_f(rd); b(i, :) = ;
  172. bq(i,:) = 'this is sub';bqq(i,:) = strcat('this is sub, ', rs , '-', rt , '-',rd);
  173. case 'and'
  174. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  175. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  176. b(i, :) = rig_f(rs); b(i, :) = rig_f(rt); b(i, :) = rig_f(rd); b(i, :) = ;
  177. bq(i,:) = 'this is and';bqq(i,:) = strcat('this is and, ', rs , '-', rt , '-',rd);
  178. case 'slt'
  179. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  180. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  181. b(i, :) = rig_f(rs); b(i, :) = rig_f(rt); b(i, :) = rig_f(rd); b(i, :) = ;
  182. bq(i,:) = 'this is slt';bqq(i,:) = strcat('this is slt, ', rs , '-', rt , '-',rd);
  183. case 'sll'
  184. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  185. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  186. b(i, :) = ; b(i, :) = rig_f(rs); b(i, :) = rig_f(rd); b(i, :) = rig_sh(imm_sh);
  187. bq(i,:) = 'this is sll';
  188. % bqq(i,:) = strcat('this is sll, ', rs , '-', rd , '-',imm_sh);
  189. case 'srl'
  190. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  191. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  192. b(i, :) = ; b(i, :) = rig_f(rs); b(i, :) = rig_f(rd); b(i, :) = rig_sh(imm_sh);
  193. bq(i,:) = 'this is srl';
  194. % bqq(i,:) = strcat('this is srl, ', rs , '-', rd , '-',imm_sh);
  195. case 'sra'
  196. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  197. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  198. b(i, :) = ; b(i, :) = rig_f(rs); b(i, :) = rig_f(rd); b(i, :) = rig_sh(imm_sh);
  199. bq(i,:) = 'this is sra';
  200. case 'beq'
  201. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  202. b(i, :) = rig_f(rd); b(i, :) = rig_f(rs); b(i, :) = rig_n(imm_sh);
  203. bq(i,:) = 'this is beq';
  204. %bqq(i,:) = strcat('this is beq, ', rd , '-', rs , '-',imm_sh);
  205. case 'bne'
  206. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  207. b(i, :) = rig_f(rd); b(i, :) = rig_f(rs); b(i, :) = rig_n(imm_sh);
  208. bq(i,:) = 'this is bne';
  209. %bqq(i,:) = strcat('this is bne, ', rd , '-', rs , '-',imm_sh);
  210. case 'mul'
  211. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  212. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  213. b(i, :) = rig_f(rs); b(i, :) = rig_f(rt); b(i, :) = rig_f(rd); b(i, :) = ;
  214. bq(i,:) = 'this is mul';bqq(i,:) = strcat('this is mul, ', rs , '-', rt , '-',rd);
  215. case 'muf'
  216. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  217. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  218. b(i, :) = rig_f(rs); b(i, :) = rig_f(rt); b(i, :) = rig_f(rd); b(i, :) = ;
  219. bq(i,:) = 'this is mul';bqq(i,:) = strcat('this is mul, ', rs , '-', rt , '-',rd);
  220. otherwise
  221. switch opcode1
  222. case 'j'
  223. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  224. b(i, :) = ;
  225. bq(i,:) = 'this is jrr';bqq(i,:) = strcat('this is j ', '');
  226. otherwise
  227. end
  228. end
  229. end
  230.  
  231. switch opcode2
  232. case 'or'
  233. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  234. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  235. b(i, :) = rig_f(rs2); b(i, :) = rig_f(rt2); b(i, :) = rig_f(rd2); b(i, :) = ;
  236. bq(i,:) = 'this is orr';
  237.  
  238. case 'lw'
  239. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  240. b(i, :) = rig_f(rs_w);b(i, :) = rig_f(rt_w); b(i, :) = rig_n(imm_w);
  241.  
  242. % bqq(i,:) = strcat('this is lwr, ', rs_w, '-', rt_w, '-',imm_w);
  243. bq(i,:) = 'this is lwr';
  244.  
  245. case 'sw'
  246. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  247. b(i, :) = rig_f(rs_w);b(i, :) = rig_f(rt_w); b(i, :) = rig_n(imm_w);
  248. bq(i,:) = 'this is swr';
  249. otherwise
  250. end
  251.  
  252. end
  253.  
  254. bb = num2str(b);
  255. set(handles.edit1, 'String', bb);
  256. set(handles.edit3, 'String', bq);
  257. val = b;
  258.  
  259. % --- Executes on button press in pushbutton2.
  260. function pushbutton2_Callback(hObject, eventdata, handles)
  261. global val
  262. % hObject handle to pushbutton2 (see GCBO)
  263. % eventdata reserved - to be defined in a future version of MATLAB
  264. % handles structure with handles and user data (see GUIDATA)
  265. dlmwrite('C:\Users\ALIENWARE\Desktop\fft_test.txt', val, 'delimiter', '', 'precision', , 'newline','pc');
  266.  
  267. function edit3_Callback(hObject, eventdata, handles)
  268. % hObject handle to edit3 (see GCBO)
  269. % eventdata reserved - to be defined in a future version of MATLAB
  270. % handles structure with handles and user data (see GUIDATA)
  271.  
  272. % Hints: get(hObject,'String') returns contents of edit3 as text
  273. % str2double(get(hObject,'String')) returns contents of edit3 as a double
  274.  
  275. % --- Executes during object creation, after setting all properties.
  276. function edit3_CreateFcn(hObject, eventdata, handles)
  277. % hObject handle to edit3 (see GCBO)
  278. % eventdata reserved - to be defined in a future version of MATLAB
  279. % handles empty - handles not created until after all CreateFcns called
  280.  
  281. % Hint: edit controls usually have a white background on Windows.
  282. % See ISPC and COMPUTER.
  283. if ispc && isequal(get(hObject,'BackgroundColor'), get(,'defaultUicontrolBackgroundColor'))
  284. set(hObject,'BackgroundColor','white');
  285. end
  286.  
  287. % --- Executes on button press in pushbutton3.
  288. function pushbutton3_Callback(hObject, eventdata, handles)
  289. % hObject handle to pushbutton3 (see GCBO)
  290. % eventdata reserved - to be defined in a future version of MATLAB
  291. % handles structure with handles and user data (see GUIDATA)
  292. close(gcf);

函数rig_f 用来寻找名称对应的寄存器地址

  1. function [q] = rig_f(a)
  2. switch a
  3. case '0_'
  4. q()=;q()=;q()=;q()=;q()=;
  5. case 'at'
  6. q()=;q()=;q()=;q()=;q()=;
  7. case 'v0'
  8. q()=;q()=;q()=;q()=;q()=;
  9. case 'v1'
  10. q()=;q()=;q()=;q()=;q()=;
  11. case 'a0'
  12. q()=;q()=;q()=;q()=;q()=;
  13. case 'a1'
  14. q()=;q()=;q()=;q()=;q()=;
  15. case 'a2'
  16. q()=;q()=;q()=;q()=;q()=;
  17. case 'a3'
  18. q()=;q()=;q()=;q()=;q()=;
  19. case 't0'
  20. q()=;q()=;q()=;q()=;q()=;
  21. case 't1'
  22. q()=;q()=;q()=;q()=;q()=;
  23. case 't2'
  24. q()=;q()=;q()=;q()=;q()=;
  25. case 't3'
  26. q()=;q()=;q()=;q()=;q()=;
  27. case 't4'
  28. q()=;q()=;q()=;q()=;q()=;
  29. case 't5'
  30. q()=;q()=;q()=;q()=;q()=;
  31. case 't6'
  32. q()=;q()=;q()=;q()=;q()=;
  33. case 't7'
  34. q()=;q()=;q()=;q()=;q()=;
  35. case 's0'
  36. q()=;q()=;q()=;q()=;q()=;
  37. case 's1'
  38. q()=;q()=;q()=;q()=;q()=;
  39. case 's2'
  40. q()=;q()=;q()=;q()=;q()=;
  41. case 's3'
  42. q()=;q()=;q()=;q()=;q()=;
  43. case 's4'
  44. q()=;q()=;q()=;q()=;q()=;
  45. case 's5'
  46. q()=;q()=;q()=;q()=;q()=;
  47. case 's6'
  48. q()=;q()=;q()=;q()=;q()=;
  49. case 's7'
  50. q()=;q()=;q()=;q()=;q()=;
  51. case 't8'
  52. q()=;q()=;q()=;q()=;q()=;
  53. case 't9'
  54. q()=;q()=;q()=;q()=;q()=;
  55. case 'k0'
  56. q()=;q()=;q()=;q()=;q()=;
  57. case 'k1'
  58. q()=;q()=;q()=;q()=;q()=;
  59. case 'gp'
  60. q()=;q()=;q()=;q()=;q()=;
  61. case 'sp'
  62. q()=;q()=;q()=;q()=;q()=;
  63. case 'fp'
  64. q()=;q()=;q()=;q()=;q()=;
  65. case 'ra'
  66. q()=;q()=;q()=;q()=;q()=;
  67. otherwise
  68. q()=;q()=;q()=;q()=;q()=;
  69. end

函数rig_n 用来将5位十进制数转换成16位2进制小数输出

  1. function [u] = rig_n(a)
  2.  
  3. if (a() == '-')
  4. nu = str2num(a(:));
  5. num = ^ - nu;
  6. q = dec2bin(num, );
  7. else
  8. if (a() == '' | a() == '' | a() == '' | a() == '' | a() == '' | a() == '')
  9. nu = str2num(a);
  10. q = dec2bin(nu,);
  11. end
  12. end
  13.  
  14. for i = :
  15. u(i) = str2num(q(i));
  16. end

函数rig_sh 用来将3位十进制数转换成5位2进制小数输出

  1. function [u] = rig_sh(a)
  2. num = str2num(a);
  3. q = dec2bin(num, );
  4.  
  5. for i = :
  6. u(i) = str2num(q(i))
  7. end

最后欣赏一下炫酷的界面

以及附带的read me 和最终打包的Matlab程序~~

  1. *** 修正了lwsw指令
  2. *** 打开C2M.m文件运行程序
  3. *** 立即数变成5位,lwswaddi等指令的数字都变成了5
  4.  
  5. 支持指令名称:
  6. add\sub\and\slt\sll\srl\beq\bne\mul\addi\or\lw\sw
  7.  
  8. 标准形式:
  9. add $s1, $s2, $s0
  10. sub $s1, $s2, $s0
  11. and $s1, $s2, $s0
  12. slt $s1, $s2, $s0
  13. sll $s1, $s2,
  14. srl $s1, $s2,
  15. beq $s1, $s2,
  16. bne $s1, $s2,
  17. mul $s1, $s2, $s3
  18. or $s1, $s2, $s3
  19. lw $s1, ($s2)
  20. sw $s1, ($s2)
  21. addi $s1, $s2, -
  22.  
  23. 每一个命令之后加一个tab,地址前加$,逗号之后有空格,立即数的输入为3位,如5写成005,负数-5写成-
  24. 寄存器文件按照书上标准,其中$0写法为$0_
  25.  
  26. 创建txt文件:
  27. 地址为:line266
  28. C:\Users\ALIENWARE\Desktop\test_.txt (需要改成你自己的地址)
  29.  
  30. *不包含 j 指令

Read_me

  1. function varargout = C2M_export(varargin)
  2. val = zeros(,);
  3.  
  4. % C2M_export MATLAB code for C2M_export.fig
  5. % C2M_export, by itself, creates a new C2M_export or raises the existing
  6. % singleton*.
  7. %
  8. % H = C2M_export returns the handle to a new C2M_export or the handle to
  9. % the existing singleton*.
  10. %
  11. % C2M_export('CALLBACK',hObject,eventData,handles,...) calls the local
  12. % function named CALLBACK in C2M_export.M with the given input arguments.
  13. %
  14. % C2M_export('Property','Value',...) creates a new C2M_export or raises the
  15. % existing singleton*. Starting from the left, property value pairs are
  16. % applied to the GUI before C2M_export_OpeningFcn gets called. An
  17. % unrecognized property name or invalid value makes property application
  18. % stop. All inputs are passed to C2M_export_OpeningFcn via varargin.
  19. %
  20. % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
  21. % instance to run (singleton)".
  22. %
  23. % See also: GUIDE, GUIDATA, GUIHANDLES
  24.  
  25. % Edit the above text to modify the response to help C2M_export
  26.  
  27. % Last Modified by GUIDE v2. -Jul- ::
  28.  
  29. % Begin initialization code - DO NOT EDIT
  30. gui_Singleton = ;
  31. gui_State = struct('gui_Name', mfilename, ...
  32. 'gui_Singleton', gui_Singleton, ...
  33. 'gui_OpeningFcn', @C2M_export_OpeningFcn, ...
  34. 'gui_OutputFcn', @C2M_export_OutputFcn, ...
  35. 'gui_LayoutFcn', @C2M_export_LayoutFcn, ...
  36. 'gui_Callback', []);
  37. if nargin && ischar(varargin{})
  38. gui_State.gui_Callback = str2func(varargin{});
  39. end
  40.  
  41. if nargout
  42. [varargout{:nargout}] = gui_mainfcn(gui_State, varargin{:});
  43. else
  44. gui_mainfcn(gui_State, varargin{:});
  45. end
  46. % End initialization code - DO NOT EDIT
  47.  
  48. % --- Executes just before C2M_export is made visible.
  49. function C2M_export_OpeningFcn(hObject, eventdata, handles, varargin)
  50. % This function has no output args, see OutputFcn.
  51. % hObject handle to figure
  52. % eventdata reserved - to be defined in a future version of MATLAB
  53. % handles structure with handles and user data (see GUIDATA)
  54. % varargin command line arguments to C2M_export (see VARARGIN)
  55.  
  56. % Choose default command line output for C2M_export
  57. handles.output = hObject;
  58.  
  59. % Update handles structure
  60. guidata(hObject, handles);
  61.  
  62. % UIWAIT makes C2M_export wait for user response (see UIRESUME)
  63. % uiwait(handles.figure1);
  64.  
  65. % --- Outputs from this function are returned to the command line.
  66. function varargout = C2M_export_OutputFcn(hObject, eventdata, handles)
  67. % varargout cell array for returning output args (see VARARGOUT);
  68. % hObject handle to figure
  69. % eventdata reserved - to be defined in a future version of MATLAB
  70. % handles structure with handles and user data (see GUIDATA)
  71.  
  72. % Get default command line output from handles structure
  73. varargout{} = handles.output;
  74.  
  75. function edit1_Callback(hObject, eventdata, handles)
  76. % hObject handle to edit1 (see GCBO)
  77. % eventdata reserved - to be defined in a future version of MATLAB
  78. % handles structure with handles and user data (see GUIDATA)
  79.  
  80. % Hints: get(hObject,'String') returns contents of edit1 as text
  81. % str2double(get(hObject,'String')) returns contents of edit1 as a double
  82.  
  83. % --- Executes during object creation, after setting all properties.
  84. function edit1_CreateFcn(hObject, eventdata, handles)
  85. % hObject handle to edit1 (see GCBO)
  86. % eventdata reserved - to be defined in a future version of MATLAB
  87. % handles empty - handles not created until after all CreateFcns called
  88.  
  89. % Hint: edit controls usually have a white background on Windows.
  90. % See ISPC and COMPUTER.
  91. if ispc && isequal(get(hObject,'BackgroundColor'), get(,'defaultUicontrolBackgroundColor'))
  92. set(hObject,'BackgroundColor','white');
  93. end
  94.  
  95. function edit2_Callback(hObject, eventdata, handles)
  96. % hObject handle to edit2 (see GCBO)
  97. % eventdata reserved - to be defined in a future version of MATLAB
  98. % handles structure with handles and user data (see GUIDATA)
  99.  
  100. % Hints: get(hObject,'String') returns contents of edit2 as text
  101. % str2double(get(hObject,'String')) returns contents of edit2 as a double
  102.  
  103. % --- Executes during object creation, after setting all properties.
  104. function edit2_CreateFcn(hObject, eventdata, handles)
  105. % hObject handle to edit2 (see GCBO)
  106. % eventdata reserved - to be defined in a future version of MATLAB
  107. % handles empty - handles not created until after all CreateFcns called
  108.  
  109. % Hint: edit controls usually have a white background on Windows.
  110. % See ISPC and COMPUTER.
  111. if ispc && isequal(get(hObject,'BackgroundColor'), get(,'defaultUicontrolBackgroundColor'))
  112. set(hObject,'BackgroundColor','white');
  113. end
  114.  
  115. % --- Executes on button press in pushbutton1.
  116. function pushbutton1_Callback(hObject, eventdata, handles)
  117. global val
  118. % hObject handle to pushbutton1 (see GCBO)
  119. % eventdata reserved - to be defined in a future version of MATLAB
  120. % handles structure with handles and user data (see GUIDATA)
  121.  
  122. str1 = get(handles.edit2, 'String'); %??????
  123.  
  124. x = size(str1, ); %????????
  125. y = size(str1, ); %????????
  126. %b = zeros(y, x); %b??????????????????
  127.  
  128. for i = : y
  129.  
  130. opcode1 = str1(i,);
  131. opcode2 = strcat(str1(i,), str1(i,));
  132. opcode3 = strcat(str1(i,), str1(i,), str1(i,));
  133. opcode4 = strcat(str1(i,), str1(i,), str1(i,), str1(i,));
  134. rd = strcat(str1(i, ), str1(i, ));
  135. rs = strcat(str1(i,), str1(i,));
  136. rt = strcat(str1(i,), str1(i,));
  137.  
  138. if (x >= )
  139. imm_sh = strcat(str1(i,), str1(i,), str1(i,), str1(i, ), str1(i, ));
  140. end
  141. rt4 = strcat(str1(i,), str1(i,));
  142. rs4 = strcat(str1(i,), str1(i,));
  143. if (x >= ) imm4 = strcat(str1(i,), str1(i,), str1(i, ), str1(i, ), str1(i, ));
  144. end
  145.  
  146. rd2 = strcat(str1(i, ), str1(i, ));
  147. rs2 = strcat(str1(i,), str1(i,));
  148. rt2 = strcat(str1(i,), str1(i,));
  149. rt_w = strcat(str1(i, ), str1(i, ));
  150. imm_w = strcat(str1(i, ), str1(i, ), str1(i, ), str1(i, ), str1(i, ));
  151. rs_w = strcat(str1(i, ), str1(i, ));
  152.  
  153. switch opcode4
  154. case 'addi'
  155. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  156. b(i, :) = rig_f(rs4); b(i, :) = rig_f(rt4);
  157. b(i, :) = rig_n(imm4);
  158. % bq(i,:) = 'this is adi';bqq(i,:) = strcat('this is addi ', rs4 , '-', rt4 , '-',imm4);
  159. otherwise
  160. switch opcode3
  161. case 'add'
  162. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  163. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  164. b(i, :) = rig_f(rs); b(i, :) = rig_f(rt); b(i, :) = rig_f(rd); b(i, :) = ;
  165. bq(i,:) = 'this is add';bqq(i,:) = strcat('this is add, ', rs , '-', rt , '-',rd);
  166. case 'sub'
  167. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  168. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  169. b(i, :) = rig_f(rs); b(i, :) = rig_f(rt); b(i, :) = rig_f(rd); b(i, :) = ;
  170. bq(i,:) = 'this is sub';bqq(i,:) = strcat('this is sub, ', rs , '-', rt , '-',rd);
  171. case 'and'
  172. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  173. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  174. b(i, :) = rig_f(rs); b(i, :) = rig_f(rt); b(i, :) = rig_f(rd); b(i, :) = ;
  175. bq(i,:) = 'this is and';bqq(i,:) = strcat('this is and, ', rs , '-', rt , '-',rd);
  176. case 'slt'
  177. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  178. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  179. b(i, :) = rig_f(rs); b(i, :) = rig_f(rt); b(i, :) = rig_f(rd); b(i, :) = ;
  180. bq(i,:) = 'this is slt';bqq(i,:) = strcat('this is slt, ', rs , '-', rt , '-',rd);
  181. case 'sll'
  182. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  183. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  184. b(i, :) = ; b(i, :) = rig_f(rs); b(i, :) = rig_f(rd); b(i, :) = rig_sh(imm_sh);
  185. bq(i,:) = 'this is sll';
  186. % bqq(i,:) = strcat('this is sll, ', rs , '-', rd , '-',imm_sh);
  187. case 'srl'
  188. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  189. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  190. b(i, :) = ; b(i, :) = rig_f(rs); b(i, :) = rig_f(rd); b(i, :) = rig_sh(imm_sh);
  191. bq(i,:) = 'this is srl';
  192. % bqq(i,:) = strcat('this is srl, ', rs , '-', rd , '-',imm_sh);
  193. case 'sra'
  194. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  195. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  196. b(i, :) = ; b(i, :) = rig_f(rs); b(i, :) = rig_f(rd); b(i, :) = rig_sh(imm_sh);
  197. bq(i,:) = 'this is sra';
  198. case 'beq'
  199. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  200. b(i, :) = rig_f(rd); b(i, :) = rig_f(rs); b(i, :) = rig_n(imm_sh);
  201. bq(i,:) = 'this is beq';
  202. % bqq(i,:) = strcat('this is beq, ', rd , '-', rs , '-',imm_sh);
  203. case 'bne'
  204. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  205. b(i, :) = rig_f(rd); b(i, :) = rig_f(rs); b(i, :) = rig_n(imm_sh);
  206. bq(i,:) = 'this is bne';
  207. % bqq(i,:) = strcat('this is bne, ', rd , '-', rs , '-',imm_sh);
  208. case 'mul'
  209. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  210. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  211. b(i, :) = rig_f(rs); b(i, :) = rig_f(rt); b(i, :) = rig_f(rd); b(i, :) = ;
  212. bq(i,:) = 'this is mul';bqq(i,:) = strcat('this is mul, ', rs , '-', rt , '-',rd);
  213. otherwise
  214. switch opcode1
  215. case 'j'
  216. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  217. b(i, :) = ;
  218. bq(i,:) = 'this is jrr';bqq(i,:) = strcat('this is j ', '');
  219. otherwise
  220. end
  221. end
  222. end
  223.  
  224. switch opcode2
  225. case 'or'
  226. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  227. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  228. b(i, :) = rig_f(rs2); b(i, :) = rig_f(rt2); b(i, :) = rig_f(rd2); b(i, :) = ;
  229. bq(i,:) = 'this is orr';
  230.  
  231. case 'lw'
  232. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  233. b(i, :) = rig_f(rs_w);b(i, :) = rig_f(rt_w); b(i, :) = rig_n(imm_w);
  234.  
  235. % bqq(i,:) = strcat('this is lwr, ', rs_w, '-', rt_w, '-',imm_w);
  236. bq(i,:) = 'this is lwr';
  237.  
  238. case 'sw'
  239. b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;b(i,)=;
  240. b(i, :) = rig_f(rs_w);b(i, :) = rig_f(rt_w); b(i, :) = rig_n(imm_w);
  241. bq(i,:) = 'this is swr';
  242. otherwise
  243. end
  244.  
  245. end
  246.  
  247. bb = num2str(b);
  248. set(handles.edit1, 'String', bb);
  249. set(handles.edit3, 'String', bq);
  250. val = b;
  251.  
  252. % --- Executes on button press in pushbutton2.
  253. function pushbutton2_Callback(hObject, eventdata, handles)
  254. global val
  255. % hObject handle to pushbutton2 (see GCBO)
  256. % eventdata reserved - to be defined in a future version of MATLAB
  257. % handles structure with handles and user data (see GUIDATA)
  258. dlmwrite('C:\Users\ALIENWARE\Desktop\fft_test.txt', val, 'delimiter', '', 'precision', , 'newline','pc');
  259.  
  260. function edit3_Callback(hObject, eventdata, handles)
  261. % hObject handle to edit3 (see GCBO)
  262. % eventdata reserved - to be defined in a future version of MATLAB
  263. % handles structure with handles and user data (see GUIDATA)
  264.  
  265. % Hints: get(hObject,'String') returns contents of edit3 as text
  266. % str2double(get(hObject,'String')) returns contents of edit3 as a double
  267.  
  268. % --- Executes during object creation, after setting all properties.
  269. function edit3_CreateFcn(hObject, eventdata, handles)
  270. % hObject handle to edit3 (see GCBO)
  271. % eventdata reserved - to be defined in a future version of MATLAB
  272. % handles empty - handles not created until after all CreateFcns called
  273.  
  274. % Hint: edit controls usually have a white background on Windows.
  275. % See ISPC and COMPUTER.
  276. if ispc && isequal(get(hObject,'BackgroundColor'), get(,'defaultUicontrolBackgroundColor'))
  277. set(hObject,'BackgroundColor','white');
  278. end
  279.  
  280. % --- Executes on button press in pushbutton3.
  281. function pushbutton3_Callback(hObject, eventdata, handles)
  282. % hObject handle to pushbutton3 (see GCBO)
  283. % eventdata reserved - to be defined in a future version of MATLAB
  284. % handles structure with handles and user data (see GUIDATA)
  285. close(gcf);
  286.  
  287. % --- Creates and returns a handle to the GUI figure.
  288. function h1 = C2M_export_LayoutFcn(policy)
  289. % policy - create a new figure or use a singleton. 'new' or 'reuse'.
  290.  
  291. persistent hsingleton;
  292. if strcmpi(policy, 'reuse') & ishandle(hsingleton)
  293. h1 = hsingleton;
  294. return;
  295. end
  296. load C2M_export.mat
  297.  
  298. appdata = [];
  299. appdata.GUIDEOptions = mat{};
  300. appdata.lastValidTag = 'figure1';
  301. appdata.GUIDELayoutEditor = [];
  302. appdata.initTags = struct(...
  303. 'handle', [], ...
  304. 'tag', 'figure1');
  305.  
  306. h1 = figure(...
  307. 'PaperUnits','inches',...
  308. 'Units','characters',...
  309. 'Position',[135.8 23.5 250.2 52.2857142857143],...
  310. 'Visible',get(,'defaultfigureVisible'),...
  311. 'Color',[0.313725490196078 0.313725490196078 0.313725490196078],...
  312. 'IntegerHandle','off',...
  313. 'MenuBar','none',...
  314. 'Name','C2M',...
  315. 'NumberTitle','off',...
  316. 'Tag','figure1',...
  317. 'Resize','off',...
  318. 'PaperPosition',get(,'defaultfigurePaperPosition'),...
  319. 'PaperSize',[8.5 ],...
  320. 'PaperSizeMode',get(,'defaultfigurePaperSizeMode'),...
  321. 'PaperType','usletter',...
  322. 'PaperTypeMode',get(,'defaultfigurePaperTypeMode'),...
  323. 'PaperUnitsMode',get(,'defaultfigurePaperUnitsMode'),...
  324. 'ScreenPixelsPerInchMode','manual',...
  325. 'HandleVisibility','callback',...
  326. 'CreateFcn', {@local_CreateFcn, blanks(), appdata} );
  327.  
  328. appdata = [];
  329. appdata.lastValidTag = 'edit1';
  330.  
  331. h2 = uicontrol(...
  332. 'Parent',h1,...
  333. 'FontUnits',get(,'defaultuicontrolFontUnits'),...
  334. 'Units','characters',...
  335. 'HorizontalAlignment','left',...
  336. 'Max',,...
  337. 'String',blanks(),...
  338. 'Style','edit',...
  339. 'Position',[69.6 16.3571428571429 110.2 28.7142857142857],...
  340. 'BackgroundColor',[0.105882352941176 0.309803921568627 0.207843137254902],...
  341. 'Callback',@(hObject,eventdata)C2M_export('edit1_Callback',hObject,eventdata,guidata(hObject)),...
  342. 'Children',[],...
  343. 'ForegroundColor',[ ],...
  344. 'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)C2M_export('edit1_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
  345. 'Tag','edit1',...
  346. 'FontSize',);
  347.  
  348. appdata = [];
  349. appdata.lastValidTag = 'edit2';
  350.  
  351. h3 = uicontrol(...
  352. 'Parent',h1,...
  353. 'FontUnits',get(,'defaultuicontrolFontUnits'),...
  354. 'Units','characters',...
  355. 'HorizontalAlignment','left',...
  356. 'Max',,...
  357. 'String',blanks(),...
  358. 'Style','edit',...
  359. 'Position',[9.8 16.3571428571429 50.2 28.8571428571429],...
  360. 'BackgroundColor',[0.862745098039216 0.862745098039216 0.862745098039216],...
  361. 'Callback',@(hObject,eventdata)C2M_export('edit2_Callback',hObject,eventdata,guidata(hObject)),...
  362. 'Children',[],...
  363. 'ForegroundColor',[0.231372549019608 0.443137254901961 0.337254901960784],...
  364. 'TooltipString',blanks(),...
  365. 'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)C2M_export('edit2_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
  366. 'Tag','edit2',...
  367. 'FontSize',,...
  368. 'FontWeight',get(,'defaultuicontrolFontWeight'));
  369.  
  370. appdata = [];
  371. appdata.lastValidTag = 'pushbutton1';
  372.  
  373. h4 = uicontrol(...
  374. 'Parent',h1,...
  375. 'FontUnits',get(,'defaultuicontrolFontUnits'),...
  376. 'Units','characters',...
  377. 'String','Come On Boy !',...
  378. 'Style',get(,'defaultuicontrolStyle'),...
  379. 'Value',,...
  380. 'ValueMode',get(,'defaultuicontrolValueMode'),...
  381. 'Position',[9.8 2.14285714285714 140.2 10.7857142857143],...
  382. 'BackgroundColor',[ ],...
  383. 'Callback',@(hObject,eventdata)C2M_export('pushbutton1_Callback',hObject,eventdata,guidata(hObject)),...
  384. 'Children',[],...
  385. 'ForegroundColor',[0.945098039215686 0.968627450980392 0.949019607843137],...
  386. 'Tag','pushbutton1',...
  387. 'FontSize',,...
  388. 'FontWeight','bold',...
  389. 'CreateFcn', {@local_CreateFcn, blanks(), appdata} );
  390.  
  391. appdata = [];
  392. appdata.lastValidTag = 'pushbutton2';
  393.  
  394. h5 = uicontrol(...
  395. 'Parent',h1,...
  396. 'FontUnits',get(,'defaultuicontrolFontUnits'),...
  397. 'Units','characters',...
  398. 'String','Create txt file',...
  399. 'Style',get(,'defaultuicontrolStyle'),...
  400. 'Position',[159.6 2.14285714285714 60.2 10.7857142857143],...
  401. 'BackgroundColor',[ ],...
  402. 'Callback',@(hObject,eventdata)C2M_export('pushbutton2_Callback',hObject,eventdata,guidata(hObject)),...
  403. 'Children',[],...
  404. 'ForegroundColor',[0.105882352941176 0.309803921568627 0.207843137254902],...
  405. 'Tag','pushbutton2',...
  406. 'FontSize',,...
  407. 'FontAngle','italic',...
  408. 'FontWeight','bold',...
  409. 'CreateFcn', {@local_CreateFcn, blanks(), appdata} );
  410.  
  411. appdata = [];
  412. appdata.lastValidTag = 'text3';
  413.  
  414. h6 = uicontrol(...
  415. 'Parent',h1,...
  416. 'FontUnits',get(,'defaultuicontrolFontUnits'),...
  417. 'Units','characters',...
  418. 'String','Assemble Language',...
  419. 'Style','text',...
  420. 'Position',[5.4 45.7857142857143 60.8 2.92857142857143],...
  421. 'BackgroundColor',[0.313725490196078 0.313725490196078 0.313725490196078],...
  422. 'Children',[],...
  423. 'ForegroundColor',[0.941176470588235 0.941176470588235 0.941176470588235],...
  424. 'CreateFcn', {@local_CreateFcn, blanks(), appdata} ,...
  425. 'Tag','text3',...
  426. 'FontSize',,...
  427. 'FontAngle','italic',...
  428. 'FontWeight','bold');
  429.  
  430. appdata = [];
  431. appdata.lastValidTag = 'text4';
  432.  
  433. h7 = uicontrol(...
  434. 'Parent',h1,...
  435. 'FontUnits',get(,'defaultuicontrolFontUnits'),...
  436. 'Units','characters',...
  437. 'String','Machine Language',...
  438. 'Style','text',...
  439. 'Position',[93.6 45.6428571428571 60.8 2.92857142857143],...
  440. 'BackgroundColor',[0.313725490196078 0.313725490196078 0.313725490196078],...
  441. 'Children',[],...
  442. 'ForegroundColor',[ ],...
  443. 'ButtonDownFcn',blanks(),...
  444. 'CreateFcn', {@local_CreateFcn, blanks(), appdata} ,...
  445. 'DeleteFcn',blanks(),...
  446. 'Tag','text4',...
  447. 'FontSize',,...
  448. 'FontAngle','italic',...
  449. 'FontWeight','bold');
  450.  
  451. appdata = [];
  452. appdata.lastValidTag = 'edit3';
  453.  
  454. h8 = uicontrol(...
  455. 'Parent',h1,...
  456. 'FontUnits',get(,'defaultuicontrolFontUnits'),...
  457. 'Units','characters',...
  458. 'Max',,...
  459. 'String',blanks(),...
  460. 'Style','edit',...
  461. 'Position',[189.4 16.3571428571429 50.4 28.7142857142857],...
  462. 'BackgroundColor',[ ],...
  463. 'Callback',@(hObject,eventdata)C2M_export('edit3_Callback',hObject,eventdata,guidata(hObject)),...
  464. 'Children',[],...
  465. 'ForegroundColor',[ 0.949019607843137 0.866666666666667],...
  466. 'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)C2M_export('edit3_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
  467. 'Tag','edit3',...
  468. 'FontSize',,...
  469. 'FontWeight','bold');
  470.  
  471. appdata = [];
  472. appdata.lastValidTag = 'text5';
  473.  
  474. h9 = uicontrol(...
  475. 'Parent',h1,...
  476. 'FontUnits',get(,'defaultuicontrolFontUnits'),...
  477. 'Units','characters',...
  478. 'String','States',...
  479. 'Style','text',...
  480. 'Position',[182.4 45.6428571428571 60.8 2.92857142857143],...
  481. 'BackgroundColor',[0.313725490196078 0.313725490196078 0.313725490196078],...
  482. 'Children',[],...
  483. 'ForegroundColor',[ ],...
  484. 'ButtonDownFcn',blanks(),...
  485. 'CreateFcn', {@local_CreateFcn, blanks(), appdata} ,...
  486. 'DeleteFcn',blanks(),...
  487. 'Tag','text5',...
  488. 'FontSize',,...
  489. 'FontAngle','italic',...
  490. 'FontWeight','bold');
  491.  
  492. appdata = [];
  493. appdata.lastValidTag = 'pushbutton3';
  494.  
  495. h10 = uicontrol(...
  496. 'Parent',h1,...
  497. 'FontUnits',get(,'defaultuicontrolFontUnits'),...
  498. 'Units','characters',...
  499. 'String','EXIT',...
  500. 'Style',get(,'defaultuicontrolStyle'),...
  501. 'Position',[219.8 2.07142857142857 20.2 10.7857142857143],...
  502. 'BackgroundColor',[0.105882352941176 0.309803921568627 0.207843137254902],...
  503. 'Callback',@(hObject,eventdata)C2M_export('pushbutton3_Callback',hObject,eventdata,guidata(hObject)),...
  504. 'Children',[],...
  505. 'ForegroundColor',[ ],...
  506. 'Tag','pushbutton3',...
  507. 'FontSize',,...
  508. 'FontAngle','italic',...
  509. 'FontWeight','bold',...
  510. 'CreateFcn', {@local_CreateFcn, blanks(), appdata} );
  511.  
  512. hsingleton = h1;
  513.  
  514. % --- Set application data first then calling the CreateFcn.
  515. function local_CreateFcn(hObject, eventdata, createfcn, appdata)
  516.  
  517. if ~isempty(appdata)
  518. names = fieldnames(appdata);
  519. for i=:length(names)
  520. name = char(names(i));
  521. setappdata(hObject, name, getfield(appdata,name));
  522. end
  523. end
  524.  
  525. if ~isempty(createfcn)
  526. if isa(createfcn,'function_handle')
  527. createfcn(hObject, eventdata);
  528. else
  529. eval(createfcn);
  530. end
  531. end
  532.  
  533. % --- Handles default GUIDE GUI creation and callback dispatch
  534. function varargout = gui_mainfcn(gui_State, varargin)
  535.  
  536. gui_StateFields = {'gui_Name'
  537. 'gui_Singleton'
  538. 'gui_OpeningFcn'
  539. 'gui_OutputFcn'
  540. 'gui_LayoutFcn'
  541. 'gui_Callback'};
  542. gui_Mfile = '';
  543. for i=:length(gui_StateFields)
  544. if ~isfield(gui_State, gui_StateFields{i})
  545. error(message('MATLAB:guide:StateFieldNotFound', gui_StateFields{ i }, gui_Mfile));
  546. elseif isequal(gui_StateFields{i}, 'gui_Name')
  547. gui_Mfile = [gui_State.(gui_StateFields{i}), '.m'];
  548. end
  549. end
  550.  
  551. numargin = length(varargin);
  552.  
  553. if numargin ==
  554. % C2M_EXPORT
  555. % create the GUI only if we are not in the process of loading it
  556. % already
  557. gui_Create = true;
  558. elseif local_isInvokeActiveXCallback(gui_State, varargin{:})
  559. % C2M_EXPORT(ACTIVEX,...)
  560. vin{} = gui_State.gui_Name;
  561. vin{} = [get(varargin{}.Peer, 'Tag'), '_', varargin{end}];
  562. vin{} = varargin{};
  563. vin{} = varargin{end-};
  564. vin{} = guidata(varargin{}.Peer);
  565. feval(vin{:});
  566. return;
  567. elseif local_isInvokeHGCallback(gui_State, varargin{:})
  568. % C2M_EXPORT('CALLBACK',hObject,eventData,handles,...)
  569. gui_Create = false;
  570. else
  571. % C2M_EXPORT(...)
  572. % create the GUI and hand varargin to the openingfcn
  573. gui_Create = true;
  574. end
  575.  
  576. if ~gui_Create
  577. % In design time, we need to mark all components possibly created in
  578. % the coming callback evaluation as non-serializable. This way, they
  579. % will not be brought into GUIDE and not be saved in the figure file
  580. % when running/saving the GUI from GUIDE.
  581. designEval = false;
  582. if (numargin> && ishghandle(varargin{}))
  583. fig = varargin{};
  584. while ~isempty(fig) && ~ishghandle(fig,'figure')
  585. fig = get(fig,'parent');
  586. end
  587.  
  588. designEval = isappdata(,'CreatingGUIDEFigure') || (isscalar(fig)&&isprop(fig,'GUIDEFigure'));
  589. end
  590.  
  591. if designEval
  592. beforeChildren = findall(fig);
  593. end
  594.  
  595. % evaluate the callback now
  596. varargin{} = gui_State.gui_Callback;
  597. if nargout
  598. [varargout{:nargout}] = feval(varargin{:});
  599. else
  600. feval(varargin{:});
  601. end
  602.  
  603. % Set serializable of objects created in the above callback to off in
  604. % design time. Need to check whether figure handle is still valid in
  605. % case the figure is deleted during the callback dispatching.
  606. if designEval && ishghandle(fig)
  607. set(setdiff(findall(fig),beforeChildren), 'Serializable','off');
  608. end
  609. else
  610. if gui_State.gui_Singleton
  611. gui_SingletonOpt = 'reuse';
  612. else
  613. gui_SingletonOpt = 'new';
  614. end
  615.  
  616. % Check user passing 'visible' P/V pair first so that its value can be
  617. % used by oepnfig to prevent flickering
  618. gui_Visible = 'auto';
  619. gui_VisibleInput = '';
  620. for index=::length(varargin)
  621. if length(varargin) == index || ~ischar(varargin{index})
  622. break;
  623. end
  624.  
  625. % Recognize 'visible' P/V pair
  626. len1 = min(length('visible'),length(varargin{index}));
  627. len2 = min(length('off'),length(varargin{index+}));
  628. if ischar(varargin{index+}) && strncmpi(varargin{index},'visible',len1) && len2 >
  629. if strncmpi(varargin{index+},'off',len2)
  630. gui_Visible = 'invisible';
  631. gui_VisibleInput = 'off';
  632. elseif strncmpi(varargin{index+},'on',len2)
  633. gui_Visible = 'visible';
  634. gui_VisibleInput = 'on';
  635. end
  636. end
  637. end
  638.  
  639. % Open fig file with stored settings. Note: This executes all component
  640. % specific CreateFunctions with an empty HANDLES structure.
  641.  
  642. % Do feval on layout code in m-file if it exists
  643. gui_Exported = ~isempty(gui_State.gui_LayoutFcn);
  644. % this application data is used to indicate the running mode of a GUIDE
  645. % GUI to distinguish it from the design mode of the GUI in GUIDE. it is
  646. % only used by actxproxy at this time.
  647. setappdata(,genvarname(['OpenGuiWhenRunning_', gui_State.gui_Name]),);
  648. if gui_Exported
  649. gui_hFigure = feval(gui_State.gui_LayoutFcn, gui_SingletonOpt);
  650.  
  651. % make figure invisible here so that the visibility of figure is
  652. % consistent in OpeningFcn in the exported GUI case
  653. if isempty(gui_VisibleInput)
  654. gui_VisibleInput = get(gui_hFigure,'Visible');
  655. end
  656. set(gui_hFigure,'Visible','off')
  657.  
  658. % openfig (called by local_openfig below) does this for guis without
  659. % the LayoutFcn. Be sure to do it here so guis show up on screen.
  660. movegui(gui_hFigure,'onscreen');
  661. else
  662. gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt, gui_Visible);
  663. % If the figure has InGUIInitialization it was not completely created
  664. % on the last pass. Delete this handle and try again.
  665. if isappdata(gui_hFigure, 'InGUIInitialization')
  666. delete(gui_hFigure);
  667. gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt, gui_Visible);
  668. end
  669. end
  670. if isappdata(, genvarname(['OpenGuiWhenRunning_', gui_State.gui_Name]))
  671. rmappdata(,genvarname(['OpenGuiWhenRunning_', gui_State.gui_Name]));
  672. end
  673.  
  674. % Set flag to indicate starting GUI initialization
  675. setappdata(gui_hFigure,'InGUIInitialization',);
  676.  
  677. % Fetch GUIDE Application options
  678. gui_Options = getappdata(gui_hFigure,'GUIDEOptions');
  679. % Singleton setting in the GUI MATLAB code file takes priority if different
  680. gui_Options.singleton = gui_State.gui_Singleton;
  681.  
  682. if ~isappdata(gui_hFigure,'GUIOnScreen')
  683. % Adjust background color
  684. if gui_Options.syscolorfig
  685. set(gui_hFigure,'Color', get(,'DefaultUicontrolBackgroundColor'));
  686. end
  687.  
  688. % Generate HANDLES structure and store with GUIDATA. If there is
  689. % user set GUI data already, keep that also.
  690. data = guidata(gui_hFigure);
  691. handles = guihandles(gui_hFigure);
  692. if ~isempty(handles)
  693. if isempty(data)
  694. data = handles;
  695. else
  696. names = fieldnames(handles);
  697. for k=:length(names)
  698. data.(char(names(k)))=handles.(char(names(k)));
  699. end
  700. end
  701. end
  702. guidata(gui_hFigure, data);
  703. end
  704.  
  705. % Apply input P/V pairs other than 'visible'
  706. for index=::length(varargin)
  707. if length(varargin) == index || ~ischar(varargin{index})
  708. break;
  709. end
  710.  
  711. len1 = min(length('visible'),length(varargin{index}));
  712. if ~strncmpi(varargin{index},'visible',len1)
  713. try set(gui_hFigure, varargin{index}, varargin{index+}), catch break, end
  714. end
  715. end
  716.  
  717. % If handle visibility is set to 'callback', turn it on until finished
  718. % with OpeningFcn
  719. gui_HandleVisibility = get(gui_hFigure,'HandleVisibility');
  720. if strcmp(gui_HandleVisibility, 'callback')
  721. set(gui_hFigure,'HandleVisibility', 'on');
  722. end
  723.  
  724. feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});
  725.  
  726. if isscalar(gui_hFigure) && ishghandle(gui_hFigure)
  727. % Handle the default callbacks of predefined toolbar tools in this
  728. % GUI, if any
  729. guidemfile('restoreToolbarToolPredefinedCallback',gui_hFigure);
  730.  
  731. % Update handle visibility
  732. set(gui_hFigure,'HandleVisibility', gui_HandleVisibility);
  733.  
  734. % Call openfig again to pick up the saved visibility or apply the
  735. % one passed in from the P/V pairs
  736. if ~gui_Exported
  737. gui_hFigure = local_openfig(gui_State.gui_Name, 'reuse',gui_Visible);
  738. elseif ~isempty(gui_VisibleInput)
  739. set(gui_hFigure,'Visible',gui_VisibleInput);
  740. end
  741. if strcmpi(get(gui_hFigure, 'Visible'), 'on')
  742. figure(gui_hFigure);
  743.  
  744. if gui_Options.singleton
  745. setappdata(gui_hFigure,'GUIOnScreen', );
  746. end
  747. end
  748.  
  749. % Done with GUI initialization
  750. if isappdata(gui_hFigure,'InGUIInitialization')
  751. rmappdata(gui_hFigure,'InGUIInitialization');
  752. end
  753.  
  754. % If handle visibility is set to 'callback', turn it on until
  755. % finished with OutputFcn
  756. gui_HandleVisibility = get(gui_hFigure,'HandleVisibility');
  757. if strcmp(gui_HandleVisibility, 'callback')
  758. set(gui_hFigure,'HandleVisibility', 'on');
  759. end
  760. gui_Handles = guidata(gui_hFigure);
  761. else
  762. gui_Handles = [];
  763. end
  764.  
  765. if nargout
  766. [varargout{:nargout}] = feval(gui_State.gui_OutputFcn, gui_hFigure, [], gui_Handles);
  767. else
  768. feval(gui_State.gui_OutputFcn, gui_hFigure, [], gui_Handles);
  769. end
  770.  
  771. if isscalar(gui_hFigure) && ishghandle(gui_hFigure)
  772. set(gui_hFigure,'HandleVisibility', gui_HandleVisibility);
  773. end
  774. end
  775.  
  776. function gui_hFigure = local_openfig(name, singleton, visible)
  777.  
  778. % openfig with three arguments was new from R13. Try to call that first, if
  779. % failed, try the old openfig.
  780. if nargin('openfig') ==
  781. % OPENFIG did not accept 3rd input argument until R13,
  782. % toggle default figure visible to prevent the figure
  783. % from showing up too soon.
  784. gui_OldDefaultVisible = get(,'defaultFigureVisible');
  785. set(,'defaultFigureVisible','off');
  786. gui_hFigure = matlab.hg.internal.openfigLegacy(name, singleton);
  787. set(,'defaultFigureVisible',gui_OldDefaultVisible);
  788. else
  789. % Call version of openfig that accepts 'auto' option"
  790. gui_hFigure = matlab.hg.internal.openfigLegacy(name, singleton, visible);
  791. % %workaround for CreateFcn not called to create ActiveX
  792. % peers=findobj(findall(allchild(gui_hFigure)),'type','uicontrol','style','text');
  793. % for i=:length(peers)
  794. % if isappdata(peers(i),'Control')
  795. % actxproxy(peers(i));
  796. % end
  797. % end
  798. end
  799.  
  800. function result = local_isInvokeActiveXCallback(gui_State, varargin)
  801.  
  802. try
  803. result = ispc && iscom(varargin{}) ...
  804. && isequal(varargin{},gcbo);
  805. catch
  806. result = false;
  807. end
  808.  
  809. function result = local_isInvokeHGCallback(gui_State, varargin)
  810.  
  811. try
  812. fhandle = functions(gui_State.gui_Callback);
  813. result = ~isempty(findstr(gui_State.gui_Name,fhandle.file)) || ...
  814. (ischar(varargin{}) ...
  815. && isequal(ishghandle(varargin{}), ) ...
  816. && (~isempty(strfind(varargin{},[get(varargin{}, 'Tag'), '_'])) || ...
  817. ~isempty(strfind(varargin{}, '_CreateFcn'))) );
  818. catch
  819. result = false;
  820. end

C2M_EXPORT

MIPS架构——汇编代码转机器代码编译器 Matlab GUI的更多相关文章

  1. 如何在C或C++代码中嵌入ARM汇编代码

    转载自:http://blog.csdn.net/roland_sun/article/details/42921131 大家知道,用C或者C++等高级语言编写的程序,会被编译器编译成最终的机器指令. ...

  2. 程序编码(机器级代码+汇编代码+C代码+反汇编)

    [-1]相关声明 本文总结于csapp: 了解详情,或有兴趣,建议看原版书籍: [0]程序编码 GCC调用了一系列程序,将源代码转化成可执行代码的流程如下: (1)C预处理器扩展源代码,插入所有用#i ...

  3. c++(vs上)与g++(linux下)对于++操作的汇编代码解读

    先来看一个代码,估计很多同学都碰到过其中的某一个. #include <stdio.h> #include <iostream> using namespace std; in ...

  4. arm-elf-gcc汇编代码个人理解

    arm-elf-gcc汇编代码个人理解 有关arm-elf-gcc的安装使用问题请参照本人博客的另一篇文章http://www.cnblogs.com/wsine/p/4664503.html 由于各 ...

  5. GCC 嵌入汇编代码

    The format of basic inline assembly is very much straight forward. Its basic form is 基本汇编嵌入格式如下: asm ...

  6. 使用WinDbg获得托管方法的汇编代码

    概述:有时候,我们需要查看一个托管方法的汇编指令是怎么样的.记得在大学的时候,我们使用gcc -s和objdump来获得一个c程序代码的汇编指令.但是对于.NET程序来说,我们肯定无法轻松地获得这些内 ...

  7. GCC生成的汇编代码

    假设我们写了一个C代码文件 code.c包含下面代码: int accum = 0; int sum(int x, int y){ int t = x + y; accum += t; return ...

  8. Keil 中关于C语言编译生成汇编代码函数名规则

    在keil 中 C语言的函数有带参数和不带参数之分. 一般的资料里说fun(void)类型的函数不带参数,所以,keil编译器生成的汇编的调用地址(函数名) 为fun.这没有错.事实上,不管C语言的函 ...

  9. libaio under MIPS architecture /在mips架构下使用的libaio

    First, you can find libaio source in http://libaio.sourcearchive.com/ Second,download the libaio_0.3 ...

随机推荐

  1. SpringMVC源码分析和一些常用最佳实践

    前言 本文分两部分,第一部分剖析SpringMVC的源代码,看看一个请求响应是如何处理,第二部分主要介绍一些使用中的最佳实践,这些best practices有些比较common,有些比较tricky ...

  2. Redis学习---Redis操作之有序集合

    有序集合,在集合的基础上,为每元素排序:元素的排序需要根据另外一个值来进行比较,所以,对于有序集合,每一个元素有两个值,即:值和分数,分数专门用来做排序. zadd(name, *args, **kw ...

  3. symfony学习笔记2—纯的PHP代码和symfony的区别

    Symfony vs 纯PHP为啥symfony比普通的php文件访问要好?这一章我们写一个简单的php文件项目,然后组织它,你会发现为什么web应用会发展到现在这个样子.最后我们将学习symfony ...

  4. java String,StringBuilder和StringBuffer

    String:1.java语言中的字符串值属于String类,虽然有其它方法表示字符串(如字符数组),但java一般使用Sting类作为字符串的标准格式,java编译器把字符串值作为String对象. ...

  5. 【原创】MySQL 生产环境备份还原

    公司需要对生产环境的数据库进行备份,我接下了这份任务. 1. 首先谷歌了以下大家的备份方法 许多都使用到了Xtrabackup这个工具,超大型的公司可能有其他的的备份方法,这个工具对于中小型公司,甚至 ...

  6. debian 7上安装svn

    1.在终端中直接输入  sudo apt-get install subversion,选择安装即可 2.查看版本命令 svnserve --version(更多命令直接键入svnserve --he ...

  7. 前端统计利器:Sentry & Matomo

    今天主要说下两款前端统计工具的使用,Sentry & Matomo.以下主要是统计代码接入方式,因此使用前提是你已经在自己的服务器上搭建好了Sentry和Matomo的服务器 Sentry统计 ...

  8. hihocoder [Offer收割]编程练习赛61

    [Offer收割]编程练习赛61 A:最小排列 给定一个长度为m的序列b[1..m],再给定一个n,求一个字典序最小的1~n的排列A,使得b是A的子序列. 贪心即可,b是A的子序列,把不在b中的元素, ...

  9. HashMap,LinkedHashMap和Hashtable类的深入剖析与理解

    上一篇文章写了一些关于HashMap以及HashMap的线程安全问题,这篇文章再来说说Map系列中HashMap,LinkedHashMap和Hashtable三者之间的差异以及该注意的地方. Has ...

  10. BZOJ1434:[ZJOI2009]染色游戏(博弈论)

    Description 一共n×m个硬币,摆成n×m的长方形.dongdong和xixi玩一个游戏,每次可以选择一个连通块,并把其中的硬币全部翻转,但是需要满足存在一个硬币属于这个连通块并且所有其他硬 ...