about summary refs log tree commit diff stats
path: root/test/arch/x86/unit/test_asm_x86_64.py
blob: f56770dc79ae22fb1decc22db9ab0bbd621f0fe9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from miasm.core import asmblock
from miasm.arch.x86  import arch
from miasm.core import parse_asm
from miasm.core.interval import interval
from miasm.core.locationdb import LocationDB

my_mn = arch.mn_x86
loc_db = LocationDB()

asmcfg = parse_asm.parse_txt(
    my_mn, 64, r'''
main:
  PUSH   RBP
  MOV    RBP, RSP
loop_dec:
  CMP    RCX, RDX
  JB    loop_dec
end:
  MOV    RSP, RBP
  POP    RBP
  RET

''',
    loc_db
)

loc_db.set_location_offset(loc_db.get_name_location("main"), 0x100001000)
dst_interval = interval([(0x100001000, 0x100002000)])
patches = asmblock.asm_resolve_final(
    my_mn,
    asmcfg,
    dst_interval
)