flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Non-x86 architectures > [ARM] ARMv7 Visual Disassembler. Amazing Graphics/Interface!

Author
Thread Post new topic Reply to topic
m3ntal



Joined: 08 Dec 2013
Posts: 296
[ARM] ARMv7 Visual Disassembler. Amazing Graphics/Interface!
[ARM] ARMVD Visual Disassembler, Interactive Debugger.

Download: ARMVD for X86/Windows

Supports most ARMv6/7. Fast & easy to use. No setup or installation.

Disassembler engine (INCLUDE\DARM.INC) consists of >5,300+ lines of tightly written syntax with help and descriptions of instructions.

11 stylish, innovative themes: Designed for resolution width 1280W-1920W. To select themes, press Ctrl+LEFT/RIGHT or click theme icon near zoom.

Teaches ARM assembler with popup help descriptions of instructions.

Image
Image
Image
Image

SOURCE PREVIEW

Identify Instruction

Code:
if.bits 27-25=011b       ; #227, A5-16.
   if.bit 4               ; media
     jmp .mi              ; instructions
   end
 end
 if.bits 31-27=11110b     ; A5.7.1
   jmp .misc2             ; miscellaneous 2
 end
 if.bits 27-26=10b        ; branch
   if.bit 25
     if.bit 24            ; with link?
       return I.BL
     end
     return I.B
   end
 end
 if.not.bit 25            ; #210, A5-2
   if.bits 27-26=0        ; class 0
     . op=i,\
      op>>>20op&11001b  ; op=not 10xx0
     if op<>10000b
       if.not.bit 4       ; op=xxx0. data
         jmp .dpr         ; processing register
       end
       if.not.bit 7       ; op=0xx1. data
         jmp .dprsr       ; processing register
       end                ; shifted register
     end
   end
   if.bits 24-23=10b
     if.not.bit 20
       if.not.bit 7       ; miscellaneous
         jmp .misc
       end
       if.not.bit 4       ; multiply half
         jmp .mulh
       end
     end
   end
   if.bits 7-4=1001b
     if.not.bit 24        ; multiply
       jmp .mula          ; accumulate
     end
     jmp .sync            ; synchronization
   end
   if.not.bit 24          ; op=0xx1x
     if.bit 21
       if.bits 7-4=1011b  ; load/store extra
         jmp .lsu         ; unprivileged
       end
       if.bits 7-6=11b
         if.bit 4
           jmp .lsu
         end
       end
     end
   end
   jmp .ldst              ; load/store
 else                     ; op=1
   . op=i,\               ; data processing
    op>>>20op&11111b    ; move 16BIT
   if op=10000b           ; immediate
     if.bit 26
       return I.STR
     end
     return I.MOVW
   end
   if op=10100b
     if.bit 26
       return I.STRB
     end
     return I.MOVT
   end
   if.bits 24-23=10b      ; msr immediate
     if.bits 21-20=10b    ; and hints
       jmp .msrih
     end
   end
   if.bit 25              ; not 10xx0
     if.not.bit 26
       jmp .dpi           ; data processing
     end                  ; immediate
   end
 end                 

 ; #219, A5.2.7, A5-9 - signed multiply half

 .mulh:
 . op=i,\
  op>>>21op&11b
 if op=0
   . op=i,\
    op>>>5op&11b
   if op=0
     return I.SMLABB
   else.if op=1
     return I.SMLATB
   else.if op=2
     return I.SMLABT
   else.if op=3
     return I.SMLATT
   end
 else.if op=1
   . op=i,\
    op>>>5op&11b
   if op=0
     return I.SMULWB
   else.if op=1
     return I.SMULWT
   else.if op=2
     return I.SMLAWB
   else.if op=3
     return I.SMLAWT
   end
 else.if op=2
   . op=i,\
    op>>>5op&11b
   if op=0
     return I.SMLALBB
   else.if op=1
     return I.SMLALTB
   else.if op=2
     return I.SMLALBT
   else.if op=3
     return I.SMLALTT
   end
 else                     ; op=3
   . op=i,\
    op>>>5op&11b
   if op=0
     return I.SMULBB
   else.if op=1
     return I.SMULTB
   else.if op=2
     return I.SMULBT
   else.if op=3
     return I.SMULTT
   end
 end



Convert Instruction

