News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

why does this give me an error ?

Started by hfheatherfox07, January 31, 2013, 08:22:19 PM

Previous topic - Next topic

hfheatherfox07

lol I know about CL there is also another batch file that sets the paths ...
I think this is it http://www.opensource.apple.com/source/awk/awk-18/src/vcvars32.bat

I can never get it to work .....
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

MichaelW

This is what I used for the above, but note that it depends on your having an appropriate PSDK installed:

set file="test"
set PATH=C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin;%PATH%
set INCLUDE=C:\Program Files\Microsoft SDK\include;C:\Program Files\Microsoft Visual C++ Toolkit 2003\include;%INCLUDE%
set LIB=C:\Program Files\Microsoft SDK\lib;C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib;%LIB%

cl /W4 /Fa %file%.c

: cl /W4 /O2 /G6 /FA %file%.c

: cl /W4 %file%.c /link advapi32.lib

pause


Dave,

FWIW, the FreeBASIC developers see Microsoft's version as the mistake, renaming it in wingdi.bi to BGR:

#define BGR(r,g,b) (cuint(r) or (cuint(g) shl 8) or (cuint(b) shl 16))

Well Microsoft, here's another nice mess you've gotten us into.

hfheatherfox07

Quote from: dedndave on February 01, 2013, 08:25:09 AM
no - you can use RGB
you will have to change the PROTO
and - you will have to change everyplace this function is used to pass an RGB

dib_PutPixel proc x:DWORD, y:DWORD, crRGB:COLORREF
                mov   ecx,x
                mov   ebx,ScreenWidth
mov   eax,y
                .if (ecx<ebx)&&(eax<ScreenHeight)
    imul  eax,ebx
                    add   eax,ecx
                    mov   ebx,crRGB
                    mov   ecx,lpCanvasBuffer
    mov   [ecx+eax*4],ebx
                .endif
ret
dib_PutPixel endp


if you have the colors as individual bytes in memory, you can use the RGB macro
otherwise, you can assign them as EQUates or something
COLORREF = 65536*Red + 256*Green + Blue
where Red, Green, and Blue are 0 to 255

How can I make this Proto work ?
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

hfheatherfox07

@MichaelW
Thanks That bat Worked Geart  :biggrin:

Here is a working link for:  The Microsoft Visual C++ Toolkit 2003 If anybody wants it

http://kael.civfanatics.net/files/VCToolkitSetup.exe

And: Microsoft Platform SDK. For the windows.h and other includes and library's

http://kael.civfanatics.net/files/PSDK-x86.exe

HelloWorld.C

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
void main()
{
    printf("Hello world!\n");

      getch();
}
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

dedndave

QuoteHow can I make this Proto work ?

well - that source is a bit of a mess - lol
some functions don't have a PROC
i didn't find any prototypes

but - if you declare a PROC before it is invoked, PROTO is not required
so - it does assemble and work
it would be much cleaner if all PROC's that have parameters were prototyped
prototypes typically go near the beginning of the source file, after the normal include/includelib's

speaking of which - the preamble is defined in both the asm source and the inc file
it should only appear in one or the other

as Michael mentioned, these are not COLORREF values, they are RGBQUAD's
however, COLORREF's are DWORDS, RGBQUAD's are 4-byte structures

i would change the PROC to look something like this
dib_PutPixel proc x:DWORD, y:DWORD, rgbColor:DWORD

then, near the beginning of the source, a prototype would be...
dib_PutPixel PROTO :DWORD, :DWORD, :DWORD

hfheatherfox07

Quote from: dedndave on February 03, 2013, 12:35:39 AM
QuoteHow can I make this Proto work ?

as Michael mentioned, these are not COLORREF values, they are RGBQUAD's
however, COLORREF's are DWORDS, RGBQUAD's are 4-byte structures


Woops ....
I miss that .... I read it but did not quite understand that... I do now
I will stick to that first example that was converted to asm....
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

jj2007

Quote from: dedndave on February 03, 2013, 12:35:39 AMthese are not COLORREF values, they are RGBQUAD's
however, COLORREF's are DWORDS, RGBQUAD's are 4-byte structures

I hear one senior assembler expert say "everything is a DWORD". Even 4-byte structures :biggrin:

dedndave

i suppose the assembler will let you pass a structure as an atomic parameter
i have never tried it   :P

i have already reached my quota of new things to try, this week - lol

jj2007

Quote from: dedndave on February 03, 2013, 08:45:34 AM
i suppose the assembler will let you pass a structure as an atomic parameter

What do you mean with "atomic parameter"? Something like this?

include \masm32\include\masm32rt.inc

.code
rq   RGBQUAD <12h, 34h, 56h, 78h>

testrc proc rcPar:RGBQUAD
  movzx eax, rcPar.rgbRed
  print hex$(eax), 9, "red", 13, 10
  movzx eax, rcPar.rgbGreen
  print hex$(eax), 9, "green", 13, 10
  movzx eax, rcPar.rgbBlue
  print hex$(eax), 9, "blue", 13, 10, 10
  ret
testrc endp 

