News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

subproc parameters deliver problem

Started by xiahan, April 30, 2012, 03:28:43 AM

Previous topic - Next topic

xiahan

I'm construct a bmp viewer,but it seems there is little problem

the whole source code is at the attahment zip


xiahan


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


dedndave

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

xiahan

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

nixeagle

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 ;).

xiahan

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:

xiahan

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

dedndave

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

xiahan



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!