Code:
; data processing...

 if.search.table \
   dp.tbid
   get s=search.n \       ; 2 operands?
    dp2.tbid,\          ; mov/cmp/etc
    dp2.tb.n
   . r1=i
   if s=0
     jmp @f
   else.if id=I.MOV
     jmp @f
   else.if id=I.MVN
     @@:
     . r1>>12
   else
     . r1>>16
   end
   . r1&0Fh
   put.r r1               ; operand 1
   put.cs                 ; ", "
   . r0=i
   if.bit 25              ; immediate?
     if s=0               ; implicit?
       . r0=i,\
        r0>>16r0&0Fh    ; operand 2
       put.r r0
       put.cs
     end
     . r0=i,\
      r1=r0r1&0FFh,\
      n=r1
     if r0&0F00h          ; constant
       . r1=r0,\          ; rotation?
        r1>>8r1&0Fh,\
        r1*2              ; double
        ror ncl
     end
     if n>=-1             ; -1/0-9 as
       if n<=9            ; decimal
         put.n n
         jmp .r
       end
     end
     put.h n              ; h number
     jmp .r
   end
   if s=0                 ; operand 2
     . r0=i,\
      r0>>16r0&0Fh
     put.r r0
     put.cs               ; ", "
   end
   . r0=ir0&0Fh
   put.r r0               ; operand 3
   . r0=i
   if.not.bit 4           ; shift #i
     . \
      r0=ir0>>7,\
      r0&11111bn=r0
     if false             ; #i=0, no
       jmp .r             ; shift. just
     end                  ; register
     put.cs               ; ", "
     . r0=i,\
      r0>>5r0&11b       ; shift
     put.shift r0         ; type
     put.space
     put.n n              ; #number
     jmp .r
   end
   . \                    ; else, shift
    r0=ir0>>8,\         ; by register
    r0&0Fhn=r0
   put.cs                 ; ", "
   . r0=i,\
    r0>>5r0&11b         ; shift
   put.shift r0           ; type
   put.space
   put.r n                ; register
   jmp .r                 ; return
 end                      ; end dp  

 ; load/store w/b...

 if.search.table \
   ls.tbid
   . r0=ir1=r0,\
    r1>>25not r1r1&1imm=r1,\
    r1=r0r1>>24r1&1post=r1,\
    r1=r0r1>>23r1&1up=r1,\
    r1=r0r1>>21r1&1wb=r1,\
    r1=r0r1&0FFFh,\
    n=r1
   put.rx 12           ; destiny
   put.cs              ; register
   . testing?=0
   if testing?
     put.c '<'
     if imm
       put.c 'i'
     end
     if post
       put.c 'p'
     end
     if up
       put.c 'u'
     end
     put.c '>'
     jmp .r
   end
   put.c '['              ; base
   put.rx 16              ; register
   if imm
     if post
       if up
         if n=0           ; ipu: ldr r, [r]
           jmp .ls.ok
         end              ; non-zero offset
         put.cs           ; ldr r, [r, #]
         put.dh n
         jmp .ls.ok
       else               ; ip: ldr r, [r, -#]
         put.cs
         put.c '-'
         put.dh n
         jmp .ls.ok
       end
     end
   end
   if post                ; pu:
     if up
       put.cs
       put.rx 0
       . r0=i
       if.bits 11-8=0     ; pu: ldr r, [r, r]
         jmp .ls.ok
       end
       put.cs             ; r, [r, r, sh #]
       . r0=i,\
        r0>>5r0&11b
       put.shift r0
       put.space
       . r0=i,\
        r0>>7r0&31
       put.n r0
       jmp .ls.ok
     end
     put.cs               ; p: r, [r, -r]
     put.c '-'
     put.rx 0
     jmp .ls.ok
   end
   if up                  ; u: r, [r], r
     put.c ']'
     put.cs
     if not imm
       put.rx 0
     else
       put.dh n
     end
     jmp .r
   end
   put.c ']'              ; none? r, [r], -r
   put.cs
   put.c '-'
   if not imm
     put.rx 0
   else
     put.dh n
   end
   jmp .r
   .ls.ok:
   put.c ']'
   if wb
     put.c '!'
   end
   jmp .r
 end



Convert Instructions to English Words/Descriptions

Code:
; in function arm.get.help(t, code)...

  if i=I.NOP
    describe NOOPERATION
    return
  else.if i=I.BKPT
    describe BREAKPOINT
    go .ok
  else.if i=I.SWI
    describe INTERRUPT
    go .ok
  else.if i=I.MOVW
    describe MOVEIMMEDIATELOW16
    go .ok
  else.if i=I.MOVT
    describe MOVEIMMEDIATEHIGH16
    go .ok
  end

Convert Condition to 'Text'

Code:
; get condition 'text'. example:

; * EQ: 'If Equal',
; * HI: 'If Greater Than Unsigned'
; * LE: 'If Less Or Equal Signed'

; return C.X condition code 0-15.
; if ALWAYS/NEVER, no 'text' is copied

; EQ, NE, HS, LO, MI, PL, VS, VC
; HI, LS, GE, LT, GT, LE, AL, NV

function arm.get.ctcode
  locals c
  . r0=coder0>>>28,\
   r0&1111bc=r0
  if c>=C.AL
    return
  end
  descript IF
  if c=C.EQ
    describe EQUAL
  else.if c=C.NE
    describe NOTEQUAL
  else.if c=C.VS
    describe OVERFLOW
  else.if c=C.VC
    describe NOTOVERFLOW
  else.if c=C.MI
    describe MINUSCNEGATIVE
  else.if c=C.LT
    describe LESSTHANSIGNED
  else.if c=C.LE
    describe LESSOREQUALSIGNED
  else.if c=C.GT
    describe GREATERTHANSIGNED
  else.if c=C.GE
    describe GREATEROREQUALSIGNED
  else.if c=C.LO
    describe LESSTHANUNSIGNED
  else.if c=C.LS
    describe LESSOREQUALUNSIGNED
  else.if c=C.HI
    describe GREATERTHANUNSIGNED
  else.if c=C.HS
    describe GREATEROREQUALUNSIGNED
  end
endf c

Step left/last/up or right/next/down to Breakpoint or Function

Code:
;;;;;;;;;;;;;;;;;;;;;; STEP ;;;;;;;;;;;;;;;;;;;;;;

; step; advance start to line # and select

function step.toi
  . r0=i, [asm.start]=r0r0-[asm.start]
  . r1=[asm.n], r1-[asm.visible]
  if [asm.start]>=r1
    . [asm.start]=r1
    . r0=[asm.n], r0--
  end
  . [asm.select]=r0
  . [asm.select.end]=r0
endf

; is line # breakpoint or function?

function is.breakpointi
  locals id
  get id=get.asm.id i
  if id=I.BKPT
    return 1
  else.if id=I.STMDB
    get.asm.code i
    if.bits 16-19=13 ; stmdb sp!...lr
      if.bit 14
        return 1
      end
    end
  end
endf 0

; advance to last/left/up or next/right/down
; appearance of breakpoint or function

function step.last
  locals is
  . s=[asm.start], s--
  for i=si>0i--
    is.breakpoint i
    if true
      step.to i
      return 1
    end
  endl
endf 0

function step.next
  locals ins
  . n=[asm.n], s=[asm.start], s++
  loop i=s to n
    is.breakpoint i
    if true
      step.to i
      return 1
    end
  endl
endf 0

Warning: Some features are unfinished in this demo/beta version. Working: Load, disassemble, save .TXT, copy, step breakpoints and most display settings. Not working: Search, popup menu, zoom, scroll bar knob (to scroll, click above or below knob or use mouse wheel or arrow keys).

Legal: Any individual has permission to use this strictly for non-profit, personal or educational purposes. If a corporation or software manufacturer is interested in my ideas, please message me. I have sent myself 3 copies of this on DVDs to prove that it's my intellectual property.

_________________
New FASM Site, Examples, Graphics, Updated Libraries


Last edited by m3ntal on 10 Nov 2014, 17:25; edited 1 time in total
Post 09 Nov 2014, 08:31
View user's profile Send private message Reply with quote
m3ntal



Joined: 08 Dec 2013
Posts: 296
UPDATE: Now working: Select All (tool bar), Copy Line/s, Copy ASM Only, Copy Code DW A,B,C (menu). Results pasted from ARMVD:

Code:
; Copy Line/s

00000000 00000000 dw      0                      ; DW: Data
00000004 E320F000 nop                            ; NOP: No Operation
00000008 E1212374 bkpt    1234h                  ; BKPT?: Breakpoint
0000000C EF001234 swi     1234h                  ; SWI?: Interrupt
00000010 E1A01002 mov     r1r2                 ; MOV$: Move
00000014 E3017234 movw    r71234h              ; MOVW?: Move Immediate Low 16BIT
00000018 E34A7BCD movt    r70ABCDh             ; MOVT?: Move Immediate High 16BIT
0000001C 03A0147F moveq   r17F000000h          ; MOV$: Move If Equal
00000020 11B01312 movsne  r1r2lsl r3         ; MOV$: Move If NOT Equal
00000024 C0821433 addgt   r1r2r3lsr r4     ; ADD$: Add If Greater Than Signed
00000028 E05217C3 subs    r1r2r3asr 15     ; SUB$: Subtract
0000002C E351087F cmp     r17F0000h            ; CMP$: Compare
00000030 E92D40EF stmdb   sp!, {r0-r3,r5-r7,lr}  ; STMDB?: Store Multiple, Decrement Before
00000034 E8BD80EF ldmia   sp!, {r0-r3,r5-r7,pc}  ; LDMIA?: Load Multiple, Increment After
00000038 70321433 eorsvc  r1r2r3lsr r4     ; EOR$: Exclusive OR If NOT Overflow
0000003C 43821102 orrmi   r1r280000000h      ; ORR$: OR If Minus, Negative
00000040 31C21383 biclo   r1r2r3lsl 7      ; BIC$: Bit Clear If Less Than Unsigned


Code:
; Copy Code DW A,B,C (menu)

dw \
000000000h,0E320F000h,0E1212374h,0EF001234h,0E1A01002h,0E3017234h,0E34A7BCDh,003A0147Fh,\
011B01312h,0C0821433h,0E05217C3h,0E351087Fh,0E92D40EFh,0E8BD80EFh,070321433h,043821102h,\
031C21383h,000821003h,0E1F01872h,010F21453h,0EA000003h,0EB000003h,01A000003h,08A000003h,\
0E0821203h,0E0465007h,010021443h,0E1811002h,0B1D21823h,0E12FFF17h,0E12FFF27h,04AFFFFF8h,\
06AFFFFFAh,0E1A01002h,0E3A01023h,0E1B01312h,0E2821003h,030B213C3h,040421413h,0E2521003h

In \INCLUDE\DARM.INC...

ASM.LINE[] structures (asm.p) with get/set:

Code:
; HL assembly line structure, 96 bytes

class ASM.LINE
  uinteger idcode
  ubyte n.operandsabc
  text name(24), operands(60)
endc ?asm

void asm.p     ; pointer to ASM.LINEs[]
uinteger asm.n ; # lines

; get &ASM.LINEs[i]...

function get.asm.pi
  . r0=ir0*ASM.LINE.$r0+[asm.p]
endf

Load and disassemble binary file to ASM.LINEs[]/asm.p:

Code:
; disassemble ARM file to dasm.p/ASM.LINEs[]

text asm.line(256)

function disassemble.asminput
  locals inpqs,\
   sizeidcode,\
   nameoperands
  catch .0
  . q=0p=0

  try q=load.file input        ; load binary
  . r0=[file.n], r0/4          ; size
  . [asm.n]=r0n=r0           ; # instructions
  . r0*ASM.LINE.$size=r0     ; allocate
  try p=allocate size          ; ASM.LINE
  . [asm.p]=r0                 ; structures
  . [@ip]=[@base]

  loop i=0 to n                ; # instructions
    . r0=qr1=i
    . r1*4r1+[@start]
    . code=[r0+r1]
    text.zero t
    dasm.arm tcode           ; disassemble
    text.copy asm.linet      ; save line
    . r0=tbyte [r0+17]=0     ; get code
    text.shift.l t8          ; 'text'
    get code=t2h t             ; convert n
    get id=identify.arm code   ; identify
    get.asm.p i                ; get &asm.p[i]
    . [?asm.id+r0]=id          ; assign id/I.*
    . [?asm.code+r0]=code
    text.copy tasm.line      ; get line
    text.shift.l t18         ; get asm
    text.copy t2t
    get s=text.get tt2       ; get name
    . r0=pr1=\
     &[?asm.name+r0], name=r1
    text.copy.n namet24
    . operands=0r0=p         ; zero operands
    . [?asm.operands+r0]=0
    get s=text.skip.w s
    if s                       ; operands?
      . r0=sr0=>[r0]
      if true
        . r0=pr1=\           ; get operands
         &[?asm.operands+r0]
        . operands=r1
        text.copy.n \
        operandss60
      end
    end
    . [@ip]+4                  ; advance ip
    . p+ASM.LINE.$             ; next ASM.LINE
  endl
  destroy q                    ; success
  return [asm.p]
  .0:                          ; error
  destroy pq
endf 0

New copy ASM functions:

Code:
align boolean asm.only?=0

function copy.asm.lines
  locals i,\
   sepsize
  catch .0
  text.zero asm.line
  get s=get.select.start
  get.select.end
  . r0++, e=r0r0-s
  . r0*256size=r0
  try p=allocate size
  text.zero p
  loop i=s to e
    if [comment.w]=0
      asm2t i                ; convert ASM.LINE
    else                     ; to 'text'
      asm2th i
    end
    if [asm.only?]           ; remove address
      text.shift.l \         ; and code
       asm.line18
    end
    text.attach pasm.line  ; attach line
    text.attach pnl.t
  endl
  .copy:
  set.clipboard.text p
  destroy p
  .0:
endf 1

; copy ASM only

function copy.asm.only
  . [asm.only?]=1
  push [comment.w]
  . [comment.w]=0
  copy.asm.lines
  pop [comment.w]
  . [asm.only?]=0
endf 1

; copy code DW A,B,C (DD in FASMW)

text code.dw.t='dw \'

function copy.code
  locals i,\
   sepcsize
  catch .0
  text.zero asm.line
  get s=get.select.start
  get.select.end
  . r0++, e=r0r0-s
  . r0*32size=r0
  try p=allocate size
  text.copy pcode.dw.t     ; dw \ ...
  text.attach pnl.t
  loop i=s to e
    get c=get.asm.code i
    h2t ct                 ; convert
    text.align t'0'9     ; 9 for 0 prefix:
    text.attach.c t'h'     ; 0ABCD1234h
    . r0=er0--             ; if not end
    if i<>r0                 ; attach ,
      text.attach.c t','
    end
    . r0=sr0-ir0--, r0&7 ; every 8 values
    if r0=0
      text.attach.c t'\'   ; escape and
      text.attach tnl.t    ; return after
    end
    text.attach pt
  endl
  .copy:
  set.clipboard.text p
  destroy p
  .0:
endf 1

Display Settings: Indent, Comment. Easy.

Code:
; set indent style: 0/8/10/12/16

?INDENT.START=8
?INDENT.END=16
?INDENT.STEP=2

function set.indent.style
  locals n
  . n=[indent?]
  if n>?INDENT.END
    . n=0
  else.if n=0
    . n=?INDENT.START
  else
    . n+?INDENT.STEP
  end
  . [indent?]=n
endf 1

; set comment style: 0=NONE/40/44/48/52/56

?COMMENT.START=40
?COMMENT.END=56
?COMMENT.STEP=4

function set.comment.style
  locals n
  . n=[comment.w]
  if n>?COMMENT.END
    . n=0
  else.if n=0
    . n=?COMMENT.START
  else
    . n+?COMMENT.STEP
  end
  . [comment.w]=n
endf 1


_________________
New FASM Site, Examples, Graphics, Updated Libraries
Post 10 Nov 2014, 16:18
View user's profile Send private message Reply with quote
m3ntal



Joined: 08 Dec 2013
Posts: 296
NEW: VIDEO TRAILER PREVIEW

Image

Update: Fixed display lines issue

_________________
New FASM Site, Examples, Graphics, Updated Libraries
Post 11 Nov 2014, 11:53
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1178
Awesome work with the interface m3ntal, it runs nicely on my pc. I use your D-ARM7.
Post 02 Feb 2016, 09:17
View user's profile Send private message Reply with quote
redrum88



Joined: 30 Mar 2016
Posts: 5
Wow, the GUI looks nice.

Did you do it in asm or use any other language/lib to do the interface?

Congratulations, by the way.
Post 30 Mar 2016, 10:22
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.