-
Notifications
You must be signed in to change notification settings - Fork 474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Armt: add some instructions #1029
base: master
Are you sure you want to change the base?
Conversation
I am restarting CI here, as it seems the faulty test is due to bad travis. |
ae9f08d
to
d17b762
Compare
hi @serpilliere, i add test code for instruction, but why test/arch/arm/sem.py seems do not include armt semantic test? do you forget it or other reason? if i write some armt instruction semantic test, it' s a right place? |
Hi @wzrybuddy ! To test the semantic, instead of testing the semantic directly, our preference goes to implement a little code and emulate it with special case, then check the registers/flags. For example, here is the test for an instruction in aarch64, in #! /usr/bin/env python2
import sys
from asm_test import Asm_Test
from pdb import pm
class Test_UBFM1(Asm_Test):
TXT = '''
main:
MOVZ X0, 0x5600
UBFM X0, X0, 8, 15
RET LR
'''
def check(self):
assert(self.myjit.cpu.X0 == 0x56)
pass
class Test_UBFM2(Asm_Test):
TXT = '''
main:
MOVZ X0, 0x56
UBFM X0, X0, 4, 55
RET LR
'''
def check(self):
assert(self.myjit.cpu.X0 == 0x5)
pass
if __name__ == "__main__":
[test(*sys.argv[1:])() for test in [Test_UBFM1, Test_UBFM2 ]] You have a bunch of these for x86 in miasm/test/arch/x86/unit/` if you want more examples! |
Ho, by the way, I will fix the tipo and relaunch your tests: it seems broken tests here are not your fault: it's only due to our bad english... |
I fix tipo with #1041 |
It seems some of your instructions have a length of 31 bits. |
4832be2
to
5025f4f
Compare
9053207
to
3a0d417
Compare
Hi @327135569 ,
I think this is necessary because if we let code empty, it will silently give an IR which will be wrong (as mnemonic will miss) and it is quite disturbing during analysis. Are you ok to fix this or do you want me to do a pr on your pr ? |
Thank you! I will try to add semantic later. |
miasm/arch/arm/sem.py
Outdated
# one dp to two gp | ||
# a = c[32:] | ||
# b = c[:32] | ||
e.append(ExprAssign(a, (c & ExprInt(0xffffffff, 64))[0:32])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, you are close to a good semantic.
Just a remark here, as you are doing a [0:32] (which will extract the first 32 bits) you don't need to mask it before with the & 0xFFFFFFFF
miasm/arch/arm/sem.py
Outdated
# a = c[32:] | ||
# b = c[:32] | ||
e.append(ExprAssign(a, (c & ExprInt(0xffffffff, 64))[0:32])) | ||
e.append(ExprAssign(b, ((c >> ExprInt(32, 64)) & ExprInt(0xffffffff, 64))[0:32])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, the bit truncation will do the mask job
Hey @327135569 |
Gosh, i am too slow to add semantic.. but seems OK, can you merge ? |
im not ensure it right, but dis is ok.