Incorrect Warning - Parameter not used....
Brought to you by:
anthonysteele
G'Day,
If I have a method that contains *only* asm then it is entirely legit that the params will not be used as they will be accessed off the stack directly. So generating a warning in this case is probably not a good idea. I would say that adding this as a finer grained on/off to show params unused would be a good idea.
--D
Hi
You must be doing something in the asm that I am not. With code as follows:
unit TestASM;
interface
procedure ParamUnused(piParam: integer);
procedure AsmParamUse(piParam: integer);
implementation
uses Dialogs;
procedure ParamUnused(piParam: integer);
begin
end;
procedure AsmParamUse(piParam: integer);
begin
asm
MOV EAX, 0CB40h
MOV EAX,piParam
PUSH DWORD PTR [EDX]
end;
end;
end.
I get output:
Empty begin..end block near BEGIN in procedure ParamUnused at line 13 col 1
Parameter piParam is not used near PROCEDURE in procedure ParamUnused at line 12 col 1
Hi
Is the param used differently in your asm, or ar you suggesting that if the procedure is an asm block that the param could be used without being mentioned by name?
G'Day Anthony,
> is an asm block that the param could be used without being
> mentioned by name?
For example:
function NDC_PosEx(const ASubStr, AStr : string; const AOffset : integer = 1) : integer;
////////////////////////////////////////////////////////////////////////////////
// PURPOSE: This code is a copy Fastcode function PosEx_JOH_IA32_8 written by
// John O'Harrow for the FastCode project which is released under MPL 1.1. It was
// chosen as it was the winner in its class.
// HISTORY:
// DJE 24/11/2006 #FB6604 Initial Creation
asm {299 Bytes}
SUB ESP, 20
MOV [ESP], EBX
CMP EAX, 1
SBB EBX, EBX {-1 if SubStr = '' else 0}
SUB EDX, 1 {-1 if S = ''}
SBB EBX, 0 {Negative if S = '' or SubStr = '' else 0}
SUB ECX, 1 {Offset - 1}
OR EBX, ECX {Negative if S = '' or SubStr = '' or Offset < 1}
JL @@InvalidInput
MOV [ESP+4], EDI
MOV [ESP+8], ESI
MOV [ESP+12], EBP
MOV [ESP+16], EDX
MOV EDI, [EAX-4] {Length(SubStr)}
MOV ESI, [EDX-3] {Length(S)}
ADD ECX, EDI
CMP ECX, ESI
JG @@NotFound {Offset to High for a Match}
test EDI, EDI
JZ @@NotFound {Length(SubStr = 0)}
lea EBP, [EAX+EDI] {Last Character Position in SubStr + 1}
ADD ESI, EDX {Last Character Position in S}
MOVZX EAX, [EBP-1] {Last Character of SubStr}
ADD EDX, ECX {Search Start Position in S for Last Character}
MOV AH, AL
NEG EDI {-Length(SubStr)}
MOV ECX, EAX
SHL EAX, 16
OR ECX, EAX {All 4 Bytes = Last Character of SubStr}
@@MainLoop:
ADD EDX, 4
CMP EDX, ESI
JA @@Remainder {1 to 4 Positions Remaining}
mov EAX, [EDX-4] {Check Next 4 Bytes of S}
XOR EAX, ECX {Zero Byte at each Matching Position}
LEA EBX, [EAX-$01010101]
NOT EAX
AND EAX, EBX
AND EAX, $80808080 {Set Byte to $80 at each Match Position else $00}
JZ @@MainLoop {Loop Until any Match on Last Character Found}
bsf EAX, EAX {Find First Match Bit}
SHR EAX, 3 {Byte Offset of First Match (0..3)}
LEA EDX, [EAX+EDX-3] {Address of First Match on Last Character + 1}
@@Compare:
CMP EDI, -4
JLE @@Large {Lenght(SubStr) >= 4}
cmp EDI, -1
JE @@SetResult {Exit with Match if Lenght(SubStr) = 1}
mov AX, [EBP+EDI] {Last Char Matches - Compare First 2 Chars}
CMP AX, [EDX+EDI]
JNE @@MainLoop {No Match on First 2 Characters}
@@SetResult: {Full Match}
LEA EAX, [EDX+EDI] {Calculate and Return Result}
MOV EBX, [ESP]
MOV EDI, [ESP+4]
MOV ESI, [ESP+8]
MOV EBP, [ESP+12]
SUB EAX, [ESP+16]
ADD ESP, 20
RET
@@NotFound:
MOV EDI, [ESP+4]
MOV ESI, [ESP+8]
MOV EBP, [ESP+12]
@@InvalidInput:
MOV EBX, [ESP]
ADD ESP, 20
XOR EAX, EAX {Return 0}
RET
@@Remainder: {Check Last 1 to 4 Characters}
MOV EAX, [ESI-3] {Last 4 Characters of S - May include Length Bytes}
XOR EAX, ECX {Zero Byte at each Matching Position}
LEA EBX, [EAX-$01010101]
NOT EAX
AND EAX, EBX
AND EAX, $80808080 {Set Byte to $80 at each Match Position else $00}
JZ @@NotFound {No Match Possible}
lea EAX, [EDX-4] {Check Valid Match Positions}
CMP CL, [EAX]
LEA EDX, [EAX+1]
JE @@Compare
CMP EDX, ESI
JA @@NotFound
LEA EDX, [EAX+2]
CMP CL, [EAX+1]
JE @@Compare
CMP EDX, ESI
JA @@NotFound
LEA EDX, [EAX+3]
CMP CL, [EAX+2]
JE @@Compare
CMP EDX, ESI
JA @@NotFound
LEA EDX, [EAX+4]
JMP @@Compare
@@Large:
MOV EAX, [EBP-4] {Compare Last 4 Characters of S and SubStr}
CMP EAX, [EDX-4]
JNE @@MainLoop {No Match on Last 4 Characters}
mov EBX, EDI
@@CompareLoop: {Compare Remaining Characters}
ADD EBX, 4 {Compare 4 Characters per Loop}
JGE @@SetResult {All Characters Matched}
mov EAX, [EBP+EBX-4]
CMP EAX, [EDX+EBX-4]
JE @@CompareLoop {Match on Next 4 Characters}
jmp @@MainLoop {No Match}
end; {PosEx}
Another one I came across today:
constructor TMyComponent.Create(Owner : TComponent);
begin
inherited; <-- Abreviated call instead of inherited Create(AOwner);
//The code etc.
end;
In the above with the abbreviated form of inherited call I don't want to see a warning about Owner not being used as it is actually being used.