Last Update

Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Coding Assembly in Linux

Assembly nowadays is a hard thing to learn, not because it's difficult but
because people thinks that there is no reason to learn assembly! That's
not true... With assembly you can have total power above the computer, and
know exactly what he's doing. Try to remember that while trying to learn!
You may wondering: Why to read this tut? Good point... There are thousands
of papers for programming assembly in x86. That's true... But did they
teach you how to make apps for linux? Did they talked about linux
interrupts? I don't think so... There are many tutorials about programming
assembly for x86 in dos and windows, but very few on linux. I want to
change that. So this is the first issue of a collection of papers about
that. If you find that this paper has any error, please contact me and let
me know.

##### Index #####

1. Numbering systems
1.1. Decimal system
1.2. Binary system
1.2.1. Converting a binary number to a decimal number
1.2.2. Converting a decimal number to a binary number
1.3. Hexadecimal system
1.4. Conventions
2. Binaries in computers
2.1. Bit
2.2. Nibble
2.3. Byte
2.4. Word
2.5. Double word

###################### 1. Numbering systems ######################

1.1. Decimal system

Nowadays we use the decimal numbering system in almost everything that is
related to numbers. We use it so often and in a natural way that we forget
it's meaning. What is decimal system?

. Every decimal number, has only digits between zero and nine,
making a total of 10 digits
Note: how many fingers do you have? ...10. In fact the decimal
system is bound to human anatomy.
. Ok, and what is the meaning of each digit? Consider the
following numbers: 234 and 234,43
We do some transformations
-> 234 i.e. 200 + 30 + 4 i.e. 2 * 10^2 + 3 * 10^1 + 4 * 10^0
-> 234,43 = 2 * 10^2 + 3 * 10^1 + 4 * 10^0 + 0,43 = 2 * 10^2 + 3 *
10^1 + 4 * 10^0 + 4 * 10^-1 + 3 * 10^-2
Do you see the relation? Each digit appearing to the left of the
decimal point represents a value between zero and nine times an increasing
power of ten. Digits appearing to the right of the decimal point represent
a value between zero and nine times a decreasing power of ten.

1.2. Binary system

Binary system uses only two digits, by convention the digits are 0 and 1.
This system is so widely used in computers... By coincidence or not this
system adjusts perfectly to computers... Computers operate using binary
logic. The computer represents values using two different voltage levels,
in this way we can represent 0 and 1. Like I said before the same applies
to binary system, it is well adjust to computer anatomy!

1.2.1. Converting a binary number to a decimal number
Apply the same rule we saw in 1.1, but with powers of two.
Example: 1010 -> 1 * 2^3 + 0 * 2^2 + 1 * 2^1 + 0 * 2^0 = 10
1.2.2. Converting a decimal number to a binary number

We have two ways to do it:

1.2.2.1 We consecutively divide the decimal value by a power
two(keeping the remainder), while the result of the division is different
than zero. The binary representation is obtained by the sequence of
remainders in the inverse order of the divisions.

Consider the number 10(in decimal):

10 / 2
0 5 / 2
1 2 / 2
0 1 / 2
1 0

So in binary we write 1010

1.2.2.2 You can try to find out the number by adding powers of two,
that added will produce the decimal result.

Consider for example number 123... hmmm it's a number not less than 2^0
and not greater then 2^7. Cool…

2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
0 1 1 1 1 0 1 1 because 1 * 2^6 + 1 * 2^5 + 1 *
2^4 + 1 * 2^3 + 0 * 2^2 + 1*2^1 + 1 * 2^0
= 123
Our result is 1111011.

1.3. Hexadecimal system

You saw how many digits took to represent the number 123 in binary. 7
digits! Imagine 1200, 10000,... it hurts. So programmers had to choose
another numbering system, just to "talk" to the machine... and no... it's
not the decimal system!! You saw the trouble we had to convert one simple
number like 10 between decimal and binary... I think you don't want to
spend half of your life doing that. Engineers thought on that and they
elected the hexadecimal system... Hexadecimals is the "english" for
computers. They have two special features:
- They're very compact
- it's simple to convert them to binary and vice-versa. A
hexadecimal number has digits with a value between 0 and 15 times a
certain power of sixteen. Because we only know digits between 0-9 we have
to use six more digits! We can use the 6 first letters of the alphabet.
Let's see a example: FF = 15 * 16^1 + 15 * 16^0 = 255 (16) (10)

Converting between binary and hexadecimal is very easy! To convert binary
to hexadecimal remember that every four digits correspond to a single
hexadecimal digit... to convert back to binary just apply the inverse
rule! Let's take a look at the next example:

110 1011 = 0110 1011 =6B
(2) (16)

It's very easy!! To make things easier, take a look at the following
table:

################
# D # H # B #
################
# 0 # 0 # 0000 #
# 1 # 1 # 0001 #
# 2 # 2 # 0010 #
# 3 # 3 # 0011 #
# 4 # 4 # 0100 #
# 5 # 5 # 0101 #
# 6 # 6 # 0110 #
# 7 # 7 # 0111 #
# 8 # 8 # 1000 #
# 9 # 9 # 1001 #
#10 # A # 1010 #
#11 # B # 1011 #
#12 # C # 1100 #
#13 # D # 1101 #
#14 # E # 1110 #
#15 # F # 1111 #
################

