Advertisement
Guest User

bmpgen

a guest
Jul 27th, 2022
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.63 KB | None | 0 0
  1. format ELF executable
  2. entry start
  3.  
  4. segment readable writeable
  5. ;bmp header
  6. header db $42,$4d
  7. ;size of the bmp file
  8. db $fa,$00,$00,$00
  9. ;unused
  10. db $00,$00
  11. ;unused
  12. db $00,$00
  13. ;offset where the pixel data can be found
  14. db $7a,$00,$00,$00
  15. ;dib header
  16. db $6c,$00,$00,$00
  17. ;width
  18. db $08,$00,$00,$00
  19. ;height
  20. db $08,$00,$00,$00
  21. ;planes
  22. db $01,$00
  23. ;bits per pixel
  24. db $20,$00
  25. ;compression
  26. db $00,$00,$00,$00
  27. ;size of the bitmap data (with padding)
  28. db $40,$00,$00,$00
  29. ;print resolution
  30. db $13,$0b,$00,$00
  31. db $13,$0b,$00,$00
  32. ;colors in the palette
  33. db $00,$00,$00,$00
  34. ;important colors
  35. db $00,$00,$00,$00
  36. ;red channel bit mask
  37. db $00,$00,$00,$00
  38. ;green channel mask
  39. db $00,$00,$00,$00
  40. ;blue channel mask
  41. db $00,$00,$00,$00
  42. ;alpha channel mask
  43. db $00,$00,$00,$00
  44. ;LCS_WINDOWS_COLOR_SPACE
  45. db $20,$6e,$69,$57
  46. ;color space endpoints
  47. db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
  48. ;red gamma
  49. db $00,$00,$00,$00
  50. ;green gamma
  51. db $00,$00,$00,$00
  52. ;blue gamma
  53. db $00,$00,$00,$00
  54. header_s = $-header
  55. ;start of the bmp data
  56. conten dd $00,$00,$00,$00
  57. dd $00,$00,$00,$00
  58. dd $00,$00,$00,$00
  59. dd $00,$00,$00,$00
  60. dd $00,$00,$00,$00
  61. dd $00,$00,$00,$00
  62. dd $00,$00,$00,$00
  63. dd $00,$00,$00,$00
  64. dd $00,$00,$00,$00
  65. dd $00,$00,$00,$00
  66. dd $00,$00,$00,$00
  67. dd $00,$00,$00,$00
  68. dd $00,$00,$00,$00
  69. dd $00,$00,$00,$00
  70. dd $00,$00,$00,$00
  71. dd $00,$00,$00,$00
  72. dd $00,$00,$00,$00
  73. dd $00,$00,$00,$00
  74. dd $00,$00,$00,$00
  75. dd $00,$00,$00,$00
  76. dd $00,$00,$00,$00
  77. dd $00,$00,$00,$00
  78. dd $00,$00,$00,$00
  79. dd $00,$00,$00,$00
  80. dd $00,$00,$00,$00
  81. dd $00,$00,$00,$00
  82. dd $00,$00,$00,$00
  83. dd $00,$00,$00,$00
  84. dd $00,$00,$00,$00
  85. dd $00,$00,$00,$00
  86. dd $00,$00,$00,$00
  87. dd $00,$00,$00,$00
  88. conten_s = $-conten
  89.  
  90. ; *** Random Generator: linear congruential generator (LCG)
  91. ;randConst dd $00003039 ;ANSI C: Addition constant: = 12345
  92. ;randMult dd $41C64E6D ;ANSI C: Multiplicator: = 1103515245
  93. ;randShift dd $00000000 ;ANSI C: No shift necessary
  94. ;randMask dd $7FFFFFFF ;ANSI C: Take bits 0..30
  95. ;randValue dd $3C6EF35F ;Initial value & result container
  96.  
  97. fd_in rb 1
  98. fd_out rb 1
  99. name db 'bmpgen.bmp',$00
  100. enterdata db "Enter your file data (128 bytes max): ",$00
  101. enterdata_s = $-enterdata
  102. done db "File generated successfully.",$0a,$00
  103. done_s = $-done
  104.  
  105. segment readable executable
  106. start:
  107. ;ask the user to fill the bmp with data
  108. push 4
  109. pop eax
  110. push 1
  111. pop ebx
  112. push enterdata
  113. pop ecx
  114. push enterdata_s
  115. pop edx
  116. int $80
  117.  
  118. push 3
  119. pop eax
  120. xor ebx,ebx
  121. push conten
  122. pop ecx
  123. push conten_s
  124. pop edx
  125. int $80
  126.  
  127. ;create the file
  128. push 8
  129. pop eax
  130. push name
  131. pop ebx
  132. push 777
  133. pop ecx
  134. int $80
  135.  
  136. mov dword[fd_out],eax
  137.  
  138. ;rndDoubleFunc:
  139. ; push edx ;Save edx register
  140. ; mov eax,[randValue] ;Calculate
  141. ; mov edx,[randMult] ;R(n+1) :=
  142. ; mul edx ;(R(n)*MULT + CONST)
  143. ; add eax,[randConst] ;MOD MASK
  144. ; and eax,[randMask] ;in CPU register and
  145. ; mov dword[randValue],eax ;save back R(n+1)
  146. ; pop edx ;Restore edx regsiter
  147. ; fild dword[randValue] ;Normalize
  148. ; fidiv dword[randMask] ;to ONE in FPU
  149. ; ret ;Return
  150.  
  151. ;seedDoubleFunc:
  152. ; push edx ;Save edx register
  153. ; rdtsc ;Get real time clock
  154. ; and eax,[randMask] ;and mask it and
  155. ; mov dword[randValue],eax ;save back as R(n+1)
  156. ; pop edx ;Restore edx regsiter
  157. ; fild dword[randValue] ;Normalize
  158. ; fidiv dword[randMask] ;to ONE in FPU
  159. ; ret ;Return
  160.  
  161. ;write stuff to the file
  162. push 4
  163. pop eax
  164. mov ebx,dword[fd_out]
  165. push header
  166. pop ecx
  167. push header_s
  168. pop edx
  169. int $80
  170.  
  171. push 4
  172. pop eax
  173. mov ebx,dword[fd_out]
  174. push conten
  175. pop ecx
  176. push conten_s
  177. pop edx
  178. int $80
  179.  
  180. ;close it
  181. push 6
  182. pop eax
  183. mov ebx,dword[fd_out]
  184.  
  185. ;warn the user that the file was created
  186. push 4
  187. pop eax
  188. push 1
  189. pop ebx
  190. push done
  191. pop ecx
  192. push done_s
  193. pop edx
  194. int $80
  195.  
  196. ;quit
  197. push 1
  198. pop eax
  199. xor ebx,ebx
  200. int $80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement