flat assembler
Message board for the users of flat assembler.

Index > 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
m3ntal 09 Nov 2014, 08:31
[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>>>20, op&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>>>20, op&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>>>21, op&11b
 if op=0
   . op=i,\
    op>>>5, op&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>>>5, op&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>>>5, op&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>>>5, op&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.tb, id
   get s=search.n \       ; 2 operands?
    dp2.tb, id,\          ; 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>>16, r0&0Fh    ; operand 2
       put.r r0
       put.cs
     end
     . r0=i,\
      r1=r0, r1&0FFh,\
      n=r1
     if r0&0F00h          ; constant
       . r1=r0,\          ; rotation?
        r1>>8, r1&0Fh,\
        r1*2              ; double
        ror n, cl
     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>>16, r0&0Fh
     put.r r0
     put.cs               ; ", "
   end
   . r0=i, r0&0Fh
   put.r r0               ; operand 3
   . r0=i
   if.not.bit 4           ; shift #i
     . \
      r0=i, r0>>7,\
      r0&11111b, n=r0
     if false             ; #i=0, no
       jmp .r             ; shift. just
     end                  ; register
     put.cs               ; ", "
     . r0=i,\
      r0>>5, r0&11b       ; shift
     put.shift r0         ; type
     put.space
     put.n n              ; #number
     jmp .r
   end
   . \                    ; else, shift
    r0=i, r0>>8,\         ; by register
    r0&0Fh, n=r0
   put.cs                 ; ", "
   . r0=i,\
    r0>>5, r0&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.tb, id
   . r0=i, r1=r0,\
    r1>>25, not r1, r1&1, imm=r1,\
    r1=r0, r1>>24, r1&1, post=r1,\
    r1=r0, r1>>23, r1&1, up=r1,\
    r1=r0, r1>>21, r1&1, wb=r1,\
    r1=r0, r1&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>>5, r0&11b
       put.shift r0
       put.space
       . r0=i,\
        r0>>7, r0&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 NO, OPERATION
    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 MOVE, IMMEDIATE, LOW, 16
    go .ok
  else.if i=I.MOVT
    describe MOVE, IMMEDIATE, HIGH, 16
    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.c, t, code
  locals c
  . r0=code, r0>>>28,\
   r0&1111b, c=r0
  if c>=C.AL
    return
  end
  descript IF
  if c=C.EQ
    describe EQUAL
  else.if c=C.NE
    describe NOT, EQUAL
  else.if c=C.VS
    describe OVERFLOW
  else.if c=C.VC
    describe NOT, OVERFLOW
  else.if c=C.MI
    describe MINUS, C, NEGATIVE
  else.if c=C.LT
    describe LESS, THAN, SIGNED
  else.if c=C.LE
    describe LESS, OR, EQUAL, SIGNED
  else.if c=C.GT
    describe GREATER, THAN, SIGNED
  else.if c=C.GE
    describe GREATER, OR, EQUAL, SIGNED
  else.if c=C.LO
    describe LESS, THAN, UNSIGNED
  else.if c=C.LS
    describe LESS, OR, EQUAL, UNSIGNED
  else.if c=C.HI
    describe GREATER, THAN, UNSIGNED
  else.if c=C.HS
    describe GREATER, OR, EQUAL, UNSIGNED
  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.to, i
  . r0=i, [asm.start]=r0, r0-[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.breakpoint, i
  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 i, s
  . s=[asm.start], s--
  for i=s, i>0, i--
    is.breakpoint i
    if true
      step.to i
      return 1
    end
  endl
endf 0

function step.next
  locals i, n, s
  . 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.


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
m3ntal 10 Nov 2014, 16:18
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     r1, r2                 ; MOV$: Move
00000014 E3017234 movw    r7, 1234h              ; MOVW?: Move Immediate Low 16BIT
00000018 E34A7BCD movt    r7, 0ABCDh             ; MOVT?: Move Immediate High 16BIT
0000001C 03A0147F moveq   r1, 7F000000h          ; MOV$: Move If Equal
00000020 11B01312 movsne  r1, r2, lsl r3         ; MOV$: Move If NOT Equal
00000024 C0821433 addgt   r1, r2, r3, lsr r4     ; ADD$: Add If Greater Than Signed
00000028 E05217C3 subs    r1, r2, r3, asr 15     ; SUB$: Subtract
0000002C E351087F cmp     r1, 7F0000h            ; 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  r1, r2, r3, lsr r4     ; EOR$: Exclusive OR If NOT Overflow
0000003C 43821102 orrmi   r1, r2, 80000000h      ; ORR$: OR If Minus, Negative
00000040 31C21383 biclo   r1, r2, r3, lsl 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 id, code
  ubyte n.operands, a, b, c
  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.p, i
  . r0=i, r0*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.asm, input
  locals i, n, p, q, s,\
   size, id, code,\
   name, operands
  catch .0
  . q=0, p=0

  try q=load.file input        ; load binary
  . r0=[file.n], r0/4          ; size
  . [asm.n]=r0, n=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=q, r1=i
    . r1*4, r1+[@start]
    . code=[r0+r1]
    text.zero t
    dasm.arm t, code           ; disassemble
    text.copy asm.line, t      ; save line
    . r0=t, byte [r0+17]=0     ; get code
    text.shift.l t, 8          ; '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 t, asm.line      ; get line
    text.shift.l t, 18         ; get asm
    text.copy t2, t
    get s=text.get t, t2       ; get name
    . r0=p, r1=\
     &[?asm.name+r0], name=r1
    text.copy.n name, t, 24
    . operands=0, r0=p         ; zero operands
    . [?asm.operands+r0]=0
    get s=text.skip.w s
    if s                       ; operands?
      . r0=s, r0=>[r0]
      if true
        . r0=p, r1=\           ; get operands
         &[?asm.operands+r0]
        . operands=r1
        text.copy.n \
        operands, s, 60
      end
    end
    . [@ip]+4                  ; advance ip
    . p+ASM.LINE.$             ; next ASM.LINE
  endl
  destroy q                    ; success
  return [asm.p]
  .0:                          ; error
  destroy p, q
endf 0    
New copy ASM functions:
Code:
align boolean asm.only?=0

function copy.asm.lines
  locals i,\
   s, e, p, size
  catch .0
  text.zero asm.line
  get s=get.select.start
  get.select.end
  . r0++, e=r0, r0-s
  . r0*256, size=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.line, 18
    end
    text.attach p, asm.line  ; attach line
    text.attach p, nl.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,\
   s, e, p, c, size
  catch .0
  text.zero asm.line
  get s=get.select.start
  get.select.end
  . r0++, e=r0, r0-s
  . r0*32, size=r0
  try p=allocate size
  text.copy p, code.dw.t     ; dw \ ...
  text.attach p, nl.t
  loop i=s to e
    get c=get.asm.code i
    h2t c, t                 ; convert
    text.align t, '0', 9     ; 9 for 0 prefix:
    text.attach.c t, 'h'     ; 0ABCD1234h
    . r0=e, r0--             ; if not end
    if i<>r0                 ; attach ,
      text.attach.c t, ','
    end
    . r0=s, r0-i, r0--, r0&7 ; every 8 values
    if r0=0
      text.attach.c t, '\'   ; escape and
      text.attach t, nl.t    ; return after
    end
    text.attach p, t
  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    
Post 10 Nov 2014, 16:18
View user's profile Send private message Reply with quote
m3ntal



Joined: 08 Dec 2013
Posts: 296
m3ntal 11 Nov 2014, 11:53
NEW: VIDEO TRAILER PREVIEW

Image

Update: Fixed display lines issue
Post 11 Nov 2014, 11:53
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1416
Location: Piraeus, Greece
Picnic 02 Feb 2016, 09:17
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 Visit poster's website Reply with quote
redrum88



Joined: 30 Mar 2016
Posts: 6
redrum88 30 Mar 2016, 10:22
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


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.