Commit Graph

109 Commits

Author SHA1 Message Date
nickysn
ae6a4030c3 + support evaluation of recordtype*constant in the intel syntax inline asm.
The recordtype itself is evaluated to 0. This makes e.g.
  'test [di+recordtype*5], 1' work. This is TP7 compatible.

git-svn-id: trunk@38200 -
2018-02-11 03:42:45 +00:00
nickysn
f0765421eb + also set the operand size in constants like recordtype (without addressing a
record field). This makes e.g.
    test [di + recordtype], 1
  work and use the size of recordtype to determine the operand size; recordtype
  itself is evaluated to 0, so if recordtype's size is 2 bytes, the above
  instruction assembles as:
    test word ptr [di], 1
  Ugly, but TP7 compatible.

git-svn-id: trunk@38176 -
2018-02-09 17:43:31 +00:00
nickysn
7338437dcd * allow recordtype.recordfield constants to set the operand size; this makes things like
test [di + recordtype.recordfield], 1
  work, as long as the size of recordfield is a valid operand size for the target

git-svn-id: trunk@38175 -
2018-02-09 17:36:54 +00:00
nickysn
f829f70186 * use the 'size' return value of BuildConstSymbolExpression to set the operand size
git-svn-id: trunk@38174 -
2018-02-09 17:22:39 +00:00
nickysn
384715be8d + add an extra output parameter 'size' to tx86intreader.BuildConstSymbolExpression,
which allows const symbol expressions to also have a size sometimes. Why?
  Because TP7 (and perhaps Delphi) allows not specifying the size in e.g.
    test [di+recordtype.recordfield], 1
  in this case, the operand size (byte ptr, word ptr, dword ptr, qword ptr) is
  determined by the size of recordtype.recordfield; this already happens with
  variables, but in this case, this is a type.field, which is resolved to a
  constant.
  This commit only adds a dummy 'size' parameter, which is always initialized to
  0 and not used. The actual implementation of the above will follow in separate
  commits.

git-svn-id: trunk@38173 -
2018-02-09 16:52:12 +00:00
nickysn
4b339fd133 * convert the 'var' parameters of tx86intreader.BuildConstSymbolExpression to 'out'
git-svn-id: trunk@38172 -
2018-02-09 16:20:34 +00:00
nickysn
84611d716b * convert the 'var' parameters of tx86intreader.BuildRecordOffsetSize to 'out'
git-svn-id: trunk@38171 -
2018-02-09 16:15:40 +00:00
nickysn
391f85f828 + for TP7 compatibility, allow the '&', '$' and '?' characters in the x86 intel
syntax inline asm reader

git-svn-id: trunk@38167 -
2018-02-08 16:54:33 +00:00
nickysn
5f56f6ec11 * always pass a valid constsize to ConcatConstSymbol; this prevents a compiler
internal error on i8086, generated by 'DB xx' or 'DB OFFSET xx'

git-svn-id: trunk@38153 -
2018-02-07 16:17:05 +00:00
nickysn
a792a92cfb * prevent the spurious warning, generated by 'DD xx' and 'DD OFFSET xx' on i8086
git-svn-id: trunk@38152 -
2018-02-07 16:14:05 +00:00
nickysn
3ad3807b6f + accept the 'DB/DW/DD OFFSET xx' syntax
git-svn-id: trunk@38150 -
2018-02-07 16:07:59 +00:00
nickysn
3b1bd8de3f + actually set hasofs to true if 'offset' is encountered in BuildConstSymbolExpression
git-svn-id: trunk@38149 -
2018-02-07 16:03:40 +00:00
nickysn
d591e698ac + added parameter 'hasofs' to ConcatConstSymbol. Will be used to support 'dd xx'
vs 'dd offset xx' being different on i8086.

git-svn-id: trunk@38148 -
2018-02-07 15:23:48 +00:00
nickysn
70038f1c0b + added extra boolean out parameter 'hasofs' to
tx86intreader.BuildConstSymbolExpression; it returns whether the 'OFFSET'
  keyword has been used in the expression. This will be used for disambiguation
  between 'dd xx' and 'dd offset xx', because they should produce different
  results on i8086 (the first generates a far pointer, i.e. the same as
  'dw xx, SEG xx', the second - a 32-bit offset)

git-svn-id: trunk@38147 -
2018-02-07 15:09:54 +00:00
nickysn
629be9cee1 + add a 'constsize' parameter to ConcatConstSymbol, so it can be used to
distinguish between e.g. 16-bit and 32-bit offsets on i8086

git-svn-id: trunk@38141 -
2018-02-06 16:22:41 +00:00
nickysn
1f0e311fdd + allow segment override prefixes to be used as a standalone opcode in the intel
syntax inline assembler; this is TP7 compatible and allows compiling ugly
  code, such as 'seges; db $67,$66; lodsw'

git-svn-id: trunk@38096 -
2018-02-01 17:31:59 +00:00
Jonas Maebe
1b66995754 * factored out check to determine whether a variable can be subscripted in
inline assembly, and fixed check after r35959 (mantis #32318)
   o can also subscript parameters passed by value on the stack
   o can also subscript local variables, the parameters passed by reference
     that are subsequently copied into a local

git-svn-id: trunk@37886 -
2018-01-01 14:29:21 +00:00
nickysn
e5dad9c98c + set oper.haslabelref in several other places, where a reference, containing a
label is created in the intel syntax x86 assembler. This fixes tfarcal3.pp and
  tfarcal4.pp after r37538

git-svn-id: trunk@37541 -
2017-11-01 14:31:16 +00:00
nickysn
9649154368 * fixed the token2str const array for intel syntax x86 asm
git-svn-id: trunk@37540 -
2017-11-01 13:36:16 +00:00
nickysn
9450beb99c * fixed bug in intel syntax i8086 inline asm, when certain 'jmp/call [v]'
instructions got erroneously converted to 'jmp/call v', if 'v' is an external
  far variable that points to certain things (like a local label, exported via
  public)

git-svn-id: trunk@37538 -
2017-10-31 16:49:38 +00:00
nickysn
29558a74cd + support exporting labels from asm blocks in intel syntax asm blocks via the
'public' directive

git-svn-id: trunk@37530 -
2017-10-30 16:44:13 +00:00
nickysn
9cebeeffa9 + check for address size mismatch in intel syntax assembler as well
git-svn-id: trunk@37475 -
2017-10-16 16:19:15 +00:00
nickysn
1ee36b5b9b + added error message in the intel assembler reader, when an attempt is made to
override the ES segment in an x86 string instruction (because it cannot be
  overriden)

git-svn-id: trunk@37454 -
2017-10-13 14:56:38 +00:00
florian
4cf2a2672a changes to fix #32043
* changed most of the variables in the assembler readers used to store constants from aint to tcgint 
  as aint has only the size of the accumular while some CPUs (AVR) allow larger constants in instructions
+ allow access to absolute symbols with address type in inline assembler
* allow absolute addresses in avr inline assembler
+ tests

git-svn-id: trunk@37411 -
2017-10-06 21:07:19 +00:00
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