 
View Full Version : Help on Delphi>-<ASM Combo
ON'error
December 12th, 2001, 11:48
...
var
  Form1: TForm1;
  First,Second,Final: Variant;
...
procedure TForm1.Button1Click(Sender: TObject);
begin
     asm
  	mov     eax, 2
        mov     ebx, 6
  	add     eax, ebx
        mov     Final, ebx
     end;
     edit3.text:=inttostr(Final);
end;
end.
hi,
i dont know, why my pc tells me that the operand size(!translationPROBLEM)is not the same.
If noone can help me or dont want to, then youve got a tutorURL maybe.
thx anyway
Js
December 12th, 2001, 14:06
Hiya,
Tried to send you a pm but it says I'm not logged in 

  so I have sent an email, (maybe) . 

stealthFIGHTER
December 12th, 2001, 14:59
Hi,
try to declare the variations as Cardinal (or LongInt) and not as Variant.
Btw. I think, that the code is so easy that you don't need to use asm:
EAX := 2;
EBX := 6;
EAX := EAX + EBX;
Final := EAX;
Edit3.Text := IntToStr(Final);
or
EAX := 2;
EBX := 6;
EBX := EBX + EAX;
Final := EBX;
Edit3.Text := IntToStr(Final);
or in ASM
asm
mov eax, 2
mov ebx, 6
add ebx, eax
mov Final, ebx
end;
Edit3.Text := IntToStr(Final);
(btw. in your example the value in Final will be '6' (as it is the value that is moved from EBX) because you typed add eax, ebx. If you want to add eax to ebx you must type add ebx, eax. Then the value in Final will be '8'.
sF
ON'error
December 12th, 2001, 15:29
hi, 1st thx for ur reply but i know that i can add 6 and 2 in another way. But i want to use asm in 32bit, else i have to prog an exclusiveOr or a shiftLeft function to use them in VB. And win32asm isnt an option 4 me, cause im very lazy. I just have some problems to understand pascalsyntax and the compiler-messages. what means "Operamds size isnt the same"@mov Final, ebx.
stealthFIGHTER
December 12th, 2001, 17:16
Hi,
what version of compiler do you use? Have you tried to look into Help? I've found this (I think this can be the solution):
=============== Paste from Help ===============
Error: Operand size mismatch 
Description
The size required by the instruction operand does not match the size given.
In the sample above, the compiler will complain because the 'offset' operator produces a 'dword', but the operator is expecting a 'byte'. 
program Produce;
  var
    v : Integer;
  procedure Assembly;
  asm
    db offset v
  end;
begin
end.
======================================== 
The solution, for this example, is to change the operator to receive a 'dword'. In the general case you will need to closely examine your code and ensure the the operator and operand sizes match. 
program Solve;
  var
    v : Integer;
  procedure Assembly;
  asm
    dd offset v
  end;
begin
end.
=============== Paste from Help ===============
I think this is clear. Btw. have you tried to declare the vars. as Integer or Cardinal?
sF
ON'error
December 13th, 2001, 07:29
ive made a huge mistake, but its fixed. When ive compiled the program and click on my button a message pops up with EAccesViolation blabla cant read FFFFFFF or something like this. and now the line: edit3.text:=inttostr(Final); is highlighted.
to quit this thread could somebody send me a code which uses asm in delphi? thx a lot
stealthFIGHTER
December 13th, 2001, 14:57
Hello,
try my tutorial #44; (how to make a kg for ... using delphi + asm) or look at this:
*******************************************
var  ECXINT, ESIINT, EAXINT : Cardinal;
asm 
    mov eax, eaxint
    mov ecx, ecxint
    mov esi, esiint
    mov esi, eax
    xor esi, ecx
    test esi, $321952
    jz @yes
    add eax, eax
    xor eax, $13218
    shl ecx, $2
    jmp @end
@yes:
    shl eax, $4
    shl ecx, $3
@end:
    mov esiint, esi
    mov eaxint, eax
    mov ecxint, ecx
end;
*******************************************
I hope it helps you a bit 
 
sF
Powered by vBulletin® Version 4.2.2 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.