News:

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

conflicting parameter definition

Started by Magnum, December 08, 2011, 09:08:50 PM

Previous topic - Next topic

Magnum

This line bin2hex  proc gives this ->
C:\masm32\SOURCE\value.asm(76) : error A2111:conflicting parameter definition


; value.asm   
;           String length CAN'T exceed 255 chars and MUST be evenly
;           divisable by 2   
;

.686                                     
.model flat, stdcall                     
option casemap :none                       

include \masm32\include\windows.inc   
include \masm32\include\masm32.inc     

include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\Comctl32.inc
include \masm32\include\comdlg32.inc
include \masm32\include\shell32.inc
include \masm32\include\oleaut32.inc
include \masm32\include\ole32.inc
include \masm32\include\msvcrt.inc
include \masm32\include\winmm.inc
include \masm32\include\advapi32.inc

include \masm32\include\dialogs.inc   
include \masm32\macros\macros.asm     

includelib \masm32\lib\masm32.lib     

includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\Comctl32.lib
includelib \masm32\lib\comdlg32.lib
includelib \masm32\lib\shell32.lib
includelib \masm32\lib\oleaut32.lib
includelib \masm32\lib\ole32.lib
includelib \masm32\lib\msvcrt.lib
includelib \masm32\lib\winmm.lib
includelib \masm32\lib\advapi32.lib

.data
   
    DETA_it        db    "Not so fast !" ; 38 chars in this string
    count          dw    $ - DETA_it ; length of string
   
.code

begin:
     
     mov      ax,count    ; move count value in prep for division
     cmp      ax,255      ; code doesn't work with these 2 lines 
     
     call     bin2hex     ; print hex value of string length
     
     xor cx,cx
     mov ax,count    ; move count value in prep for division

     mov dl,2
     div dl          ; al contains result, ah has remainder
     
     xor cx,cx
     mov cl,al       ; limits string to 255 chars max !!
                   
     mov esi, offset [DETA_it]  ; address of start-of-strings
     xor ax, ax

more:
     xor ax, [esi]    ; simple xor of string
     inc si
     inc si
     dec cx
     jnz more      ; ax now contains calculated string value

bin2hex  proc   

;Convert AX to HEX ASCII output

bin2he: mov     cx,4                    ;4 hex digits
        mov     bx,10h                  ;divisor
bin2h1: xor     dx,dx                   ;zero DX for 16 bit divide
        div     bx                      ;leaves quotient in AX
        add     dl,'0'                  ;convert remainder to ASCII
        cmp     dl,'9'
        jna     bin2h2
        add     dl,'A'-'9'-1
bin2h2: push    dx                      ;put on stack
        loop    bin2h1                  ;repeat
        mov     cx,4
bin2h3: pop     ax                      ;pop most significant digit first
        mov     dl,al
        mov     ah,02h
        int     21h
        loop    bin2h3
        ret
bin2hex endp

end begin
Have a great day,
                         Andy

dedndave

try changing the name of bin2hex
the masm32 package has a routine with that name that has 3 dword parameters

qWord

why are you specifying the flat model, while obviously writing 16Bit code? For me this also looks like a conflict definition  :bg
FPU in a trice: SmplMath
It's that simple!

Magnum

Dave,

I changed the proc name and it assembles O.K.

I put in an int 3 after jnz more, but the debugger won't stop there.

I want to see what the value that is in EAX.

I have some 16 bit code that xors a string to calculate a value that I converted to 32 bit,
but for some reason the value that is generated is not the same.


start:

     xor cx,cx
     mov ax,count    ; move count value in prep for division
     mov dl,2
     div dl          ; al contains result
     xor cx,cx
     mov cx,ax
                   
     mov esi, offset [DETA_it]  ; address of start-of-strings
     xor ax, ax
more:

     xor ax, [esi]
     inc si
     inc si
     dec cx
     jnz more
     cmp eax, [value]      ; previously calc'd value of string
     


Have a great day,
                         Andy

dedndave

well - you should completely convert it to 32-bit code
on a 32-bit processor, each time you use word-sized operands, a size override prefix byte is added to the instruction
this is not only larger, but probably slower, too

at any rate, the value in the upper word of these registers may be the reason things are not happening as desired
one thing that i see that is particularly scary...
     xor ax, [esi]
     inc si
     inc si

if the address wraps a 64 k boundry, you will have serious problems
that may not be likely in smaller programs
but if the code is later used in a larger program - bang !

even so, INC ESI is a single-byte instruction
in a 32-bit program, INC SI is 2 bytes

the divide instruction is also of particular interest, as it does not function exactly the same as it did in 16-bit world   :P
i would recommend using dword division of EDX:EAX
the resulting quotient will be in EAX and the remainder will be in EDX

also, if you want to load unsigned word or byte values into a dword register, use MOVZX
if you want to load signed word or byte values into a dword register, use MOVSX

try to avoid using word-size registers in 32-bit code as a general rule
sometimes, it cannot be avoided, of course

Magnum

I think I found one problem.

The Dos interrupt. :-)

I am surprised that masm didn't complain.



bin2h3:
        pop     eax                      ;pop most significant digit first
        mov     dl,al
        mov     ah,02h
        int     21h
        loop    bin2h3
        ret

Have a great day,
                         Andy

Magnum

I will have to dump my code and start from scratch.

I need a routine to xor a string and generate a unique value.

I would use that string in a prog and use the same routine to verify that the string has not changed.

I hope that makes sense.


Have a great day,
                         Andy