jccolext-mmx.asm 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. ;
  2. ; jccolext.asm - colorspace conversion (MMX)
  3. ;
  4. ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
  5. ;
  6. ; Based on the x86 SIMD extension for IJG JPEG library
  7. ; Copyright (C) 1999-2006, MIYASAKA Masaru.
  8. ; For conditions of distribution and use, see copyright notice in jsimdext.inc
  9. ;
  10. ; This file should be assembled with NASM (Netwide Assembler),
  11. ; can *not* be assembled with Microsoft's MASM or any compatible
  12. ; assembler (including Borland's Turbo Assembler).
  13. ; NASM is available from http://nasm.sourceforge.net/ or
  14. ; http://sourceforge.net/project/showfiles.php?group_id=6208
  15. ;
  16. ; [TAB8]
  17. %include "jcolsamp.inc"
  18. ; --------------------------------------------------------------------------
  19. ;
  20. ; Convert some rows of samples to the output colorspace.
  21. ;
  22. ; GLOBAL(void)
  23. ; jsimd_rgb_ycc_convert_mmx (JDIMENSION img_width,
  24. ; JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
  25. ; JDIMENSION output_row, int num_rows);
  26. ;
  27. %define img_width(b) (b)+8 ; JDIMENSION img_width
  28. %define input_buf(b) (b)+12 ; JSAMPARRAY input_buf
  29. %define output_buf(b) (b)+16 ; JSAMPIMAGE output_buf
  30. %define output_row(b) (b)+20 ; JDIMENSION output_row
  31. %define num_rows(b) (b)+24 ; int num_rows
  32. %define original_ebp ebp+0
  33. %define wk(i) ebp-(WK_NUM-(i))*SIZEOF_MMWORD ; mmword wk[WK_NUM]
  34. %define WK_NUM 8
  35. %define gotptr wk(0)-SIZEOF_POINTER ; void * gotptr
  36. align 16
  37. global EXTN(jsimd_rgb_ycc_convert_mmx)
  38. EXTN(jsimd_rgb_ycc_convert_mmx):
  39. push ebp
  40. mov eax,esp ; eax = original ebp
  41. sub esp, byte 4
  42. and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits
  43. mov [esp],eax
  44. mov ebp,esp ; ebp = aligned ebp
  45. lea esp, [wk(0)]
  46. pushpic eax ; make a room for GOT address
  47. push ebx
  48. ; push ecx ; need not be preserved
  49. ; push edx ; need not be preserved
  50. push esi
  51. push edi
  52. get_GOT ebx ; get GOT address
  53. movpic POINTER [gotptr], ebx ; save GOT address
  54. mov ecx, JDIMENSION [img_width(eax)] ; num_cols
  55. test ecx,ecx
  56. jz near .return
  57. push ecx
  58. mov esi, JSAMPIMAGE [output_buf(eax)]
  59. mov ecx, JDIMENSION [output_row(eax)]
  60. mov edi, JSAMPARRAY [esi+0*SIZEOF_JSAMPARRAY]
  61. mov ebx, JSAMPARRAY [esi+1*SIZEOF_JSAMPARRAY]
  62. mov edx, JSAMPARRAY [esi+2*SIZEOF_JSAMPARRAY]
  63. lea edi, [edi+ecx*SIZEOF_JSAMPROW]
  64. lea ebx, [ebx+ecx*SIZEOF_JSAMPROW]
  65. lea edx, [edx+ecx*SIZEOF_JSAMPROW]
  66. pop ecx
  67. mov esi, JSAMPARRAY [input_buf(eax)]
  68. mov eax, INT [num_rows(eax)]
  69. test eax,eax
  70. jle near .return
  71. alignx 16,7
  72. .rowloop:
  73. pushpic eax
  74. push edx
  75. push ebx
  76. push edi
  77. push esi
  78. push ecx ; col
  79. mov esi, JSAMPROW [esi] ; inptr
  80. mov edi, JSAMPROW [edi] ; outptr0
  81. mov ebx, JSAMPROW [ebx] ; outptr1
  82. mov edx, JSAMPROW [edx] ; outptr2
  83. movpic eax, POINTER [gotptr] ; load GOT address (eax)
  84. cmp ecx, byte SIZEOF_MMWORD
  85. jae short .columnloop
  86. alignx 16,7
  87. %if RGB_PIXELSIZE == 3 ; ---------------
  88. .column_ld1:
  89. push eax
  90. push edx
  91. lea ecx,[ecx+ecx*2] ; imul ecx,RGB_PIXELSIZE
  92. test cl, SIZEOF_BYTE
  93. jz short .column_ld2
  94. sub ecx, byte SIZEOF_BYTE
  95. xor eax,eax
  96. mov al, BYTE [esi+ecx]
  97. .column_ld2:
  98. test cl, SIZEOF_WORD
  99. jz short .column_ld4
  100. sub ecx, byte SIZEOF_WORD
  101. xor edx,edx
  102. mov dx, WORD [esi+ecx]
  103. shl eax, WORD_BIT
  104. or eax,edx
  105. .column_ld4:
  106. movd mmA,eax
  107. pop edx
  108. pop eax
  109. test cl, SIZEOF_DWORD
  110. jz short .column_ld8
  111. sub ecx, byte SIZEOF_DWORD
  112. movd mmG, DWORD [esi+ecx]
  113. psllq mmA, DWORD_BIT
  114. por mmA,mmG
  115. .column_ld8:
  116. test cl, SIZEOF_MMWORD
  117. jz short .column_ld16
  118. movq mmG,mmA
  119. movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
  120. mov ecx, SIZEOF_MMWORD
  121. jmp short .rgb_ycc_cnv
  122. .column_ld16:
  123. test cl, 2*SIZEOF_MMWORD
  124. mov ecx, SIZEOF_MMWORD
  125. jz short .rgb_ycc_cnv
  126. movq mmF,mmA
  127. movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
  128. movq mmG, MMWORD [esi+1*SIZEOF_MMWORD]
  129. jmp short .rgb_ycc_cnv
  130. alignx 16,7
  131. .columnloop:
  132. movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
  133. movq mmG, MMWORD [esi+1*SIZEOF_MMWORD]
  134. movq mmF, MMWORD [esi+2*SIZEOF_MMWORD]
  135. .rgb_ycc_cnv:
  136. ; mmA=(00 10 20 01 11 21 02 12)
  137. ; mmG=(22 03 13 23 04 14 24 05)
  138. ; mmF=(15 25 06 16 26 07 17 27)
  139. movq mmD,mmA
  140. psllq mmA,4*BYTE_BIT ; mmA=(-- -- -- -- 00 10 20 01)
  141. psrlq mmD,4*BYTE_BIT ; mmD=(11 21 02 12 -- -- -- --)
  142. punpckhbw mmA,mmG ; mmA=(00 04 10 14 20 24 01 05)
  143. psllq mmG,4*BYTE_BIT ; mmG=(-- -- -- -- 22 03 13 23)
  144. punpcklbw mmD,mmF ; mmD=(11 15 21 25 02 06 12 16)
  145. punpckhbw mmG,mmF ; mmG=(22 26 03 07 13 17 23 27)
  146. movq mmE,mmA
  147. psllq mmA,4*BYTE_BIT ; mmA=(-- -- -- -- 00 04 10 14)
  148. psrlq mmE,4*BYTE_BIT ; mmE=(20 24 01 05 -- -- -- --)
  149. punpckhbw mmA,mmD ; mmA=(00 02 04 06 10 12 14 16)
  150. psllq mmD,4*BYTE_BIT ; mmD=(-- -- -- -- 11 15 21 25)
  151. punpcklbw mmE,mmG ; mmE=(20 22 24 26 01 03 05 07)
  152. punpckhbw mmD,mmG ; mmD=(11 13 15 17 21 23 25 27)
  153. pxor mmH,mmH
  154. movq mmC,mmA
  155. punpcklbw mmA,mmH ; mmA=(00 02 04 06)
  156. punpckhbw mmC,mmH ; mmC=(10 12 14 16)
  157. movq mmB,mmE
  158. punpcklbw mmE,mmH ; mmE=(20 22 24 26)
  159. punpckhbw mmB,mmH ; mmB=(01 03 05 07)
  160. movq mmF,mmD
  161. punpcklbw mmD,mmH ; mmD=(11 13 15 17)
  162. punpckhbw mmF,mmH ; mmF=(21 23 25 27)
  163. %else ; RGB_PIXELSIZE == 4 ; -----------
  164. .column_ld1:
  165. test cl, SIZEOF_MMWORD/8
  166. jz short .column_ld2
  167. sub ecx, byte SIZEOF_MMWORD/8
  168. movd mmA, DWORD [esi+ecx*RGB_PIXELSIZE]
  169. .column_ld2:
  170. test cl, SIZEOF_MMWORD/4
  171. jz short .column_ld4
  172. sub ecx, byte SIZEOF_MMWORD/4
  173. movq mmF,mmA
  174. movq mmA, MMWORD [esi+ecx*RGB_PIXELSIZE]
  175. .column_ld4:
  176. test cl, SIZEOF_MMWORD/2
  177. mov ecx, SIZEOF_MMWORD
  178. jz short .rgb_ycc_cnv
  179. movq mmD,mmA
  180. movq mmC,mmF
  181. movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
  182. movq mmF, MMWORD [esi+1*SIZEOF_MMWORD]
  183. jmp short .rgb_ycc_cnv
  184. alignx 16,7
  185. .columnloop:
  186. movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
  187. movq mmF, MMWORD [esi+1*SIZEOF_MMWORD]
  188. movq mmD, MMWORD [esi+2*SIZEOF_MMWORD]
  189. movq mmC, MMWORD [esi+3*SIZEOF_MMWORD]
  190. .rgb_ycc_cnv:
  191. ; mmA=(00 10 20 30 01 11 21 31)
  192. ; mmF=(02 12 22 32 03 13 23 33)
  193. ; mmD=(04 14 24 34 05 15 25 35)
  194. ; mmC=(06 16 26 36 07 17 27 37)
  195. movq mmB,mmA
  196. punpcklbw mmA,mmF ; mmA=(00 02 10 12 20 22 30 32)
  197. punpckhbw mmB,mmF ; mmB=(01 03 11 13 21 23 31 33)
  198. movq mmG,mmD
  199. punpcklbw mmD,mmC ; mmD=(04 06 14 16 24 26 34 36)
  200. punpckhbw mmG,mmC ; mmG=(05 07 15 17 25 27 35 37)
  201. movq mmE,mmA
  202. punpcklwd mmA,mmD ; mmA=(00 02 04 06 10 12 14 16)
  203. punpckhwd mmE,mmD ; mmE=(20 22 24 26 30 32 34 36)
  204. movq mmH,mmB
  205. punpcklwd mmB,mmG ; mmB=(01 03 05 07 11 13 15 17)
  206. punpckhwd mmH,mmG ; mmH=(21 23 25 27 31 33 35 37)
  207. pxor mmF,mmF
  208. movq mmC,mmA
  209. punpcklbw mmA,mmF ; mmA=(00 02 04 06)
  210. punpckhbw mmC,mmF ; mmC=(10 12 14 16)
  211. movq mmD,mmB
  212. punpcklbw mmB,mmF ; mmB=(01 03 05 07)
  213. punpckhbw mmD,mmF ; mmD=(11 13 15 17)
  214. movq mmG,mmE
  215. punpcklbw mmE,mmF ; mmE=(20 22 24 26)
  216. punpckhbw mmG,mmF ; mmG=(30 32 34 36)
  217. punpcklbw mmF,mmH
  218. punpckhbw mmH,mmH
  219. psrlw mmF,BYTE_BIT ; mmF=(21 23 25 27)
  220. psrlw mmH,BYTE_BIT ; mmH=(31 33 35 37)
  221. %endif ; RGB_PIXELSIZE ; ---------------
  222. ; mm0=(R0 R2 R4 R6)=RE, mm2=(G0 G2 G4 G6)=GE, mm4=(B0 B2 B4 B6)=BE
  223. ; mm1=(R1 R3 R5 R7)=RO, mm3=(G1 G3 G5 G7)=GO, mm5=(B1 B3 B5 B7)=BO
  224. ; (Original)
  225. ; Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
  226. ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE
  227. ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE
  228. ;
  229. ; (This implementation)
  230. ; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G
  231. ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE
  232. ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE
  233. movq MMWORD [wk(0)], mm0 ; wk(0)=RE
  234. movq MMWORD [wk(1)], mm1 ; wk(1)=RO
  235. movq MMWORD [wk(2)], mm4 ; wk(2)=BE
  236. movq MMWORD [wk(3)], mm5 ; wk(3)=BO
  237. movq mm6,mm1
  238. punpcklwd mm1,mm3
  239. punpckhwd mm6,mm3
  240. movq mm7,mm1
  241. movq mm4,mm6
  242. pmaddwd mm1,[GOTOFF(eax,PW_F0299_F0337)] ; mm1=ROL*FIX(0.299)+GOL*FIX(0.337)
  243. pmaddwd mm6,[GOTOFF(eax,PW_F0299_F0337)] ; mm6=ROH*FIX(0.299)+GOH*FIX(0.337)
  244. pmaddwd mm7,[GOTOFF(eax,PW_MF016_MF033)] ; mm7=ROL*-FIX(0.168)+GOL*-FIX(0.331)
  245. pmaddwd mm4,[GOTOFF(eax,PW_MF016_MF033)] ; mm4=ROH*-FIX(0.168)+GOH*-FIX(0.331)
  246. movq MMWORD [wk(4)], mm1 ; wk(4)=ROL*FIX(0.299)+GOL*FIX(0.337)
  247. movq MMWORD [wk(5)], mm6 ; wk(5)=ROH*FIX(0.299)+GOH*FIX(0.337)
  248. pxor mm1,mm1
  249. pxor mm6,mm6
  250. punpcklwd mm1,mm5 ; mm1=BOL
  251. punpckhwd mm6,mm5 ; mm6=BOH
  252. psrld mm1,1 ; mm1=BOL*FIX(0.500)
  253. psrld mm6,1 ; mm6=BOH*FIX(0.500)
  254. movq mm5,[GOTOFF(eax,PD_ONEHALFM1_CJ)] ; mm5=[PD_ONEHALFM1_CJ]
  255. paddd mm7,mm1
  256. paddd mm4,mm6
  257. paddd mm7,mm5
  258. paddd mm4,mm5
  259. psrld mm7,SCALEBITS ; mm7=CbOL
  260. psrld mm4,SCALEBITS ; mm4=CbOH
  261. packssdw mm7,mm4 ; mm7=CbO
  262. movq mm1, MMWORD [wk(2)] ; mm1=BE
  263. movq mm6,mm0
  264. punpcklwd mm0,mm2
  265. punpckhwd mm6,mm2
  266. movq mm5,mm0
  267. movq mm4,mm6
  268. pmaddwd mm0,[GOTOFF(eax,PW_F0299_F0337)] ; mm0=REL*FIX(0.299)+GEL*FIX(0.337)
  269. pmaddwd mm6,[GOTOFF(eax,PW_F0299_F0337)] ; mm6=REH*FIX(0.299)+GEH*FIX(0.337)
  270. pmaddwd mm5,[GOTOFF(eax,PW_MF016_MF033)] ; mm5=REL*-FIX(0.168)+GEL*-FIX(0.331)
  271. pmaddwd mm4,[GOTOFF(eax,PW_MF016_MF033)] ; mm4=REH*-FIX(0.168)+GEH*-FIX(0.331)
  272. movq MMWORD [wk(6)], mm0 ; wk(6)=REL*FIX(0.299)+GEL*FIX(0.337)
  273. movq MMWORD [wk(7)], mm6 ; wk(7)=REH*FIX(0.299)+GEH*FIX(0.337)
  274. pxor mm0,mm0
  275. pxor mm6,mm6
  276. punpcklwd mm0,mm1 ; mm0=BEL
  277. punpckhwd mm6,mm1 ; mm6=BEH
  278. psrld mm0,1 ; mm0=BEL*FIX(0.500)
  279. psrld mm6,1 ; mm6=BEH*FIX(0.500)
  280. movq mm1,[GOTOFF(eax,PD_ONEHALFM1_CJ)] ; mm1=[PD_ONEHALFM1_CJ]
  281. paddd mm5,mm0
  282. paddd mm4,mm6
  283. paddd mm5,mm1
  284. paddd mm4,mm1
  285. psrld mm5,SCALEBITS ; mm5=CbEL
  286. psrld mm4,SCALEBITS ; mm4=CbEH
  287. packssdw mm5,mm4 ; mm5=CbE
  288. psllw mm7,BYTE_BIT
  289. por mm5,mm7 ; mm5=Cb
  290. movq MMWORD [ebx], mm5 ; Save Cb
  291. movq mm0, MMWORD [wk(3)] ; mm0=BO
  292. movq mm6, MMWORD [wk(2)] ; mm6=BE
  293. movq mm1, MMWORD [wk(1)] ; mm1=RO
  294. movq mm4,mm0
  295. punpcklwd mm0,mm3
  296. punpckhwd mm4,mm3
  297. movq mm7,mm0
  298. movq mm5,mm4
  299. pmaddwd mm0,[GOTOFF(eax,PW_F0114_F0250)] ; mm0=BOL*FIX(0.114)+GOL*FIX(0.250)
  300. pmaddwd mm4,[GOTOFF(eax,PW_F0114_F0250)] ; mm4=BOH*FIX(0.114)+GOH*FIX(0.250)
  301. pmaddwd mm7,[GOTOFF(eax,PW_MF008_MF041)] ; mm7=BOL*-FIX(0.081)+GOL*-FIX(0.418)
  302. pmaddwd mm5,[GOTOFF(eax,PW_MF008_MF041)] ; mm5=BOH*-FIX(0.081)+GOH*-FIX(0.418)
  303. movq mm3,[GOTOFF(eax,PD_ONEHALF)] ; mm3=[PD_ONEHALF]
  304. paddd mm0, MMWORD [wk(4)]
  305. paddd mm4, MMWORD [wk(5)]
  306. paddd mm0,mm3
  307. paddd mm4,mm3
  308. psrld mm0,SCALEBITS ; mm0=YOL
  309. psrld mm4,SCALEBITS ; mm4=YOH
  310. packssdw mm0,mm4 ; mm0=YO
  311. pxor mm3,mm3
  312. pxor mm4,mm4
  313. punpcklwd mm3,mm1 ; mm3=ROL
  314. punpckhwd mm4,mm1 ; mm4=ROH
  315. psrld mm3,1 ; mm3=ROL*FIX(0.500)
  316. psrld mm4,1 ; mm4=ROH*FIX(0.500)
  317. movq mm1,[GOTOFF(eax,PD_ONEHALFM1_CJ)] ; mm1=[PD_ONEHALFM1_CJ]
  318. paddd mm7,mm3
  319. paddd mm5,mm4
  320. paddd mm7,mm1
  321. paddd mm5,mm1
  322. psrld mm7,SCALEBITS ; mm7=CrOL
  323. psrld mm5,SCALEBITS ; mm5=CrOH
  324. packssdw mm7,mm5 ; mm7=CrO
  325. movq mm3, MMWORD [wk(0)] ; mm3=RE
  326. movq mm4,mm6
  327. punpcklwd mm6,mm2
  328. punpckhwd mm4,mm2
  329. movq mm1,mm6
  330. movq mm5,mm4
  331. pmaddwd mm6,[GOTOFF(eax,PW_F0114_F0250)] ; mm6=BEL*FIX(0.114)+GEL*FIX(0.250)
  332. pmaddwd mm4,[GOTOFF(eax,PW_F0114_F0250)] ; mm4=BEH*FIX(0.114)+GEH*FIX(0.250)
  333. pmaddwd mm1,[GOTOFF(eax,PW_MF008_MF041)] ; mm1=BEL*-FIX(0.081)+GEL*-FIX(0.418)
  334. pmaddwd mm5,[GOTOFF(eax,PW_MF008_MF041)] ; mm5=BEH*-FIX(0.081)+GEH*-FIX(0.418)
  335. movq mm2,[GOTOFF(eax,PD_ONEHALF)] ; mm2=[PD_ONEHALF]
  336. paddd mm6, MMWORD [wk(6)]
  337. paddd mm4, MMWORD [wk(7)]
  338. paddd mm6,mm2
  339. paddd mm4,mm2
  340. psrld mm6,SCALEBITS ; mm6=YEL
  341. psrld mm4,SCALEBITS ; mm4=YEH
  342. packssdw mm6,mm4 ; mm6=YE
  343. psllw mm0,BYTE_BIT
  344. por mm6,mm0 ; mm6=Y
  345. movq MMWORD [edi], mm6 ; Save Y
  346. pxor mm2,mm2
  347. pxor mm4,mm4
  348. punpcklwd mm2,mm3 ; mm2=REL
  349. punpckhwd mm4,mm3 ; mm4=REH
  350. psrld mm2,1 ; mm2=REL*FIX(0.500)
  351. psrld mm4,1 ; mm4=REH*FIX(0.500)
  352. movq mm0,[GOTOFF(eax,PD_ONEHALFM1_CJ)] ; mm0=[PD_ONEHALFM1_CJ]
  353. paddd mm1,mm2
  354. paddd mm5,mm4
  355. paddd mm1,mm0
  356. paddd mm5,mm0
  357. psrld mm1,SCALEBITS ; mm1=CrEL
  358. psrld mm5,SCALEBITS ; mm5=CrEH
  359. packssdw mm1,mm5 ; mm1=CrE
  360. psllw mm7,BYTE_BIT
  361. por mm1,mm7 ; mm1=Cr
  362. movq MMWORD [edx], mm1 ; Save Cr
  363. sub ecx, byte SIZEOF_MMWORD
  364. add esi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; inptr
  365. add edi, byte SIZEOF_MMWORD ; outptr0
  366. add ebx, byte SIZEOF_MMWORD ; outptr1
  367. add edx, byte SIZEOF_MMWORD ; outptr2
  368. cmp ecx, byte SIZEOF_MMWORD
  369. jae near .columnloop
  370. test ecx,ecx
  371. jnz near .column_ld1
  372. pop ecx ; col
  373. pop esi
  374. pop edi
  375. pop ebx
  376. pop edx
  377. poppic eax
  378. add esi, byte SIZEOF_JSAMPROW ; input_buf
  379. add edi, byte SIZEOF_JSAMPROW
  380. add ebx, byte SIZEOF_JSAMPROW
  381. add edx, byte SIZEOF_JSAMPROW
  382. dec eax ; num_rows
  383. jg near .rowloop
  384. emms ; empty MMX state
  385. .return:
  386. pop edi
  387. pop esi
  388. ; pop edx ; need not be preserved
  389. ; pop ecx ; need not be preserved
  390. pop ebx
  391. mov esp,ebp ; esp <- aligned ebp
  392. pop esp ; esp <- original ebp
  393. pop ebp
  394. ret
  395. ; For some reason, the OS X linker does not honor the request to align the
  396. ; segment unless we do this.
  397. align 16