设为首页收藏本站淘宝杂货铺

从F到0 - From F to 0

 找回密码
 注册已关闭
搜索
查看: 1941|回复: 0
收起左侧

易语言MASM置入代码两个字节集数据或与字节型数组首尾合并起来 (返回连接后的字节集)

[复制链接]
发表于 2019-8-30 09:01:59 | 显示全部楼层 |阅读模式

  1. .版本 2
  2. .支持库 spec

  3. .程序集 程序集1

  4. .子程序 _启动子程序, 整数型, , 请在本子程序中放置易模块初始化代码


  5. _临时子程序 ()  ' 在初始化代码执行完毕后调用测试代码
  6. 返回 (0)  ' 可以根据您的需要返回任意数值

  7. .子程序 _临时子程序
  8. .局部变量 空字节集, 字节集

  9. ' 本名称子程序用作测试程序用,仅在开发及调试环境中有效,编译发布程序前将被系统自动清空,请将所有用作测试的临时代码放在本子程序中。 ***注意不要修改本子程序的名称、参数及返回值类型。


  10. 调试输出 (字节集_合并 ({ 123, 234 }, 空字节集))
  11. 调试输出 (字节集_合并 (空字节集, { 123, 234 }))
  12. 调试输出 (字节集_合并 ({ 123, 234 }, {  }))
  13. 调试输出 (字节集_合并 ({  }, { 123, 234 }))
  14. 调试输出 (字节集_合并 ({ 1, 2, 3 }, { 4, 5 }))
  15. 调试输出 (字节集_合并 ({ 1, 2, 3, 4, 5 }, { 123 }))
  16. 调试输出 (字节集_合并 ({  }, {  }))
  17. 调试输出 (字节集与字节型数组_合并 ({ 1, 2, 3 }, { 4, 5, 6 }))
  18. 调试输出 (字节型数组与字节集_合并 ({ 1, 2, 3 }, { 4, 5, 6 }))
  19. 调试输出 (字节型数组_合并 ({ 1, 2, 3 }, { 4, 5, 6 }))


  20. 输出调试文本 (“1”)
  21. 结束 ()


  22. .子程序 字节集_合并, 字节集, 公开
  23. .参数 字节集A, 字节集
  24. .参数 字节集B, 字节集
  25. .局部变量 返回值, 字节集

  26. 返回值 = 取空白字节集 (取字节集长度 (字节集A) + 取字节集长度 (字节集B))
  27. 置入代码 ({ 235, 54, 80, 11, 192, 117, 4, 177, 1, 235, 23, 139, 0, 11, 192, 117, 4, 177, 1, 235, 13, 139, 64, 4, 11, 192, 117, 4, 177, 1, 235, 2, 50, 201, 88, 195, 86, 82, 51, 246, 235, 7, 138, 20, 6, 136, 20, 30, 70, 59, 247, 114, 245, 90, 94, 195, 80, 83, 81, 87, 86, 87, 139, 69, 8, 232, 188, 255, 255, 255, 138, 233, 139, 69, 12, 232, 178, 255, 255, 255, 139, 93, 252, 131, 195, 8, 10, 237, 116, 8, 10, 201, 116, 4, 235, 86, 235, 84, 10, 237, 116, 20, 139, 69, 12, 139, 0, 139, 120, 4, 131, 192, 8, 232, 174, 255, 255, 255, 235, 62, 235, 60, 10, 201, 116, 20, 139, 69, 8, 139, 0, 139, 120, 4, 131, 192, 8, 232, 150, 255, 255, 255, 235, 38, 235, 36, 139, 69, 8, 139, 0, 139, 120, 4, 139, 247, 131, 192, 8, 232, 128, 255, 255, 255, 139, 69, 12, 139, 0, 139, 120, 4, 131, 192, 8, 3, 222, 232, 110, 255, 255, 255, 88, 91, 89, 90, 94, 95 })
  28. ' jmp MAIN
  29. ' IS_DATA_NULL: ;是否为空字节集 参数1(字节集指针,EAX传入,由[EBP+n]返回) (CL寄存器返回,空为1,非空为0)
  30. ' push eax
  31. ' .if eax == 0
  32. ' mov cl,1
  33. ' jmp IS_DATA_NULL_END
  34. ' .endif
  35. ' mov eax,[eax]
  36. ' .if eax == 0
  37. ' mov cl,1
  38. ' jmp IS_DATA_NULL_END
  39. ' .endif
  40. ' mov eax,[eax+4]
  41. ' .if eax == 0
  42. ' mov cl,1
  43. ' jmp IS_DATA_NULL_END
  44. ' .endif
  45. ' xor cl,cl
  46. ' IS_DATA_NULL_END:
  47. ' pop eax
  48. ' ret
  49. ' COPY_RAM: ;复制内存 EAX:原地址 EBX:目标地址 EDI:长度
  50. ' push esi
  51. ' push edx
  52. ' xor esi,esi
  53. ' .while esi < edi
  54. ' mov dl,[eax+esi]
  55. ' mov [ebx+esi],dl
  56. ' inc esi
  57. ' .endw
  58. ' pop edx
  59. ' pop esi
  60. ' ret
  61. ' MAIN:
  62. ' push eax
  63. ' push ebx
  64. ' push ecx
  65. ' push edi
  66. ' push esi
  67. ' push edi
  68. ' mov eax,[ebp+8]
  69. ' call IS_DATA_NULL
  70. ' mov ch,cl
  71. ' mov eax,[ebp+12]
  72. ' call IS_DATA_NULL
  73. ' mov ebx,[ebp-4]
  74. ' add ebx,8
  75. ' .if ch && cl ;字节集AB全空
  76. ' jmp ASM_END
  77. ' .elseif ch ;字节集A空,复制B
  78. ' mov eax,[ebp+12]
  79. ' mov eax,[eax]
  80. ' mov edi,[eax+4]
  81. ' add eax,8
  82. ' call COPY_RAM
  83. ' jmp ASM_END
  84. ' .elseif cl ;字节集B空,复制A
  85. ' mov eax,[ebp+8]
  86. ' mov eax,[eax]
  87. ' mov edi,[eax+4]
  88. ' add eax,8
  89. ' call COPY_RAM
  90. ' jmp ASM_END
  91. ' .else ;字节集AB都不是空
  92. ' mov eax,[ebp+8]
  93. ' mov eax,[eax]
  94. ' mov edi,[eax+4]
  95. ' mov esi,edi
  96. ' add eax,8
  97. ' call COPY_RAM
  98. ' mov eax,[ebp+12]
  99. ' mov eax,[eax]
  100. ' mov edi,[eax+4]
  101. ' add eax,8
  102. ' add ebx,esi
  103. ' call COPY_RAM
  104. ' .endif
  105. ' ASM_END:
  106. ' pop eax
  107. ' pop ebx
  108. ' pop ecx
  109. ' pop edx
  110. ' pop esi
  111. ' pop edi

  112. 返回 (返回值)

  113. .子程序 字节集与字节型数组_合并, 字节集, 公开
  114. .参数 字节集, 字节集
  115. .参数 字节型数组, 字节型, 数组
  116. .局部变量 返回值, 字节集

  117. 返回值 = 取空白字节集 (取字节集长度 (字节集) + 取数组成员数 (字节型数组))
  118. 置入代码 ({ 235, 54, 80, 11, 192, 117, 4, 177, 1, 235, 23, 139, 0, 11, 192, 117, 4, 177, 1, 235, 13, 139, 64, 4, 11, 192, 117, 4, 177, 1, 235, 2, 50, 201, 88, 195, 86, 82, 51, 246, 235, 7, 138, 20, 6, 136, 20, 30, 70, 59, 247, 114, 245, 90, 94, 195, 80, 83, 81, 87, 86, 87, 139, 69, 8, 232, 188, 255, 255, 255, 138, 233, 139, 69, 12, 232, 178, 255, 255, 255, 139, 93, 252, 131, 195, 8, 10, 237, 116, 8, 10, 201, 116, 4, 235, 86, 235, 84, 10, 237, 116, 20, 139, 69, 12, 139, 0, 139, 120, 4, 131, 192, 8, 232, 174, 255, 255, 255, 235, 62, 235, 60, 10, 201, 116, 20, 139, 69, 8, 139, 0, 139, 120, 4, 131, 192, 8, 232, 150, 255, 255, 255, 235, 38, 235, 36, 139, 69, 8, 139, 0, 139, 120, 4, 139, 247, 131, 192, 8, 232, 128, 255, 255, 255, 139, 69, 12, 139, 0, 139, 120, 4, 131, 192, 8, 3, 222, 232, 110, 255, 255, 255, 88, 91, 89, 90, 94, 95 })
  119. ' jmp MAIN
  120. ' IS_DATA_NULL: ;是否为空字节集 参数1(字节集指针,EAX传入,由[EBP+n]返回) (CL寄存器返回,空为1,非空为0)
  121. ' push eax
  122. ' .if eax == 0
  123. ' mov cl,1
  124. ' jmp IS_DATA_NULL_END
  125. ' .endif
  126. ' mov eax,[eax]
  127. ' .if eax == 0
  128. ' mov cl,1
  129. ' jmp IS_DATA_NULL_END
  130. ' .endif
  131. ' mov eax,[eax+4]
  132. ' .if eax == 0
  133. ' mov cl,1
  134. ' jmp IS_DATA_NULL_END
  135. ' .endif
  136. ' xor cl,cl
  137. ' IS_DATA_NULL_END:
  138. ' pop eax
  139. ' ret
  140. ' COPY_RAM: ;复制内存 EAX:原地址 EBX:目标地址 EDI:长度
  141. ' push esi
  142. ' push edx
  143. ' xor esi,esi
  144. ' .while esi < edi
  145. ' mov dl,[eax+esi]
  146. ' mov [ebx+esi],dl
  147. ' inc esi
  148. ' .endw
  149. ' pop edx
  150. ' pop esi
  151. ' ret
  152. ' MAIN:
  153. ' push eax
  154. ' push ebx
  155. ' push ecx
  156. ' push edi
  157. ' push esi
  158. ' push edi
  159. ' mov eax,[ebp+8]
  160. ' call IS_DATA_NULL
  161. ' mov ch,cl
  162. ' mov eax,[ebp+12]
  163. ' call IS_DATA_NULL
  164. ' mov ebx,[ebp-4]
  165. ' add ebx,8
  166. ' .if ch && cl ;字节集AB全空
  167. ' jmp ASM_END
  168. ' .elseif ch ;字节集A空,复制B
  169. ' mov eax,[ebp+12]
  170. ' mov eax,[eax]
  171. ' mov edi,[eax+4]
  172. ' add eax,8
  173. ' call COPY_RAM
  174. ' jmp ASM_END
  175. ' .elseif cl ;字节集B空,复制A
  176. ' mov eax,[ebp+8]
  177. ' mov eax,[eax]
  178. ' mov edi,[eax+4]
  179. ' add eax,8
  180. ' call COPY_RAM
  181. ' jmp ASM_END
  182. ' .else ;字节集AB都不是空
  183. ' mov eax,[ebp+8]
  184. ' mov eax,[eax]
  185. ' mov edi,[eax+4]
  186. ' mov esi,edi
  187. ' add eax,8
  188. ' call COPY_RAM
  189. ' mov eax,[ebp+12]
  190. ' mov eax,[eax]
  191. ' mov edi,[eax+4]
  192. ' add eax,8
  193. ' add ebx,esi
  194. ' call COPY_RAM
  195. ' .endif
  196. ' ASM_END:
  197. ' pop eax
  198. ' pop ebx
  199. ' pop ecx
  200. ' pop edx
  201. ' pop esi
  202. ' pop edi

  203. 返回 (返回值)

  204. .子程序 字节型数组与字节集_合并, 字节集, 公开
  205. .参数 字节型数组, 字节型, 数组
  206. .参数 字节集, 字节集
  207. .局部变量 返回值, 字节集

  208. 返回值 = 取空白字节集 (取数组成员数 (字节型数组) + 取字节集长度 (字节集))
  209. 置入代码 ({ 235, 54, 80, 11, 192, 117, 4, 177, 1, 235, 23, 139, 0, 11, 192, 117, 4, 177, 1, 235, 13, 139, 64, 4, 11, 192, 117, 4, 177, 1, 235, 2, 50, 201, 88, 195, 86, 82, 51, 246, 235, 7, 138, 20, 6, 136, 20, 30, 70, 59, 247, 114, 245, 90, 94, 195, 80, 83, 81, 87, 86, 87, 139, 69, 8, 232, 188, 255, 255, 255, 138, 233, 139, 69, 12, 232, 178, 255, 255, 255, 139, 93, 252, 131, 195, 8, 10, 237, 116, 8, 10, 201, 116, 4, 235, 86, 235, 84, 10, 237, 116, 20, 139, 69, 12, 139, 0, 139, 120, 4, 131, 192, 8, 232, 174, 255, 255, 255, 235, 62, 235, 60, 10, 201, 116, 20, 139, 69, 8, 139, 0, 139, 120, 4, 131, 192, 8, 232, 150, 255, 255, 255, 235, 38, 235, 36, 139, 69, 8, 139, 0, 139, 120, 4, 139, 247, 131, 192, 8, 232, 128, 255, 255, 255, 139, 69, 12, 139, 0, 139, 120, 4, 131, 192, 8, 3, 222, 232, 110, 255, 255, 255, 88, 91, 89, 90, 94, 95 })
  210. ' jmp MAIN
  211. ' IS_DATA_NULL: ;是否为空字节集 参数1(字节集指针,EAX传入,由[EBP+n]返回) (CL寄存器返回,空为1,非空为0)
  212. ' push eax
  213. ' .if eax == 0
  214. ' mov cl,1
  215. ' jmp IS_DATA_NULL_END
  216. ' .endif
  217. ' mov eax,[eax]
  218. ' .if eax == 0
  219. ' mov cl,1
  220. ' jmp IS_DATA_NULL_END
  221. ' .endif
  222. ' mov eax,[eax+4]
  223. ' .if eax == 0
  224. ' mov cl,1
  225. ' jmp IS_DATA_NULL_END
  226. ' .endif
  227. ' xor cl,cl
  228. ' IS_DATA_NULL_END:
  229. ' pop eax
  230. ' ret
  231. ' COPY_RAM: ;复制内存 EAX:原地址 EBX:目标地址 EDI:长度
  232. ' push esi
  233. ' push edx
  234. ' xor esi,esi
  235. ' .while esi < edi
  236. ' mov dl,[eax+esi]
  237. ' mov [ebx+esi],dl
  238. ' inc esi
  239. ' .endw
  240. ' pop edx
  241. ' pop esi
  242. ' ret
  243. ' MAIN:
  244. ' push eax
  245. ' push ebx
  246. ' push ecx
  247. ' push edi
  248. ' push esi
  249. ' push edi
  250. ' mov eax,[ebp+8]
  251. ' call IS_DATA_NULL
  252. ' mov ch,cl
  253. ' mov eax,[ebp+12]
  254. ' call IS_DATA_NULL
  255. ' mov ebx,[ebp-4]
  256. ' add ebx,8
  257. ' .if ch && cl ;字节集AB全空
  258. ' jmp ASM_END
  259. ' .elseif ch ;字节集A空,复制B
  260. ' mov eax,[ebp+12]
  261. ' mov eax,[eax]
  262. ' mov edi,[eax+4]
  263. ' add eax,8
  264. ' call COPY_RAM
  265. ' jmp ASM_END
  266. ' .elseif cl ;字节集B空,复制A
  267. ' mov eax,[ebp+8]
  268. ' mov eax,[eax]
  269. ' mov edi,[eax+4]
  270. ' add eax,8
  271. ' call COPY_RAM
  272. ' jmp ASM_END
  273. ' .else ;字节集AB都不是空
  274. ' mov eax,[ebp+8]
  275. ' mov eax,[eax]
  276. ' mov edi,[eax+4]
  277. ' mov esi,edi
  278. ' add eax,8
  279. ' call COPY_RAM
  280. ' mov eax,[ebp+12]
  281. ' mov eax,[eax]
  282. ' mov edi,[eax+4]
  283. ' add eax,8
  284. ' add ebx,esi
  285. ' call COPY_RAM
  286. ' .endif
  287. ' ASM_END:
  288. ' pop eax
  289. ' pop ebx
  290. ' pop ecx
  291. ' pop edx
  292. ' pop esi
  293. ' pop edi

  294. 返回 (返回值)

  295. .子程序 字节型数组_合并, 字节集, 公开
  296. .参数 字节型数组A, 字节型, 数组
  297. .参数 字节型数组B, 字节型, 数组
  298. .局部变量 返回值, 字节集

  299. 返回值 = 取空白字节集 (取数组成员数 (字节型数组A) + 取数组成员数 (字节型数组B))
  300. 置入代码 ({ 235, 54, 80, 11, 192, 117, 4, 177, 1, 235, 23, 139, 0, 11, 192, 117, 4, 177, 1, 235, 13, 139, 64, 4, 11, 192, 117, 4, 177, 1, 235, 2, 50, 201, 88, 195, 86, 82, 51, 246, 235, 7, 138, 20, 6, 136, 20, 30, 70, 59, 247, 114, 245, 90, 94, 195, 80, 83, 81, 87, 86, 87, 139, 69, 8, 232, 188, 255, 255, 255, 138, 233, 139, 69, 12, 232, 178, 255, 255, 255, 139, 93, 252, 131, 195, 8, 10, 237, 116, 8, 10, 201, 116, 4, 235, 86, 235, 84, 10, 237, 116, 20, 139, 69, 12, 139, 0, 139, 120, 4, 131, 192, 8, 232, 174, 255, 255, 255, 235, 62, 235, 60, 10, 201, 116, 20, 139, 69, 8, 139, 0, 139, 120, 4, 131, 192, 8, 232, 150, 255, 255, 255, 235, 38, 235, 36, 139, 69, 8, 139, 0, 139, 120, 4, 139, 247, 131, 192, 8, 232, 128, 255, 255, 255, 139, 69, 12, 139, 0, 139, 120, 4, 131, 192, 8, 3, 222, 232, 110, 255, 255, 255, 88, 91, 89, 90, 94, 95 })
  301. ' jmp MAIN
  302. ' IS_DATA_NULL: ;是否为空字节集 参数1(字节集指针,EAX传入,由[EBP+n]返回) (CL寄存器返回,空为1,非空为0)
  303. ' push eax
  304. ' .if eax == 0
  305. ' mov cl,1
  306. ' jmp IS_DATA_NULL_END
  307. ' .endif
  308. ' mov eax,[eax]
  309. ' .if eax == 0
  310. ' mov cl,1
  311. ' jmp IS_DATA_NULL_END
  312. ' .endif
  313. ' mov eax,[eax+4]
  314. ' .if eax == 0
  315. ' mov cl,1
  316. ' jmp IS_DATA_NULL_END
  317. ' .endif
  318. ' xor cl,cl
  319. ' IS_DATA_NULL_END:
  320. ' pop eax
  321. ' ret
  322. ' COPY_RAM: ;复制内存 EAX:原地址 EBX:目标地址 EDI:长度
  323. ' push esi
  324. ' push edx
  325. ' xor esi,esi
  326. ' .while esi < edi
  327. ' mov dl,[eax+esi]
  328. ' mov [ebx+esi],dl
  329. ' inc esi
  330. ' .endw
  331. ' pop edx
  332. ' pop esi
  333. ' ret
  334. ' MAIN:
  335. ' push eax
  336. ' push ebx
  337. ' push ecx
  338. ' push edi
  339. ' push esi
  340. ' push edi
  341. ' mov eax,[ebp+8]
  342. ' call IS_DATA_NULL
  343. ' mov ch,cl
  344. ' mov eax,[ebp+12]
  345. ' call IS_DATA_NULL
  346. ' mov ebx,[ebp-4]
  347. ' add ebx,8
  348. ' .if ch && cl ;字节集AB全空
  349. ' jmp ASM_END
  350. ' .elseif ch ;字节集A空,复制B
  351. ' mov eax,[ebp+12]
  352. ' mov eax,[eax]
  353. ' mov edi,[eax+4]
  354. ' add eax,8
  355. ' call COPY_RAM
  356. ' jmp ASM_END
  357. ' .elseif cl ;字节集B空,复制A
  358. ' mov eax,[ebp+8]
  359. ' mov eax,[eax]
  360. ' mov edi,[eax+4]
  361. ' add eax,8
  362. ' call COPY_RAM
  363. ' jmp ASM_END
  364. ' .else ;字节集AB都不是空
  365. ' mov eax,[ebp+8]
  366. ' mov eax,[eax]
  367. ' mov edi,[eax+4]
  368. ' mov esi,edi
  369. ' add eax,8
  370. ' call COPY_RAM
  371. ' mov eax,[ebp+12]
  372. ' mov eax,[eax]
  373. ' mov edi,[eax+4]
  374. ' add eax,8
  375. ' add ebx,esi
  376. ' call COPY_RAM
  377. ' .endif
  378. ' ASM_END:
  379. ' pop eax
  380. ' pop ebx
  381. ' pop ecx
  382. ' pop edx
  383. ' pop esi
  384. ' pop edi

  385. 返回 (返回值)
复制代码

相关帖子

您需要登录后才可以回帖 登录 | 注册已关闭

本版积分规则

QQ|手机版|Archiver|从F到0 ( 蒙ICP备17002595号-1 )
蒙公网安备15010402000325号

腾讯云安全认证

GMT+8, 2024-4-27 07:23 , Processed in 1.313075 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表