home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / extbasdis_2 / DisasmDoc next >
Text File  |  1997-08-14  |  8KB  |  249 lines

  1. =====================
  2. Extended Disassembler
  3. =====================
  4.  
  5. Version 0.31, 14 August 1997
  6. by Darren Salt <arcsalt@spuddy.mew.co.uk>
  7.  
  8.  
  9.  
  10. Introduction
  11. ============
  12.  
  13. The module Disassembler provides a patch for all versions of the Debugger
  14. module from RISC OS 3.10 onwards. However, at the time of writing it hasn't
  15. (AFAIK) been tested with ARM8 and StrongARM.
  16.  
  17. It is aware of all ARMs up to ARM8 and StrongARM SA-110; it knows of all
  18. instructions up to ARM7, and the sign-extend and half-word load/store
  19. extensions. It also has a few extras thrown in (see below). It can also
  20. auto-detect which cache type is in use, since this is indicated by the ARM
  21. ID.
  22.  
  23. To make the necessary changes to the Debugger module it must be located in
  24. RAM. The Disassembler module will therefore attempt to RMFaster the Debugger
  25. module; if it has to be copied from ROM, then any breakpoints you may have
  26. had set will be lost, along with the register dump contents (as shown by
  27. *ShowRegs).
  28.  
  29. It is possible to initialise the flags by appending them to the load command.
  30. For example:
  31.   *RMLoad System:Modules.Disassem -FDwithR13 Y -QuoteSWIs Y
  32. (If a flag is not specified, it defaults to OFF.)
  33.  
  34.  
  35. The module supports one command and two SWIs. It also tries to patch
  36. *ShowRegs so that it uses the APCS-R register names if the APCS flag is set.
  37.  
  38.  
  39.  
  40. Commands supported
  41. ==================
  42.  
  43.  
  44. *DisassemblerFlags
  45. ------------------
  46.  
  47. Allows you to set various MemoryI and Debugger_Disassemble features.
  48. Available switches:
  49.     -FDwithR13      use FD with R13, eg. STMDB R13 -> STMFD R13
  50.     -APCS      use APCS-R register set
  51.     -LFMstack      use stack notation with LFM & SFM where possible
  52.     -LFS      use LFS and SFS in preference to LFM & SFM
  53.     -QuoteSWIs      put quotes around SWI names
  54.     -UseDCD      use DCD instead of 'Undefined instruction', and BRK where
  55.             DCD &x6000010 would be used
  56.     -UseVDU      use VDU x instead of SWI OS_WriteI+x
  57.     -ANDEQasDCD      use DCD instead of ANDEQ, MOV Rn,Rn (same register) etc.
  58.     -UseADRL      use ADRL/ADRX instead of ADR then ADD/SUB on same reg
  59.     -UseADRW      use ADRW instead of ADD/SUB Rn,R12,#m and LDRW, STRW,
  60.             LDRBW, STRBW instead of xxxx Rn,[R12,#m]
  61.     -LongMul      append L to UMUL, UMLA, SMUL, SMLA (thus using the
  62.             'official' forms)
  63.     -UseLDRL      use LDRL instead of ADD/SUB Rn,Rm,#o + LDR Rn,[Rn,#p] and
  64.             ADD/SUB Rm,Ra,#o + LDR Rn,[Ra,#p]! and STR instead of
  65.             equivalent STRs.
  66.             (The LDRWL form is enabled by this *and* UseADRW)
  67.     -UseNOP      use NOP instead of MOV R0,R0
  68.     -OldPSR      use the old PSR suffixes _ctl, _flg, _all
  69.     -Wide      disassemble for wide display
  70.     -HSLO      use HS and LO instead of CS and CC
  71.     -Shift      use x<<y comments where possible for numbers >= 8192.
  72.             This affects arithmetic and logic instructions. y is
  73.             restricted to multiples of 4 if possible, unless x=1
  74.  
  75. All the switches take a single character parameter: "0" or "N" (off), or "1"
  76. or "Y" (on). To leave a switch unchanged, don't include it in the command.
  77.  
  78. Use *DisassemblerFlags on its own to display the current state.
  79.  
  80.  
  81.  
  82. The SWI interface
  83. =================
  84.  
  85. Debugger_Disassemble
  86. --------------------
  87.  
  88. Replaces the 'standard' version. Use it in exactly the same way.
  89.  
  90.  
  91. Debugger_63
  92. -----------
  93.  
  94. Used to alter the Debugger_Disassemble flags (listed above).
  95.  
  96. Input  : R0 = BIC mask, R1 = EOR mask
  97. Process: new_flags = (old_flags AND NOT R0) EOR R1
  98. Output : R0 = old_flags, R1 = new_flags
  99.  
  100. Bits in R0 and R1 are:
  101.  0 = FDwithR13    4 = QuoteSWIs     8 = UseADRL    12 = UseNOP    16 = Shift
  102.  1 = APCS    5 = UseDCD     9 = UseADRW    13 = OldPSR
  103.  2 = LFMstack    6 = UseVDU    10 = LongMul    14 = Wide
  104.  3 = LFS    7 = ANDEQasDCD    11 = UseLDRL    15 = HSLO
  105.  
  106. Bits 16 to 22 are currently unused (reserved for future expansion); bit 23
  107. is reserved for use by Zap and other syntax-colouring editors. Bits 24 to 31
  108. are used internally and cannot be altered.
  109.  
  110.  
  111.  
  112. Disassembly extensions and changes
  113. ==================================
  114.  
  115. MOV R0,R0    Optionally disassembled as NOP
  116.  
  117. MOV PC,PC    Always disassembled as MOV PC,PC
  118.         Sometimes used instead of a branch instruction:
  119.             LDR    R0,data
  120.             MOV    PC,PC
  121.         .data    DCD    &123456        ; this is ignored
  122.             LDR    R1,[R0]
  123.  
  124. SWP        Now listed as 'ARMv2a and later'
  125.  
  126. STM        Warning if base register second or later in register list and
  127.         writeback enabled: 'Base not first in list'
  128.  
  129. ADRL        ADR followed by ADD/SUB with same condition on same register.
  130.         For example,
  131.             00010000    ADRLS    R0,&00010100
  132.             00010004    ADDLS    R0,R0,#&A000
  133.         becomes
  134.             00010000    ADRLS    R0,&00010100
  135.             00010004    ADRLSL    R0,&0001A100
  136.  
  137. ADRX        ADR followed by two ADD/SUBs with same condition on same
  138.         register.
  139.  
  140. ADRW        R12 relative: ADD/SUB Rn,R12,#m
  141.  
  142. LDRW, LDRBW,    R12 relative: LDR/LDRB/STRB/STRB Rn,[R12,#m]
  143. STRW, STRBW
  144.  
  145. LDRL, LDRBL    Without writeback:
  146.             Normal:
  147.             ADD/SUB        Rn,Rm,#o
  148.             LDR/LDRB    Rn,[Rn,#p]
  149.             ->    ADD/SUB        Rn,Rm,#o
  150.             LDRL/LDRBL    Rn,[Rm,#o+p]
  151.             PC relative:
  152.             ADR        Rn,a
  153.             LDR/LDRB    Rn,[Rn,#p]
  154.             ->    ADR        Rn,a
  155.             LDRL/LDRBL    Rn,a+p
  156.         With writeback:
  157.             ADD/SUB        Rm,Rm,#o
  158.             LDR/LDRB    Rn,[Rm,#p]!
  159.             ->    ADD/SUB        Rm,Rm,#o
  160.             LDRL/LDRBL    Rn,[Rm,#o+p]!
  161.         Store address in third register:
  162.             Normal:
  163.             ADD/SUB        Ra,Rm,#o
  164.             LDR/LDRB    Rn,[Ra,#p]!
  165.             ->    ADD/SUB        Ra,Rm,#o
  166.             LDRL/LDRBL    Rn,{Ra},[Rm,#o+p]
  167.             PC relative:
  168.             ADR        Ra,a
  169.             LDR/LDRB    Rn,[Ra,#p]
  170.             ->    ADR        Ra,a
  171.             LDRL/LDRBL    Rn,{Ra},a+p
  172.  
  173. STRL, STRBL    Without writeback:
  174.             Normal:
  175.             ADD/SUB        Rm,Rm,#o
  176.             STR/STRB    Rn,[Rm,#p]
  177.             ->    ADD/SUB        Rn,Rm,#o
  178.             STRL/STRBL    Rn,[Rm,#o+p]
  179.             (followed by a cancelling SUB/ADD)
  180.             PC relative:
  181.             Is not practical
  182.         With writeback:
  183.             ADD/SUB        Rm,Rm,#o
  184.             STR/STRB    Rn,[Rm,#p]!
  185.             ->    ADD/SUB        Rm,Rm,#o
  186.             STRL/STRBL    Rn,[Rm,#o+p]!
  187.         Store address in third register:
  188.             similar to LDRL/LDRBL
  189.  
  190. LDRWL,        R12 relative:
  191. LDRBWL,            ADD/SUB        Rn,R12,#o
  192. STRWL,            LDR/LDRB    Rn,[R12,#p]
  193. STRBWL        ->    ADD/SUB        Rn,R12,#o
  194.             LDRWL/LDRBWL    Rn,o+p
  195.         & similar for 3rd register variants (see LDRL)
  196.  
  197. MCR, MRC    Constant (following first comma) now displayed correctly
  198.  
  199. MRS, MSR    Added for ARMv3 and later
  200.  
  201. UMUL, SMUL,    Added for ARMv3M and later
  202. UMLA, SMLA    (Long 'official' forms supported)
  203.  
  204. LDFxW, STFxW    R12 relative LDF/STF ('x' = precision code)
  205.  
  206. LFM, SFM    Extended format - for example,
  207.             LFM    F1,3,[R13],#&024    ; =36
  208.         may be shown 'as is' or as any of
  209.             LFMIA    F1,3,[R13]!
  210.             LFMFD    F1,3,[R13]!
  211.             LFSIA    R13!,{F1-F3}
  212.             LFSFD    R13!,{F1-F3}
  213.  
  214. FLT        Registers shown correct way round - Fx,Ry instead of Ry,Fx
  215.  
  216. LDC, STC    L and T flags shown in order TL to avoid confusion with the
  217.         LT condition. The T flag is not supported in current versions
  218.         of FPEmulator; it is always used as the writeback bit, and
  219.         must therefore be set for the post-indexed forms.
  220.         (This also affects LDF, STF, LFM and SFM.)
  221.  
  222. VDU, VDUX    Equivalent to SWI OS_WriteI and XOS_WriteI respectively
  223.  
  224. LDR, STR    H, SH, SB forms added for ARMv4 and later
  225.         W (R12-relative) forms supported, eg. LDRSBW R0,&40
  226.  
  227. Instructions which rely on PC plus implied offset, because of the possibly
  228. different values of this offset for different ARM implementations, are
  229. flagged as "*** Offset not guaranteed".
  230. (comp.sys.arm <47kr75$hpc@doc.armltd.co.uk>, David Seal, "Re: Storing PC")
  231.  
  232. LDRs and STRs which are PC-relative always appear in the standard form. For
  233. an instruction pair in which the first is of the form "[Rm],#d" and the
  234. second is an ADD or SUB modifying (and storing in) Rm, a comment "Rm+=x" will
  235. be shown.
  236.  
  237. Comments of the form '="x"' now contain the character code: '="x" (120)".
  238.  
  239. Constants which the BASIC assembler won't get right (eg. 256 stored as 4 ROR
  240. #26, rather than 1 ROR #24) are flagged as such.
  241.  
  242.  
  243.  
  244. And finally
  245. ===========
  246.  
  247. As with all good software, there may be undocumented features... let me know
  248. and I'll try to fix them :-)
  249.