Quote
tom.mert...@student.kuleuven.ac.be (Tom Mertens) wrote:
>Should I do this with some CMP xx, yy and JZ instructions, or is there a more easy way?
>BTW, how can I work with Longint in BASM?
>Ciao!
This Pascal-style case construction
case Value of
0: ..;
1: ..;
2: ..;
else ..;
end;
can be written in assembler like this:
ASM Mov Al, Value
@Case0: Cmp Al, 0
Jne @Case1
{ code }
Jmp @EndOfCase
@Case1: Cmp Al, 1
Jne @CaseA
{ code }
Jmp @EndOfCase
@CaseA: Cmp Al, 'A'
Jne @Else
{ code }
Jmp @EndOfCase
@Else: { code }
@EndOfCase:
END;
If 'Value' is not a Byte, but a Word (or Integer), use 'Ax' instead of 'Al'.
If you want to use LongInt's, you have to insert an $66 before each 32-bit
instruction, eg
'Db 66h; Mov Ax,Bx' is equal to 'Mov eAx,eBx'
'Db 66h; Mov Ax,Value' is equal to 'Mov eAx,Value'
Note that you can't use immediates in this way:
'Db 66h; Mov Ax, 7' is NOT equal to 'Mov eAx,7'
Because the left instruction creates a 16-bit number where a 32-bit number is
required.
What you can do to use LongInt's in a Cmp-statement is defining a constant:
const CmpEAX = $3d66;
and then instead of
Cmp eAx, 7
use this:
Dd CmpEAX; Dd 7; { Cmp eAx,7 }
- Robert Beicht -
---------------------------------------------------------------------
--- Robert Beicht e-Mail: bei...@lrz.fh-muenchen.de ---
--- Compuserve: 100551,2212 ---
---------------------------------------------------------------------
--- WWW: http://www.lrz-muenchen.de/~p7003ot ---
---------------------------------------------------------------------