Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 7th, 2006, 01:43 PM
megamanz megamanz is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 3 megamanz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 0
I need help with assembly code

i want to load an image from the dos command line: like LSB.exe image.bmp
here is the program source files (HERE THE LOADING OF THE IMAGE IS DONE BY OPEN WINDOW)
please help me i need to do command line execution of the program....
the LSB.asm saves the result image but i want it displayed in a window


please help i dont know any thing about assembly..

the code is the following
callW macro x
extrn x:PROC
call x
endm

.486
.model flat


;-------------- Data of the Program --------------

.data

;----------------- structures --------------------

openfilename_struct:
lStructSize dd openfilename_struct_size
hwndOwner dd 0
hInstance dd 0
lpstrFilter dd offset filter
lpstrCustomFilter dd 0
nMaxCustFilter dd 0
nFilterIndex dd 0
lpstrFile dd offset namebuffer
nMaxFile dd 255
lpstrFileTitle dd 0
nMaxFileTitle dd 32
lpstrInitialDir dd 0
lpstrTitle dd 0
Flags dd 1000h+4h+200000h
nFileOffset dw 0
nFileExtension dw 0
lpstrDefExt dd 0
lCustData dd 0
lpfnHook dd 0
lpTemplateName dd 0
openfilename_struct_size equ $-offset openfilename_struct

;------------- file/memory Essentials --------------------

filter db "Bmp files *.bmp",0,"*.bmp",0,0
namebuffer db 255 dup(0)
result_title db "BMP2LSB", 0
no_bmp db "This is not a Bitmap Image",0

file_handle2 dd ?
file_size dd ?
file_handle dd ?
file_mem_buffer dd ?
file_nb_bytes_read dd ?
pixels_data_start dd ?



;-------------- Code of the Program --------------
.code

program:

;-------- choose a file -------------

push offset openfilename_struct
callW GetOpenFileNameA
test eax, eax
jz end

;-------- open it --------------

push 0
push 80h
push 3
push 0
push 0
push 80000000h+40000000h
push dword ptr [lpstrFile]
callW CreateFileA
inc eax
jz end
dec eax
mov file_handle, eax

;---------- get its size ---------

push 0
push dword ptr file_handle
callW GetFileSize
inc eax
jz close_file
dec eax
mov file_size, eax

;--------- alloc memory for file --------

mov eax, file_size
add eax, 1024
push eax
push 40h
callW LocalAlloc
test eax, eax
jz close_file
mov file_mem_buffer, eax

;------- read entire file ------------

push 0
push offset file_nb_bytes_read
push file_size
push file_mem_buffer
push file_handle
callW ReadFile
test eax, eax
jz free_memory
mov eax, file_nb_bytes_read
cmp eax, file_size
jnz free_memory

;-------- find BMP signature in header ---------

mov esi, file_mem_buffer
lodsw
cmp ax, "MB"
jne trouble

;------- find number of bits per pixel ------

add esi, 8
lodsd
add eax, file_mem_buffer
mov pixels_data_start, eax
add esi, 14
lodsw
cmp ax, 24
je this_looks_like_a_bmp

;-------- not 24-bits BMP -----------

trouble:
push 0
push offset result_title
push offset no_bmp
push 0
callW MessageBoxA
jmp free_memory

;------ Enhance LSBs -----------

this_looks_like_a_bmp:

mov eax, pixels_data_start
sub eax, file_mem_buffer
mov ecx, file_size
sub ecx, eax

mov esi, pixels_data_start
mov edi, esi

change_all:
lodsb ;get byte
and al, 1 ;eliminate everything except LSB
jz no_fill ;if 0, do nothing
mov al, 0ffh ;if 1, replace by 255
no_fill:
stosb ;put the byte back
loop change_all

;------- add _LSB to the name ----------------

mov esi, offset namebuffer
mov ecx, 255

find_extension:
mov al, [esi+ecx]
cmp al, "."
je modify_name
loop find_extension

modify_name:
mov eax, "BSL_"
mov [esi+ecx], eax
mov eax, "pmb."
mov [esi+ecx+4], eax

;------- open a new file on the disk ----------------

push 0
push 80h
push 2
push 0
push 0
push 40000000h
push offset namebuffer
call CreateFileA
mov file_handle2, eax

;------- write buffer in it ----------------

push 0
push offset file_nb_bytes_read
push file_size
push file_mem_buffer
push file_handle2
callW WriteFile

;------- close it ----------------

push file_handle2
callW CloseHandle
jmp free_memory

;------- close memory ----------------

free_memory:
push file_mem_buffer
callW LocalFree

;-------- close file ----------

close_file:
push dword ptr file_handle
callW CloseHandle

;----------- exit ----------

end:
push -1
callW ExitProcess

end program

Reply With Quote
  #2  
