diff --git a/Debugger.java b/Debugger.java new file mode 100755 index 0000000..dd01c4e --- /dev/null +++ b/Debugger.java @@ -0,0 +1,1764 @@ +/* +Copyright (c) 2010 Achim Breidenbach + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +public class Debugger { + + + public static String hex(int value, int stringLength) { + + String returnString = (String)(Integer.toHexString(value)).toUpperCase(); + return addLeadingZeros(returnString, stringLength); + } + + public static int hexStringToInt(String theHexString) { + + int result = 0; + + if(theHexString != null){ + + char c; + theHexString = theHexString.toUpperCase(); + + for(int i=0; i='0' && c<='9'){ + result = result << 4; + result += c - '0'; + } + + if(c>='A' && c<='F'){ + result = result << 4; + result += c - 'A' + 10; + } + + } + } + return result; + } + + + public static String binary(int value, int stringLength) { + + String returnString = Integer.toBinaryString(value); + return addLeadingZeros(returnString, stringLength); + } + + public static int binStringToInt(String theBinString) { + + int result = 0; + + if(theBinString != null){ + + char c; + + for(int i=0; i