start:
   invoke testrc, rq
   ; invoke testrc, 78563412h   ; works with JWasm but not with ML
   inkey "bye"
   exit

end start

dedndave

Quoteworks with JWasm but not with ML

yes, that's exactly what i meant
maybe a misuse of terminology   :P

i could probably force it to work with ASSUME or something - not worth the effort

dedndave

maybe like this ?
        ASSUME  EDX:RGBQUAD
        invoke  testrc, edx
        ASSUME  EDX:Nothing


maybe this ?
        invoke  testrc, RGBQUAD ptr 78563412h
that doesn't seem right - lol

jj2007

Quote from: dedndave on February 03, 2013, 09:06:18 AM
i could probably force it to work with ASSUME or something - not worth the effort

   invoke testrc, rq

   mov eax, offset rq
   invoke testrc, RGBQUAD ptr [eax]

   push 78563412h
   invoke testrc, RGBQUAD ptr [esp]

   mov eax, offset rq
   assume eax:PTR RGBQUAD
   invoke testrc, [eax]

All four variants work for ML and JWasm.

dedndave

how about
        invoke  testrc, RGBQUAD ptr <12h,34h,56h,0>

i was trying to see how you'd do it with an immediate

MichaelW

In my test ML 6.15 had problems passing an RGBTRIPLE structure, but I think this could be due entirely to a longstanding bug with passing bytes on the stack. All of the other structures I tested could be accessed from the receiving procedure, so I assume they were passed correctly. I didn't have time for this, but it would be interesting to see if it can handle a very long structure with embedded structures, something like ENHMETAHEADER or DEVMODE.

;==============================================================================
include \masm32\include\masm32rt.inc
;==============================================================================

.data
    rgbt  RGBTRIPLE   <1,2,3>
    align 4
    aceh  ACE_HEADER  <1,2,3>
    acl   ACL         <1,2,3,4,5>
    align 4
    rgbq  RGBQUAD     <1,2,3,4>
    rectl RECTL       <1,2,3,4>
    bm    BITMAP      <1,2,3,4,5,6,7>

.code
;==============================================================================
Proc1 proc arg:RGBTRIPLE
    printf("(%d)\t", SIZEOF arg)
    movzx eax, arg.rgbtBlue
    printf("%d\t", eax)
    movzx eax, arg.rgbtGreen
    printf("%d\t", eax)
    movzx eax, arg.rgbtRed
    printf("%d\n", eax)
    ret
Proc1 endp

Proc2 proc arg:ACE_HEADER
    printf("(%d)\t", SIZEOF arg)
    movzx eax, arg.AceType
    printf("%d\t", eax)
    movzx eax, arg.AceFlags
    printf("%d\t", eax)
    movzx eax, arg.AceSize
    printf("%d\n", eax)
    ret
Proc2 endp

Proc3 proc arg:ACL
    printf("(%d)\t", SIZEOF arg)
    movzx eax, arg.AclRevision
    printf("%d\t", eax)
    movzx eax, arg.Sbz1
    printf("%d\t", eax)
    movzx eax, arg.AclSize
    printf("%d\t", eax)
    movzx eax, arg.AceCount
    printf("%d\t", eax)
    movzx eax, arg.Sbz2
    printf("%d\n", eax)
    ret
Proc3 endp

Proc4 proc arg:RGBQUAD
    printf("(%d)\t", SIZEOF arg)
    movzx eax, arg.rgbBlue
    printf("%d\t", eax)
    movzx eax, arg.rgbGreen
    printf("%d\t", eax)
    movzx eax, arg.rgbRed
    printf("%d\t", eax)
    movzx eax, arg.rgbReserved
    printf("%d\n", eax)
    ret
Proc4 endp

Proc5 proc arg:RECTL
    printf("(%d)\t", SIZEOF arg)
    printf("%d\t", arg.left)
    printf("%d\t", arg.top)
    printf("%d\t", arg.right)
    printf("%d\n", arg.bottom)
    ret
Proc5 endp

Proc6 proc arg:BITMAP
    printf("(%d)\t", SIZEOF arg)
    printf("%d\t", arg.bmType)
    printf("%d\t", arg.bmWidth)
    printf("%d\t", arg.bmHeight)
    printf("%d\t", arg.bmWidthBytes)
    movzx eax, arg.bmPlanes
    printf("%d\t", eax)
    movzx eax, arg.bmBitsPixel
    printf("%d\t", eax)
    printf("%d\n\n", arg.bmBits)
    ret
Proc6 endp

;==============================================================================
start:
;==============================================================================
    invoke Proc1, rgbt
    invoke Proc2, aceh
    invoke Proc3, acl
    invoke Proc4, rgbq
    invoke Proc5, rectl
    invoke Proc6, bm

    inkey
    exit
;==============================================================================
end start


(3)     3       0       3
(4)     1       2       3
(8)     1       2       3       4       5
(4)     1       2       3       4
(16)    1       2       3       4
(24)    1       2       3       4       5       6       7



Well Microsoft, here's another nice mess you've gotten us into.

dedndave

yah - but those are all memory operands
and, Jochen showed us how with registers

what about passing an immediate dword as a complete structure ?