September 8, 2011

Introduction to C Assembly Programming - Part 1

Hello everyone! we have started Assembly Programming series.. Here we going to talk about assembly Programming which is a low-level language..
Introduction to C Assembly Programming - Part 1

Here we going to talk about what is assembly language and what is its scope in turbo c.

The question is too long to explain so i will divide it in parts and let you know one by one

you must have heard that assembly language as BLACK ART suited only to hackers and computer wizards the reason is that it allows both speed and greater control to computer resources and hardwares.It is a language used to do tiny tasks in a large program.A simple program in assembly requires more lines of code than analogus C code.In assembly their aint any predefined functions like printf() or cout instead you must rely on hardware(BIOS functions) for it, thats the hell with assembly.
Since different processors have different config the program for one processor becomes unportable for another processor another flaw.

But there is significant reason why to use it even with these probs

1 . SPEED - when you write a program in c there often is redundant code generated by compiler that would run faster if written in assembly. Though modern compilers are good at it but still there is room for enhancement.

2 . CONTROL - while you have significant access to some critical resources in C but you sometimes need even more freedom for ex

there is no way to run simultaneously 2 or more programs in turbo C..........

Here assembly language can do good for you(however complex it may be)
second thing is that in assembly you are the decider who decides exactly what to do?? how to do ?? Even more minute things like calling function and parameter passing is in your control.......


Most assembly language books start with basic conversions of different bases

BASE 10 => decimal

it is the basic and perhaps the most usefull system for users its base is 10 means you have 10 numbers in this system 0,1,2,3,4,5,6,7,8,9
the numbers used are in this format

msd(mostsignificant)----------lsd(least significant )

the no 235 is like
2*(10^2) 3*(10^1) 5*(10^0)
in decimal.

The start from right with count 0 and exponent its base(10) with count it recieves then multiply and add

BASE 2 => binary numbers

0 and 1 is what it is about
1010 is like

1*(2^3) 0*(2^2) 1*(2^1) 0*(2^0) = 10 in dec

we start counting from right with 0 and exponent its base(2) with the count it recieves then multiply and add.

You precede a suffix b after binary no in assembly 1010b

BASE 16 => hexadecimal
a hexadecimal no is
what matters most in its base says it has 16 numbers


2F is hexadecimal no.
You add suffix h after hex no in assembly 2Fh


most of the times you need to convert hex to bin or to dec... So i explain then only

you need a ascii table to covert any of them

0 0 0 0 --- 0
0 0 0 1 --- 1
0 0 1 0 --- 2
0 0 1 1 --- 3
0 1 0 0 --- 4
0 1 0 1 --- 5
0 1 1 0 --- 6
0 1 1 1 --- 7
1 0 0 0 --- 8
1 0 0 1 --- 9
1 0 1 0 --- A
1 0 1 1 --- B
1 1 0 0 --- C
1 1 0 1 --- D
1 1 1 0 --- E
1 1 1 1 --- F

what you do is select the no and get its bio form then apply above logic to convert it in dec.

PART 2 - will explain different operations on these nos the concept of registers


Related Posts :


Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

Related Posts with Thumbnails