1.4. Conventions

Programming in assembly, requires you to obey some rules when using
numbers, because you can use three different numbering systems.

When writing a number:

- all numbers have to start with a decimal digit
- all numbers end with a letter, indicating the type of number:
. for hexadecimals the letter is h
. binary numbers end with b
. decimals end with t or d We will use the following notation:

Xn Xn-1 ... X2 X1 -> Xi represents a bit, and i<-[0,1,...,n] represents
it's position.

Journey To A Linux Desktop

As the holidays approach and we wind down to the end of the year, we all tend to look back on our accomplishments. This year, I am reminded that I am approaching the one-year anniversary of my move to a Linux desktop. For those of you who really want to learn Linux, I hope my experiences will help you take the plunge in 2010!

What prompted my move: I needed a more powerful laptop. I had my personal laptop configured as a dual-boot machine ever since Novell bought SUSE. Dual-boot is fine, but in my haste to get things done, I would inevitably drop back to Windows ... and that just wasn't working out well. Time to dig in, work through the issues, and find new, powerful applications that ran on Linux.

The hardware: Last year's holiday season yielded some great deals. While I could have bought a new system with Linux installed so that driver availability would be guaranteed, I decided to take a gamble and buy a Dell Studio 15 off the shelf at Staples and work through any driver issues I might encounter. This unit has a 64 bit processor, a 320G hard drive, and 4G of RAM.

Driver issues: While SUSE Linux Enterprise Desktop 10 SP 2 ships with a great many drivers (including loads of printer drivers), I had two problematic pieces off hardware: the ATI graphics card and the Broadcom wireless card. After lots of searching, I finally found the best answers for my issues at www.opensuse.org. If you go the Ubuntu route as many people do, the Ubuntu forums will be your best resources.

* For information on how to install Broadcom wireless drivers on SUSE please see: http://en.opensuse.org/SDB:Broadcom_(BCM4306)_WLAN_Installation_under_SUSE.

* For information on dealing with ATI's graphics cards, please see: http://en.opensuse.org/Ati.

* For a list of models and hardware compatible with SUSE, please see: http://en.opensuse.org/HCL or http://www.suselinuxhcl.org/.

Software replacement: One of the main reasons people avoid moving to Linux is that many pieces of commercially-available software are written only for Windows. There has been more movement to write for the Mac, but Linux support can lag behind. Enter the open source community. I found some great replacements for software I use regularly ... and some of it actually works better than the Windows versions I had been using! Here are just a few of the applications I am currently running:

* Office Productivity Suite: If you have not looked at OpenOffice recently, you should definitely take some time to explore! The 3.0 version is greatly improved. I have been able to do most of what I need with OpenOffice, and actually like the Calc program better than Excel. SUSE also comes with Acrobat Reader and Planner (a project management program) already installed.

* Photo Editing: Gimp is included with SLED and does everything I would have used Paint for, and more.

* Diagrams: For the more advanced Visio functions, check out Dia. If you just need to do a flowchart or some other simple diagrams, I recommend using Draw in OpenOffice.

* Multifunction Printer Software: HP has some great tools included with their Officejet All-in-One printer/scanner/copier/fax machines. While I found the printer drivers for my unit (a 7410) included with SLED, I really wanted some of the more advanced functions (for example, scan to PDF) that I had on Windows. Enter the HP Toolbox found at http://hplipopensource.com/hplip-web/index.html. When this program installs, it uses xsane for scanning documents to image files for PDF. I got all of the functions I needed ... plus, I no longer get those annoying update messages from Windows!

* Broadband Wireless: OK, I know this is actually hardware, but when I migrated I could not find a version of Verizon's VZAccess Manager to connect the card. After a bit of digging, I found that I could configure the card as a modem (which it is) and use Kinternet as my dialer. Quick and simple and no need to install more software. A quick search at www.google.com/linux should get you the answers you need for your card. If not, instead of putting in the card name, try searching on "EVDO card."

As I mentioned at the beginning of this article, I have been working with this laptop since last December and absolutely love it. The only way to truly learn Linux is to work with it every day. If you are bored over your Christmas break and want to play, give Linux a try. I will never go back!

Ubuntu Linux Toolbox: 1000+ Commands for Ubuntu and Debian

Aimed squarely at aspiring Linux power users and professional
administrators, the Ubuntu Linux Toolbox offers more than 1000 examples
of useful Linux command lines. This compact, handy reference is made to
carry with you, whether you are maintaining hundreds of Linux systems or
just want to dig beneath the surface of your Ubuntu desktop system. This
is the Linux reference book you need to step up to the next level.

DownLoad
Code:
http://hotfile.com/dl/20799536/cf2c8db/Wiley.Ubuntu.Linux.Toolbox.rar.html

Followers

My Friends

Send Messange




Copyright 2009-2010 Junkelsee.tk. All Right Reserved

Back to TOP