Commit Graph

85 Commits

Author SHA1 Message Date
Jonas Maebe
744facb7fc * properly support accepting register parameters of assembler routines in
the intel assembler reader: no longer parse them as register tokens,
    but as local operands that are later converted into registers. This
    ensures in particular that the type of the operand is set, which is
    necessary in case this operand later subscripted (as in tasm10a)

git-svn-id: trunk@36288 -
2017-05-21 20:17:15 +00:00
Jonas Maebe
61af0fb72d * only take into account the location of the parameter at the callee side to
determine whether it's in a register if it's a pure assembler routine
  * you can't "index" implicit pointers either using their fields

git-svn-id: trunk@36287 -
2017-05-21 20:17:11 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
Jonas Maebe
aa82e00615 * fixed check to determine whether a record parameter can be subscripted
directly in inline assembly: that's only possible if it's a register
    parameter where the address of the record was passed (rather than the
    record itself), or if a parameter has been explicitly typecasted in
    Intel-style assembly using ".size"

git-svn-id: trunk@35959 -
2017-04-26 19:43:35 +00:00
nickysn
5f66f5cebb + distinguish between x86 flags subregisters: flags, eflags and rflags
git-svn-id: trunk@35953 -
2017-04-25 16:10:43 +00:00
sergei
8ae0864c9a * x86 Intel asm reader: handle special variables "self" and "result" similar to regular ones in terms of subscripting. This makes fix from r34911 apply to these special variables. Resolves #31542.
git-svn-id: trunk@35669 -
2017-03-27 19:58:55 +00:00
florian
ad557a1da6 * allow call dword ptr eax in delphi, resolves #18225
git-svn-id: trunk@35572 -
2017-03-12 16:37:48 +00:00
florian
b9dba41ad0 * intel assembler reader: scale factor in references can also be a constant symbol, resolves #31165
git-svn-id: trunk@35473 -
2017-02-22 20:59:52 +00:00
Jonas Maebe
015f034904 * reverted r35424, wasn't ready for commit yet
git-svn-id: trunk@35426 -
2017-02-11 21:21:44 +00:00
Jonas Maebe
4d9617da97 * fixed check to determine whether a record parameter can be subscripted
directly in inline assembly: that's only possible if it's a register
    parameter where the address of the record was passed (rather than the
    record itself)

git-svn-id: trunk@35424 -
2017-02-11 19:57:08 +00:00
sergei
d5ffc2da97 * Force OPR_LOCAL operand into reference whenever subscripting is used, so that all record fields are handled in same way regardless of their offset. Previously, operand was changed to reference only by fields with non-zero offset (see logic in tcgasmnode.ResolveRef method).
git-svn-id: trunk@34911 -
2016-11-18 05:56:12 +00:00
Jonas Maebe
aa1be3276f - removed default value of _typ parameter of TAsmData.(Weak)RefAsmSymbol():
it was AT_NONE, which is invalid and should never be used
  * explicitly pass the correct value for all calls to those methods elsewhere
    in the compiler

git-svn-id: trunk@34250 -
2016-08-05 07:09:16 +00:00
sergei
f69f6336e9 * Replaced hacks with resetting 'c' to zero and decreasing inputpointer by boolean parameter to skipcomment and skipoldtpcomment. This parameter specifies whether first character of comment should be read.
- in_asm_string also rendered useless by r32828, removed.

