home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Updates / Perl / Non-RPC / !Perl / riscos / ARM.pm next >
Text File  |  1998-07-31  |  1KB  |  62 lines

  1. package ARM;
  2.  
  3. use RISCOS::SWI;
  4. require Exporter;
  5. use strict;
  6. use vars qw (@ISA @EXPORT $VERSION $disassemble $mask);
  7.  
  8. @ISA = qw(Exporter);
  9. @EXPORT = qw(disassemble);
  10. $VERSION = 0.01;
  11.  
  12. $disassemble = SWINumberFromString("XDebugger_Disassemble");
  13. $mask = ®mask([0..1],[1]);
  14.  
  15. sub disassemble ($;$)
  16. {
  17.     my ($inst, $addr) = @_;
  18.     my ($result) = '1234';
  19.  
  20.     $addr += 0;    # force to be defined and numeric, default zero;
  21.     
  22.     return undef unless defined $inst;
  23.     
  24.     return undef unless swix ($disassemble, $mask, $inst, $addr, $result);
  25.     
  26.     return unpack 'p', $result;
  27. }
  28.  
  29. $disassemble;    # Fail if we don't get the SWI
  30. __END__
  31.  
  32. =head1 NAME
  33.  
  34. ARM -- perl module to disassemble an arm instruction.
  35.  
  36. =head1 SYNOPSIS
  37.  
  38.     use Arm;
  39.     $mnemonic = disassemble($instr, $addr_of_instr);
  40.  
  41. =head1 DESCRIPTION
  42.  
  43. This module provides a perl interface to C<Debugger_Dissassemble>, allowing
  44. numeric ARM instructions to be disassembled to text mnemonics. It is necessary
  45. to supply the address of the instruction to correctly disassemble C<PC> relative
  46. instructions (I<i.e.> C<B>, C<BL>, C<LDR I<x>,[PC,#..]> - if this is omitted it
  47. will default to zero.
  48.  
  49. Returns the textual mnemonic, or undefined on error.
  50.  
  51. =head1 BUGS
  52.  
  53. It is limited by the capabilities of the Debugger in the version of S<RISC OS>
  54. it is running under. For example 32 bit ARM instructions will not be recognised
  55. on an A series machine.
  56.  
  57. =head1 AUTHOR
  58.  
  59. Nicholas Clark <F<nick@unfortu.net>>
  60.  
  61. =cut
  62.