Page 1 of 1

Help needed with assembler code..

Posted: Fri Jul 30, 2004 3:50 pm
by Claes
Can anyone help make the below code work?

Code: Select all

function MakeWord(L, H: Byte): Word;
{ macro creates a word from low and high bytes }
inline(
  $5A/            { pop dx }
  $58/            { pop ax }
  $8A/$E2);       { mov ah, dl }
It seems that Delphi no longer understand "inline"...? Anyhow I'm no assembler guy AT ALL, so I can't make it work...

The function is taken from the library SendKeys that I found somewhere on the net, and the code is part of Delphi Developers Guide by Steve Teixeira

Posted: Fri Jul 30, 2004 3:52 pm
by Claes
Will this work?

Code: Select all

function MakeWord(L,H: Byte): Word;
begin
  MakeWord := (H shl 8) + L;
end;

Posted: Fri Jul 30, 2004 5:30 pm
by nildo

Code: Select all

function MakeWord(L, H: Byte): Word; 
{ macro creates a word from low and high bytes } 
begin
   asm 
      pop dx
      pop ax
      mov ah, dl
   end;
end;
?

Posted: Sat Jul 31, 2004 10:02 am
by madshi
Is this still 16bit code? In Delphi you usually use "asm" instead of "inline", it's much nicer anyway.

But I'd do it like this:

Code: Select all

function MakeWord(L, H: Byte) : Word;
begin
  result := Word(H) shl 8 + L;
end;

Posted: Sun Aug 01, 2004 4:11 pm
by Claes
Thanks, guys! ;)