Processing Assembler Directives
This function checks and processes assembler directives DB
, DW
and DD
. More then one byte, word or double word can be separated by comma.
Function ProcessAssemblerDirective: Boolean;
Procedure GenerateDirectiveAsmIntermediateCode;
Var N: Integer;
begin
RightExpression := LeftExpression;
Case DirectiveSize of
1: begin
If LeftExpression^.RelocatableIdentifier <> 0 then AsmError (InvalidCombinationOfOpcodeAndOperands);
If Length (AsmString) <> 0 then
begin
For N := 1 to Length (AsmString) do
begin
AddAsmIntermediateCodeRecord (acByte, 0, Byte (AsmString [N]), Ord (AsmToken));
GenerateAsmStatementIntermediateCode;
end;
Exit;
end;
If not RightExpressionNumericConstantAndSize8Bit then AsmError (ConstantOutOfRange)
else AddAsmIntermediateCodeRecord (acByte, 0, LeftExpression^.Value.Byte, Ord (AsmToken));
end;
2: begin
If Length (AsmString) > 2 then AsmError (StringConstantExceedsLine); { ??? }
RightExpression16BitNumericConstant;
If LeftExpression^.RelocatableIdentifier = 0 then
begin
AddAsmIntermediateCodeRecord (acByte, 0, LeftExpression^.Value.Byte, Ord (AsmToken));
AddAsmIntermediateCodeRecord (acByte, 0, LeftExpression^.Value.Byte1, Ord (AsmToken));
Exit;
end;
CurrentRelocatableIdentifier.Long := AsmExpression1.RelocatableIdentifier;
If LeftExpression^.ReferenceFlags = 0 then
AddAsmIntermediateCodeRecord (acReference, $01, LeftExpression^.Value.Word, Ord (AsmToken)) else
AddAsmIntermediateCodeRecord (acReference, LeftExpression^.ReferenceFlags,
LeftExpression^.Value.Word, Ord (AsmToken));
end;
else begin
If Length (AsmString) > 4 then AsmError (StringConstantExceedsLine); { ??? }
If LeftExpression^.RelocatableIdentifier = 0 then
begin
AddAsmIntermediateCodeRecord (acByte, 0, LeftExpression^.Value.Byte, Ord (AsmToken));
AddAsmIntermediateCodeRecord (acByte, 0, LeftExpression^.Value.Byte1, Ord (AsmToken));
AddAsmIntermediateCodeRecord (acByte, 0, LeftExpression^.Value.Byte2, Ord (AsmToken));
AddAsmIntermediateCodeRecord (acByte, 0, LeftExpression^.Value.Byte3, Ord (AsmToken));
Exit;
end;
CurrentRelocatableIdentifier.Long := AsmExpression1.RelocatableIdentifier;
If LeftExpression^.ReferenceFlags = 0 then
AddAsmIntermediateCodeRecord (acReference, $03, LeftExpression^.Value.Word, Ord (AsmToken)) else
begin
AddAsmIntermediateCodeRecord (acReference, LeftExpression^.ReferenceFlags,
LeftExpression^.Value.Word, Ord (AsmToken));
AddAsmIntermediateCodeRecord (acByte, 0, LeftExpression^.Value.Word2, Ord (AsmToken))
end;
end;
end;
end;
begin
If (AsmToken = AsmToken_Instruction) and (InstructionData^.B0 = $EA) then
begin
DirectiveSize := InstructionData^.B1;
If PrefixOpcode [0] <> 0 then AsmError (SyntaxError);
GetNextAsmToken;
Repeat
LeftExpression := @AsmExpression1;
ProcessAsmExpressionAndCheck;
GenerateDirectiveAsmIntermediateCode;
GenerateAsmStatementIntermediateCode;
until not CheckAndGetNextAsmToken (AsmToken_Comma);
ExpectAsmTokenAndGetNext (AsmToken_Semicolon);
ProcessAssemblerDirective := True;
end else ProcessAssemblerDirective := False;
end;