git-svn-id: trunk@32836 -
2016-01-03 17:07:15 +00:00
sergei
bbfbab7e0c * Moved handling of comments and line breaks in assembler blocks from scanner to tokenizer level. Handling them at character level was causing compiler to accept comments in the middle of any assembler token, which should never happen. It was also causing Mantis #27459: a newline immediately after closing 'end' token was first handled in asmgetchar and then by normal parser, causing all subsequent line numbering to be off by one.
git-svn-id: trunk@32828 -
2016-01-02 06:17:14 +00:00
Jonas Maebe
fd0c2f36e5 * don't parse "flags" as a register name in the Intel assembler reader
(mantis #29040)

git-svn-id: trunk@32368 -
2015-11-19 19:40:06 +00:00
nickysn
a553b15a1c + handle properly inline asm segment constants different than word:
o 'DB SEG symbol' produces an error
  o 'DD SEG symbol' (and anything larger than DW, like DQ) adds extra high zeros
    to the segment constant (this is Turbo Pascal 7 compatible)

git-svn-id: trunk@32283 -
2015-11-10 21:18:34 +00:00
nickysn
606b64a7f1 * fixed indentation
git-svn-id: trunk@32282 -
2015-11-10 20:57:52 +00:00
nickysn
3b80ca4376 + implemented the 'SEG @CODE' inline assembler directive for i8086
git-svn-id: trunk@32281 -
2015-11-10 18:02:10 +00:00
nickysn
995ca4fb12 + implemented the 'SEG @DATA' inline assembler directive for i8086
git-svn-id: trunk@32280 -
2015-11-10 17:26:21 +00:00
nickysn
43dabca8ab * moved the handling of the @Code and @Data inline assembler symbols to new methods Tx86operand.SetupCode and .SetupData
git-svn-id: trunk@32279 -
2015-11-10 14:04:40 +00:00
nickysn
ca24b006ef + support 'dw SEG symbol' in the inline assembler on i8086
git-svn-id: trunk@32256 -
2015-11-06 15:35:20 +00:00
nickysn
2e30b92c79 * removed the 'near ignored' and 'far ignored' inline asm warning messages on
the i8086, as 'near' and 'far' actually work there. Some forms may even work
  on the i386, but that's not tested very well for now, so we leave the messages
  there on i386 and x86_64.

git-svn-id: trunk@32195 -
2015-10-29 22:47:40 +00:00
nickysn
9e110e8e7e * treat interrupt procedures as 'near' in the i8086 inline assembler for TP7
compatibility

git-svn-id: trunk@32194 -
2015-10-29 22:43:41 +00:00
nickysn
dd9e5ea6f6 * convert 'call/jmp [proc]' properly to a near or far call/jmp, depending on
proc's call model

git-svn-id: trunk@32193 -
2015-10-29 22:05:09 +00:00
nickysn
ed09b4fcaa * in i8086 inline asm, convert 'call/jmp [proc/label]' to 'call/jmp proc/label'.
This is BP7 compatible and fixes e.g. 'call near ptr label' and 'call far ptr label'.

git-svn-id: trunk@32192 -
2015-10-29 17:07:23 +00:00
nickysn
77159d2806 + also add a cs: prefix to references such as [2+label]
git-svn-id: trunk@32191 -
2015-10-29 16:17:34 +00:00
nickysn
823deb39ac + also add an implicit cs: prefix on i8086 in tx86intreader.BuildOperand.AddLabelOperand
git-svn-id: trunk@32189 -
2015-10-29 15:35:09 +00:00
nickysn
92a39c93f5 + add a CS: override for references without an explicitly set segment override, which are relative to a function entry point
git-svn-id: trunk@32187 -
2015-10-29 14:48:59 +00:00
nickysn
ef5e368327 + support local label data access in the i8086 inline asm (fixes test tlbldat1.pp)
git-svn-id: trunk@32179 -
2015-10-28 17:22:37 +00:00
nickysn
dc6119bab7 * also convert 'jmp farprocsymbol' to 'jmp far farprocsymbol' in the i8086
inline assembler

git-svn-id: trunk@32170 -
2015-10-28 00:19:42 +00:00
nickysn
cb36b2d3bd * i8086 inline asm: convert 'call symbol' to 'call far symbol' only for symbols
that are an entry point of a function with a far call model

git-svn-id: trunk@32169 -
2015-10-28 00:17:54 +00:00
nickysn
c068c96302 * on i8086 convert the 'ret' inline asm instruction to either 'retn' or 'retf',
depending on the call model of the current function (which is BP7 compatible
  behaviour)

git-svn-id: trunk@32157 -
2015-10-26 16:01:50 +00:00
nickysn
b3c2765da9 * on i8086, for BP7 compatibility, assemble 'call/jmp dword [ref]' as a far call
git-svn-id: trunk@31945 -
2015-10-05 00:47:17 +00:00
nickysn
e9c790f4eb + support 'SEG' in the i8086 inline assembler
git-svn-id: trunk@31428 -
2015-08-26 15:57:44 +00:00
Jonas Maebe
3be51e1455 * fixed endless recursion in tabstractrecorddef.contains_float_field() in
case a record contains an internal typed constant of its own type
    (which happened becuase such a typed constant is also fieldvarsym, solved
     by checking for sp_static) (mantis #27880)
  * fixed several other similar cases in the compiler where we are only
    interested in instance fields, but processed all fieldvarsyms

git-svn-id: trunk@30614 -
2015-04-16 21:25:22 +00:00
florian
d6e4af8279 + applied remaining patches of Torsten Grundke: adds gather instructions of avx2
git-svn-id: trunk@29745 -
2015-02-17 21:43:46 +00:00
sergei
475a9e1617 * Asm readers: allow using procedure symbols in references, resolves #22376.
* rax86int.pas: reject RIP-relative references to locals/parameters.

git-svn-id: trunk@29087 -
2014-11-17 05:34:55 +00:00
sergei
42d251da1c - x86 assembler readers: cleaned out operand swapping code. Operands of TInstruction are kept in AT&T order, Intel reader attaches operands right-to-left. It was effectively the same way before the change (except Intel reader attaching operands left-to-right, followed by a single swap), operand order checks all over the place were just reducing readability.
git-svn-id: trunk@29081 -
2014-11-16 16:37:26 +00:00
sergei
de42f2f2f7 * Fixed handling of sign in constant expressions in Intel x86 assembler reader. Mantis #26668.
git-svn-id: trunk@28731 -
2014-10-03 15:51:38 +00:00
nickysn
9b560ffd64 * x86 intel syntax inline asm: allow a segment override (segcs,segds,seges,etc.)
to be followed by an instruction on the same line as the override

git-svn-id: trunk@28066 -
2014-06-25 21:06:19 +00:00
sergei
e7cd5319f0 * Put under {$ifndef x86_64} more cases of instructions that do not exist in 64-bit mode.
git-svn-id: trunk@27933 -
2014-06-11 12:51:38 +00:00
sergei
5c48804240 * Moved local label infrastructure into tasmreader, reduces number of global vars. Functionality is not changed.
git-svn-id: trunk@27477 -
2014-04-05 09:43:13 +00:00
sergei
9c54cdc85d * x86: Cleaned out addr_far,addr_far_ref used to encode far calls/jumps. NASM (and FPC x86 assembler based on it) already have opsize=S_FAR for this purpose.
git-svn-id: trunk@27037 -
2014-03-08 22:54:43 +00:00
nickysn
4f96e8a20d * convert i8086 inline asm instruction 'call symbol' to 'call far symbol' in memory models with far code
git-svn-id: trunk@25438 -
2013-09-08 16:34:12 +00:00
sergei
ea65e272dd * Changed global variable into field.
git-svn-id: trunk@25217 -
2013-08-05 16:32:37 +00:00
svenbarth
b6bfa864d4 Disallow the usage of the inline assembler inside generics, because there are currently two problems:
1. At least on x86 the assembler reader initializes the parameter location informations which results in InternalError 200301231
2. Assembler tokens are not stored in the token stream and thus won't be reproduced during specialization

x86/rax86int.pas, tx86intreader.Assemble:
  * check for "parse_generic" before calling generate_parameter_info
pstatmnt.pas, assembler_block & statement:
  * generate an error message if an asm statement should be parsed inside a generic

+ added test

git-svn-id: trunk@24892 -
2013-06-13 19:42:49 +00:00
florian
283ff05127 * merged avx support in inline assembler developed by Torsten Grundke
git-svn-id: trunk@22568 -
2012-10-06 19:47:18 +00:00
Jonas Maebe
68d9e95120 * if the size of an operand is not explicitly forced in intel assembler
(e.g. via "dword ptr"), let the size of accessed fields in memory
    expressions override the default size (mantis #18019)

git-svn-id: trunk@22250 -
2012-08-26 17:05:31 +00:00
Jonas Maebe
4d0e4e1b56 * treat "[var + rip]" in intel assembler mode as addr_pic_no_got on x86-64
(mantis #22665)
  + support "[var wrt ..gotpcrel]" nasm/yasm syntax in intel assembler mode
    for GOT-relative accesses on x86-64, + give an error when trying to do
    this on win64 (it doesn't have a GOT)
  * moved code that give a warning when using GOT-relative accesses to
    static data on x86-64 from the AT&T reader to rax86 so it's also
    active for the Intel assembler reader
  + added warning when not using GOT-relative accesses (but plain
    RIP-relative instead) to global data on non-Win64 x86-64

git-svn-id: trunk@22243 -
2012-08-25 15:12:49 +00:00
Jonas Maebe
2c43e084f0 * disabled "[reg].offset globalvar" pic syntax in intel assembler mode for
x86-64, because it does not specify whether the code should be got-based
    or not

git-svn-id: trunk@22242 -
2012-08-25 15:12:44 +00:00