L
luyear
Unregistered / Unconfirmed
GUEST, unregistred user!
20號是小妹kelly的生日,請大家幫忙發生日卡給她
發者有分。
幾個不錯的ASM delphi函數供參考
function Min(X,Y : integer) : integer;
assembler;
asm
mov ax,X
cmp ax,Y
jle @@1
mov ax,Y
@@1:
end;
{ Min }
function Max(X,Y : integer) : integer;
assembler;
asm
mov ax,X
cmp ax,Y
jge @@1
mov ax,Y
@@1:
end;
{ Max }
function LongMin(A,B : longint) : longint;
assembler;
asm
mov ax, word ptr [A]
mov dx, word ptr [A+2]
mov bx, word ptr
mov cx, word ptr [B+2]
cmp dx,cx
jl @@1
jg @@2
cmp ax,bx
jbe @@1
@@2:
mov ax,bx
mov dx,cx
@@1:
end;
{ LongMin }
function LongMax(A,B : longint) : longint;
assembler;
asm
mov ax, word ptr [A]
mov dx, word ptr [A+2]
mov bx, word ptr
mov cx, word ptr [B+2]
cmp dx,cx
jg @@1
jl @@2
cmp ax,bx
jae @@1
@@2:
mov ax,bx
mov dx,cx
@@1:
end;
{ LongMax }
function InRange(V,A,B : integer) : boolean;
assembler;
asm
mov ax,V
cmp ax,A
jl @1
cmp ax,B
jg @1
mov ax,1
jmp @2
@1:
xor ax,ax
@2:
end;
{ InRange }
function OutRange(V,A,B : integer) : boolean;
assembler;
asm
mov ax,V
cmp ax,A
jl @1
cmp ax,B
jg @1
xor ax,ax
jmp @2
@1:
mov ax,1
@2:
end;
{ OutRange }
function LongInRange(V,A,B : longint) : boolean;
begin
LongInRange := (V >= A) and (V <= B);
end;
{ LongInRange }
function LongOutRange(V,A,B : longint) : boolean;
begin
LongOutRange := (V < A) or (V > B);
end;
{ LongOutRange }
function LongToInt(V : longint) : integer;
begin
if V < -MaxInt then
LongToInt := -MaxInt
else
if V > MaxInt then
LongToInt := MaxInt
else
LongToInt := V;
end;
{ LongToInt }
function IntToShort(V : integer) : shortint;
begin
if V > 127 then
IntToShort := 127
else
if V < -128 then
IntToShort := -128
else
IntToShort := V;
end;
{ IntToShort }
function CompToLongInt(V : Comp):longint;
var
s : string[20];
l : longint;
e : integer;
begin
if V > MaxLongInt then
l := MaxLongInt
else
if V < -MaxLongInt then
l := -MaxLongInt
else
begin
Str(V:20:0, S);
val(s, l, e);
end;
CompToLongInt := l;
end;
{ CompToLongInt }
function CompToInt(V : Comp):integer;
var
s : string[20];
i, e : integer;
begin
if V > MaxInt then
i := MaxInt
else
if V < -MaxInt then
i := -MaxInt
else
begin
Str(V:20:0, S);
val(s, i, e);
end;
CompToInt := i;
end;
{ CompToInt }
end.
{ unit Arit }
發者有分。
幾個不錯的ASM delphi函數供參考
function Min(X,Y : integer) : integer;
assembler;
asm
mov ax,X
cmp ax,Y
jle @@1
mov ax,Y
@@1:
end;
{ Min }
function Max(X,Y : integer) : integer;
assembler;
asm
mov ax,X
cmp ax,Y
jge @@1
mov ax,Y
@@1:
end;
{ Max }
function LongMin(A,B : longint) : longint;
assembler;
asm
mov ax, word ptr [A]
mov dx, word ptr [A+2]
mov bx, word ptr
mov cx, word ptr [B+2]
cmp dx,cx
jl @@1
jg @@2
cmp ax,bx
jbe @@1
@@2:
mov ax,bx
mov dx,cx
@@1:
end;
{ LongMin }
function LongMax(A,B : longint) : longint;
assembler;
asm
mov ax, word ptr [A]
mov dx, word ptr [A+2]
mov bx, word ptr
mov cx, word ptr [B+2]
cmp dx,cx
jg @@1
jl @@2
cmp ax,bx
jae @@1
@@2:
mov ax,bx
mov dx,cx
@@1:
end;
{ LongMax }
function InRange(V,A,B : integer) : boolean;
assembler;
asm
mov ax,V
cmp ax,A
jl @1
cmp ax,B
jg @1
mov ax,1
jmp @2
@1:
xor ax,ax
@2:
end;
{ InRange }
function OutRange(V,A,B : integer) : boolean;
assembler;
asm
mov ax,V
cmp ax,A
jl @1
cmp ax,B
jg @1
xor ax,ax
jmp @2
@1:
mov ax,1
@2:
end;
{ OutRange }
function LongInRange(V,A,B : longint) : boolean;
begin
LongInRange := (V >= A) and (V <= B);
end;
{ LongInRange }
function LongOutRange(V,A,B : longint) : boolean;
begin
LongOutRange := (V < A) or (V > B);
end;
{ LongOutRange }
function LongToInt(V : longint) : integer;
begin
if V < -MaxInt then
LongToInt := -MaxInt
else
if V > MaxInt then
LongToInt := MaxInt
else
LongToInt := V;
end;
{ LongToInt }
function IntToShort(V : integer) : shortint;
begin
if V > 127 then
IntToShort := 127
else
if V < -128 then
IntToShort := -128
else
IntToShort := V;
end;
{ IntToShort }
function CompToLongInt(V : Comp):longint;
var
s : string[20];
l : longint;
e : integer;
begin
if V > MaxLongInt then
l := MaxLongInt
else
if V < -MaxLongInt then
l := -MaxLongInt
else
begin
Str(V:20:0, S);
val(s, l, e);
end;
CompToLongInt := l;
end;
{ CompToLongInt }
function CompToInt(V : Comp):integer;
var
s : string[20];
i, e : integer;
begin
if V > MaxInt then
i := MaxInt
else
if V < -MaxInt then
i := -MaxInt
else
begin
Str(V:20:0, S);
val(s, i, e);
end;
CompToInt := i;
end;
{ CompToInt }
end.
{ unit Arit }