DOS, Hexdump and Number conversion

Today we start with DOS again by creating a directory called Projects in the student directory on drive C:\Users\BO103LabStudent. You could on the other hand use a Jump drive and create the directory there. Its drive letter will be E or F or something other than C.

Here we will use notepad(or notepad++) to create and save a small file, say myfile.txt. Type into this file the string Hello[tab]There[cr] where [tab] represents the tab key and [cr] the enter key. The [tab] key will later be represented by \t and the [cr] key by \n. Save the file and go back to DOS

At this point we execute the following instruction hexdump myfile.txt. This command basically converts the file myfile.txt to the hexadecimal format. We will discuss hex later. Here is an example of output that you might see. In order for this to work you must copy hexdump.exe from the Y drive under my named directory to your working directory which should be C:\Users\BO103LabStudent\Projects at this point. You can make this copy either from the command line or from windows.

Command line method

Go to the Y drive and then to richard.simpson using the DOS command cd. When you get there you can copy hexdump.exe back to your working directory with the command

copy hexdump.exe C:\Users\BO103LabStudent\Projects

Now go back to the Projects directory using cd \Users\BO103LabStudent\Projects

There are also copies of hexdump.zip on the web. Here is one that I have NOT checked out so be wary.

Note that the [tab] is represented in this list of numbers as an 09. These numbers are hex values. You can look at the string on the right and match up each letter with the number on the left. For example H is matched with 48, e is matched with 65 and so on. What is 0d and 0a. Since these are all hex numbers that are represented in the ASCII table you can look these up and check each. See this ASCII table to see what I am talking about. This utility allows us to look, very closely at the contents of a file. We can easily see every character that is actually in the file including the tabs, carriage returns and other control codes.

Numbering System

There are many numbering systems in the world today, some quite old. Roman numerals, time, Mayan, as well as many others. Our system is called decimal and is a base 10 place value system. Why 10? We really do not have a clue. The early Babylonian system was base 60 while the classic Mayan civilization used base 20 in one of its numbering systems. The number of symbols used in writing numbers in a base system is the same as the base. For example in a base 10 system we use the old Arabic symbols, 0,1,2,3,4,5,6,7,8, and 9. A base 5 system would use 0,1,2,3 and 4 as its only symbols. A place value system ( as you might recall from elementary school) represents numbers in a sequence . For example the number 5341 in base 10 is spoken of as 5 thousand, 3 hundred and 41. Why? Because the 1 is in the units position, the 4 in 10′s position, the 3 in the hundredth position and the 5 is in the thousandth position. The need to fill each and every position in a place value system forces the creation of a symbol to represent 0. Otherwise numbers such as 2302 could not be represented. Note that the Roman numeral system is not place value so consequently one could get along without a zero symbol. Writing a number in a place value system allows the easy addition of numbers by hand. Before using calculators all the time you might recall adding numbers a column at a time with a carry being placed over the next column. This scheme works for all place value systems. Computers use three special place value systems in order to represent numbers,and these are binary, octal and hex. The following sections will discuss each in turn. The value of the base is used to define the place value of each position by increasing powers of the base.

Binary Numbers

This is the simplest system in that it is base 2. Base 2 numbers are used to represent the position of switches and since a computer and its memory are switch oriented. The smallest binary number is a single bit(binary digit), which has the value 0 or 1. Usually the value 1 represents an switch that is turned on and 0 one that is turned off. Combining multiple binary digits together we can represent numbers of any desired size. For example the binary number 101 has 3 places with the right most digit being the units digit, the second from the right digit being the 2’s digit and the leading digit the 4’s. Hence we see that 101 in binary is really equivalent to the number 4 in decimal. Here is a site that contains simple tutorial on binary. Here is a very simple binary to decimal conversion tool. It will convert to and from decimal. Use this tool to test your knowledge. I.E. put a number in the tool, calculate the answer by hand and then use the tool to check your answer. There is a quiz at the top of the page. Use it to test yourself. You may also use the windows calculator in scientific mode to do conversions as well. Just click the different buttons, Hex, Dec, Oct and Bin to do the conversions.

Other sites of interest. Note that there are may binary tutorials on the web. Just look them up with google if you need more.

Comments are closed.