0CodErr
member
Posts
201
Threads
37
Location
Unknown
Post #1659
2015-02-10 16:42:59 UTC
This is for testing http://pastebin.com/W7Txw8ap
It contains commented part / /, because it cannot be compiled
Operand size mismatch!
Code:
bt ax, imm And also something wrong with test
test eax,0xc3f70012
instead of
test ax
Also (this was not included in file above):
sbb ax, 0x1234
Result:
00000000 6683D834 sbb ax,byte +0x34
I reported only about some errors. Also there are similar errors. And better if you check all output.
Colin
admin
Posts
928
Threads
49
Location
Bulgaria
Post #1663
2015-02-11 01:11:18 UTC
I have rewrote test and bt(s/r) instruction handlers and solved both of those issues, I will take a look at sbb tomorrow.
0CodErr
member
Posts
201
Threads
37
Location
Unknown
Post #1664
2015-02-11 09:58:13 UTC
You wrote that Ziron now supported shld | shrd .
I have some tested. And it gave incorrect result.
This source: http://paste2.org/_wdDImHML
This result: http://paste2.org/_ed7CL5z7
Colin
admin
Posts
928
Threads
49
Location
Bulgaria
Post #1666
2015-02-11 13:21:02 UTC
My mistake, I missed a 16 bit check on one of the functions I rewrote. Thanks for fast report, it will be updated on next beta or release.
I have also fixed sbb, it was a problem with word based values being sometimes truncated into bytes.
0CodErr
member
Posts
201
Threads
37
Location
Unknown
Post #1674
2015-02-11 22:12:52 UTC
# Registers support very basic assignment expressions using + and - e.g. eax = edx + ecx - ebx; program RAW_IMAGE 'test';
#set bits 32;
eax = dl + dh + dx;
Result:
00000000 0FB6C2 movzx eax,dl
00000003 03C6 add eax,esi
00000005 03C2 add eax,edx
But not every expression such as in your example so very basic .
And support such expressions can make parsing and code generation more complex.
I suggest to support only expressions which can be directly translated.
For example not so clear how translate this:
eax = ~ebx + ~ecx
even this
eax = ebx + eax
because not clear which value of eax we will add? Which was before calculations or after
eax = ebx
?
But as for simple expressions that really good thing :)
for example:
eax = ebx | ecx
eax = ebx & ecx
eax = ebx ^ ecx
eax = ebx >> cl
eax = edx << cl
eax = ebx - ecx
eax = ebx + ecx
Colin
admin
Posts
928
Threads
49
Location
Bulgaria
Post #1676
2015-02-11 22:53:39 UTC
Yes I plan to only have very basic assignment expressions because of inefficient code generation without loss of registers.
Assignment expressions work from left to right.
so eax = eax + ebx + ecx - esi will go from left to right
eax = eax;
add eax, ebx
add eax, ecx
sub eax, esi
as for
eax = dl + dh + dx;
I have added the appropriate error message. Thanks.
0CodErr
member
Posts
201
Threads
37
Location
Unknown
Post #1680
2015-02-12 20:32:25 UTC
Ok, how it would be in my example above?
eax = ebx + eax
This way:
mov eax, ebx
add eax, eax
And now compare some high level example:
a = b + a
Here in result 'a ' really will be as sum of 'a + b '
While in our registers expression we get that 'eax ' will be 'ebx * 2 ' but not 'ebx + eax '
Assignment expressions work from left to right. What about operator precedence? As I know in constant expressions it does matter. And it may cause conflict with constant expressions and reg|mem expressions.
Yet example:
eax = ebx & ecx + edi - ebp | edx ^ esi
eax = -~-~ebx
Maybe better need to completely define in documentation which expressions are 'simple '. And if expression not simple then we just say 'error: expression too complex '
0CodErr
member
Posts
201
Threads
37
Location
Unknown
Post #1682
2015-02-12 21:24:17 UTC
Again this http://pastebin.com/W7Txw8ap with some changes.
Add this:
#set imm_roll on;
Change this:
const imm = imm16; // imm8;
And check result http://pastebin.com/8Vm0QEuK