Old March 8th, 2006, 07:45 AM
jafet jafet is offline
Redpill
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2005
Posts: 1,660 jafet User rank is First Lieutenant (10000 - 20000 Reputation Level)jafet User rank is First Lieutenant (10000 - 20000 Reputation Level)jafet User rank is First Lieutenant (10000 - 20000 Reputation Level)jafet User rank is First Lieutenant (10000 - 20000 Reputation Level)jafet User rank is First Lieutenant (10000 - 20000 Reputation Level)jafet User rank is First Lieutenant (10000 - 20000 Reputation Level)jafet User rank is First Lieutenant (10000 - 20000 Reputation Level)jafet User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 11 h 19 m 55 sec
Reputation Power: 150
Send a message via MSN to jafet
WTF are you doing with all this code if you don't know bupkis about ASM? I suggest you pick up a book and learn the basics before you ask any questions. If this is really urgent, go look for whoever dumped you this job and tell the person you know 0% of ASM.
Comments on this post
mvantuyl disagrees: That was uncalled for. If you don't have anything to contribute, at least avoid posting this
rubbish.
__________________
Code:
#include <stdio.h>
int main(int o,char**O){return o>-1?o-2||!main(-1,1+O)?!!fprintf(stderr,"%s [0-"
"9]{81}\n",*O):main(-83,++O):o>-83?(*O)[-1-o]?81==(o=-o-1)||o[*O]<'0'||'9'<o[*O]
?0:main(-2-o,O):o==-82:o>-164?(*O)[-83-o]<'1'?main(o-82,O):main(--o,O):o+164?o>-
246?(*O)[-165-o]<'1'?main(o-82,O):main(--o,O):o+246?o>-328?(*O)[o=-o-247]<='8'?(
main(-328-o,(++o[*O],O)),main(-247-o,O)):!(o[*O]='0'):(o=-o-328)<729?(o%9/3*3-o%
27+o/243*9+o/81%3&&(*O)[o%81]==(*O)[o%81-o%27+o%9/3*3+o/243*9+o/81%3])||(o%81-o%
9-o/81*9&&(*O)[o%81]==(*O)[o%9+o/81*9])||(o/81-o%9&&(*O)[o%81]==(*O)[o%81-o%9+o/
81])?0:main(-409-o,O):main(-165-o%81,O):!puts(*O):0                           ;}

Reply With Quote
  #3  
Old March 8th, 2006, 09:02 AM
megamanz megamanz is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 3 megamanz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 0
sorry but the coder email is not in use

this program is loading a 24-bit bitmap image and then extracts the LSB then it saves the result image in the same name of the loaded image with _LSB extention
the only thing i need is to load the image from the comand line like this LSB.exe image.bmp
and then displays the result image rather than saving it.

i need it badly because my project uses this command line feature...

sorry if i was annoying..
but if you can help me please do..
thanks

Reply With Quote
  #4  
Old March 8th, 2006, 09:10 AM
mvantuyl's Avatar
mvantuyl mvantuyl is offline
Walrus Gramps
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Aug 2005
Location: San Antonio, Texas
Posts: 1,229 mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 48973 Folding Title: Beginner FolderFolding Points: 48973 Folding Title: Beginner FolderFolding Points: 48973 Folding Title: Beginner Folder
Time spent in forums: 3 Weeks 4 Days 5 h 55 m 23 sec
Reputation Power: 618
Send a message via ICQ to mvantuyl
Sorry, I don't speak assembler, but this is the appropriate place to post such a question. Just ignore Jafet's sanctimonious proclamations.
Comments on this post
jafet agrees: Arrgh fine
__________________
All science is either physics or stamp collecting. - Ernest Rutherford

How To Ask Questions The Smart Way by Eric S. Raymond

Reply With Quote
  #5  
Old March 8th, 2006, 09:45 AM
LinuxPenguin's Avatar
LinuxPenguin LinuxPenguin is offline
fork while true;
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: May 2005
Location: England, UK
Posts: 5,538 LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)  Folding Points: 11590 Folding Title: Novice Folder
Time spent in forums: 1 Month 3 Weeks 1 Day 19 h 30 m 28 sec
Reputation Power: 1050
generating a window... that could be difficult in asm.

Assemble it with DJGPP (yes, it will eat ASM code...)

call it and then display the image, all from within a batch file.

Reply With Quote
  #6  
Old March 8th, 2006, 02:54 PM
megamanz megamanz is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 3 megamanz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 0
mvantuyl please give me the link

Reply With Quote
  #7  
Old March 8th, 2006, 03:09 PM
LinuxPenguin's Avatar
LinuxPenguin LinuxPenguin is offline
fork while true;
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: May 2005
Location: England, UK
Posts: 5,538 LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)  Folding Points: 11590 Folding Title: Novice Folder
Time spent in forums: 1 Month 3 Weeks 1 Day 19 h 30 m 28 sec
Reputation Power: 1050
There wasn't meant to be a link

Reply With Quote
  #8  
Old March 8th, 2006, 08:46 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,389 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 22 h 1 m 11 sec
Reputation Power: 4080
Is there a good reason that you want this done in assembler and not use a higher level language (say C++?) Note that the asm code is using a bunch of Windows API calls (GetFileNameA, CreateFileA etc.) and parsing the header from the file. You can easily write this in a high level language as well.
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > I need help with assembly code

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap