The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: xiahan on April 30, 2012, 03:28:43 AM

Title: subproc parameters deliver problem
Post by: xiahan on April 30, 2012, 03:28:43 AM
I'm construct a bmp viewer,but it seems there is little problem

the whole source code is at the attahment zip
Title: Re: subproc parameters deliver problem
Post by: dedndave on April 30, 2012, 04:01:37 AM
use LoadImage for a BMP file
http://msdn.microsoft.com/en-us/library/windows/desktop/ms648045%28v=vs.85%29.aspx
Title: Re: subproc parameters deliver problem
Post by: xiahan on May 01, 2012, 02:38:35 AM

invoke LoadImage,0,offset OutputString,IMAGE_BITMAP,0,0,LR_LOADFROMFILE


i was using LoadImage to load the bmp from a file

i have found my misunderstanding


invoke LoadBmp,addr width1,addr height1,addr size1,ofn.lpstrFile
...
LoadBmp proc pwidth,pheight,psize,pszfile
mov eax,bmpinfo.biHeight
mov [pheight],eax
LoadBmp endp


the instruction

mov [pheight],eax

is actually mov [ebp+12],eax
but originally i think it's somthing like this

mov [addr height1],eax

so i lost my self after i called the function but found the value of width1 was not changed

Title: Re: subproc parameters deliver problem
Post by: dedndave on May 01, 2012, 03:01:04 AM
are you using GoAsm ???
if you are using Masm...
        mov     pheight,eax

perhaps you are reading some [GoAsm] example code and assembling with Masm   :P
Title: Re: subproc parameters deliver problem
Post by: xiahan on May 01, 2012, 03:06:33 AM
thanks for the remind, i almost forget the convenient way  :green2

no i'm reading a C++ example ,the convert between C++ and masm sometimes make difficulty
Title: Re: subproc parameters deliver problem
Post by: nixeagle on May 01, 2012, 03:12:19 AM
An easy way to do that is to compile the C++ to an object file and disassemble that. With GCC you can compile your code with g++ code.cpp -c code.o and peek at the assembly result with objdump -dCr -Mintel code.o.

I'm sure there are equivalents using Microsoft's compiler ;).
Title: Re: subproc parameters deliver problem
Post by: xiahan on May 01, 2012, 03:18:30 AM
Quote from: nixeagle on May 01, 2012, 03:12:19 AM
An easy way to do that is to compile the C++ to an object file and disassemble that. With GCC you can compile your code with g++ code.cpp -c code.o and peek at the assembly result with objdump -dCr -Mintel code.o.

I'm sure there are equivalents using Microsoft's compiler ;).

good advice ! i will give a try :dance:
Title: Re: subproc parameters deliver problem
Post by: xiahan on May 01, 2012, 03:21:04 AM
Quote from: dedndave on May 01, 2012, 03:01:04 AM
are you using GoAsm ???
if you are using Masm...
        mov     pheight,eax

perhaps you are reading some [GoAsm] example code and assembling with Masm   :P

i recompile use

mov pwidth,eax

but it seems it has the same problem with

mov [pwidth],eax

ps: i'm using masm
Title: Re: subproc parameters deliver problem
Post by: dedndave on May 01, 2012, 04:26:13 AM
to get the size of the image after loading, i use GetObject...
        LOCAL   bms:BITMAP
;
;
        INVOKE  LoadImage........
;
;
        INVOKE  GetObject,hBitmap,sizeof BITMAP,addr bms
        mov     ecx,bms.bmWidth
        mov     edx,bms.bmHeight

;BITMAP      STRUCT
; bmType       dd ?
; bmWidth      dd ?
; bmHeight     dd ?
; bmWidthBytes dd ?
; bmPlanes     dw ?
; bmBitsPixel  dw ?
; bmBits       dd ?


to understand the problem you are having with pheight/pwidth, we would need to see more of the code   :P
offhand, it sounds like pheight and pwidth may be pointers - not the variables, themselves - thus the 'p'
try this...
        mov     edx,pheight
        mov     [edx],eax
Title: Re: subproc parameters deliver problem
Post by: xiahan on May 02, 2012, 12:54:04 AM


mov ebx,bmpinfo.biWidth
mov eax,pwidth
mov [eax],ebx
mov ebx,bmpinfo.biHeight
mov eax,pheight
mov [eax],ebx
mov ebx,bmpheader.bfSize
sub ebx,bmpheader.bfOffBits
mov eax,psize
mov [eax],ebx

it works!
Title: Re: subproc parameters deliver problem
Post by: dedndave on May 02, 2012, 03:29:32 AM
 :U

:bg