Sunday, 24 July 2016

Take a quick look at what is 8085 programming!!!

It is important to know why are we going to start coding in 8085 assembly.
8085 is not the latest microprocessor, not even the oldest one. It was neither be too popular nor be successor of any popular processor. So why peoples say to learn 8085 programming?

Here is the reason=>
Take an look at the list given here Wikipedia.
After seeing this ,it gets crystal clear that it was Intel's 4th microprocessor which came in early 1976.
The reason behind learning 8085 is that the actual assembly programming concept took its plane from here only. 8085 contains all the basics ( which is actually not at all basic) about microprocessor.
We today are seeing Pentium, Xeon, Atom, i3,i5,i7 processors but all these contain the same instructions as that of 8085 but with a lot of upgrades.
It is said in this like way that we learn firstly C than C++ than Java and than Android programming, only after that we can code candy crush/clash of clans.

=>Basics of 8085
There are some basic terms in assembly programming that needs be understood before moving ahead.I'm not going to explain hardware related terms here, my main focus will be only on software related part.

Operand-
The entities on which we perform various operations are called operands.

Opcode-
The keywords through which we perform operations on operand are called opcode.

Instructions-
The entire code containing opcode and operand is called an Instruction.
Above is the list of all the opcodes available in 8085 with which we code in ours simulators.

Related Hex Codes-
The instruction is firstly converted into corresponding hex codes and then it is executed by processor.

Registers-
These are the group of bits where we place our operands.
Before performing any operations we require to place one of the operands in Acc or A (Accumulator) and rest are placed in either of registers (B,C,D,E,H,L). All these are 8bit registers that is we can only keep numbers from 0-255 (or -127to128). Rest we will discuss later.

That's it!!! Nothing more is required.
No data type.
No Integer.
No floats.
No functions/methods.

Lets Code!!!

Wednesday, 20 July 2016

Learn Binary and Hexadecimal numbers

Binary is the basis of all computer components whether you the laptop/keyboard you are typing on right now or the smart phone just ringing on your desk or the set top box you are using to watch TV.
Everywhere is the binary.

-> But What is this BINARY actually?
Computer chips/microprocessor only understand the language which is either turn on or off. They can't understand your english, hindi or french. So technicians found the way to develop machines which could be programmed using this method and they developed binary!!

"Binary is an set of numbers which consist of only two digits 0 and 1 and has the base of 2."

The definition is little confusing cause we have only seen and counted everything in numbers where we had digits from 0 to 9. Here still have all those numbers but the only thing is that base has changed. You may probably be knowing the logarithmic functions where the base word is used, this base is the same thing.
Each of 1s and 0s are called bits in machines.

-> What is Hexadecimal number system ?
For convenient of humans, techies created a new number system hexadecimal.

"Hexadecimal consist of numbers from 0 to 9 and letters A to F and has base of 16"

Binary will not be to convenient for our general use cause it may make lots of confusions (bring me 111 bananas mean bring me 7 bananas and 111 bananas).

-> Then how do we represent numbers in binary and Hexadecimal ?
Here is the list of all natural numbers with there binary equivalent--

Binary Equivalent Natural Number Hexadecimal Equivalent
000000
000111
001022
001133
010044
010155
011066
011177
100088
100199
101010A
101111B
110012C
110113D
111014E
111115F

These are the only basic numbers till 15 in various systems. You can represent other numbers in binary and hex as well by knowing the correct sequence of numbers.
Don't worry If you couldn't understand it today. It takes a little practice to learn this.
Once you have learnt this table it'll be easy for you to learn 8085 in depth.

But wait is it convenient to represent all these numbers in such a way. If I'll ask what binary equivalent of 158, you won't be able to answer even I don't know by heart. And even machines take a bit longer to process big numbers.so what can we do to solve the problem.

For this we have BCD numbers (Binary Coded Decimal numbers). Here all the numbers are only represented in chunk of four bits. So it makes processing faster machine's and ours as well.
For this you don't need to remember anything else other than the table given above.
Lets take the same example again. 158 in binary is 0001 0101 1000.
And for converting into hex divide it by 16 and write the quotient and remainder in sequence.
158/16=9 and remainder is E(14), so hex equivalent will be 9E for 158.
Lets move ahead!!

What to know before starting with 8085 ?

There's no special requirement for somebody to learn assembly language programming but yeah! If you are not from a technical background (mean you are unaware of basic computer functioning)
then it'll take a little longer for you to start with 8085.

Here are the basic requirements for someone to JUMP AHEAD-
1) BINARY and HEXADECIMAL NUMBERS ->
This is one of the fundamental necessity for learning assembly programming; reason, cause any mathematical or logical action will you perform, in assembly that will be done in binary only and to understand the flow of these binary numbers you'll require to learn hexadecimal.
You can go to my another post where I've discussed about binary and hexadecimal numbers briefly.

2) Need to know the FLOW of program ->
As any other high languages like c++, java you'll not find any kind of bugs generating in your program when you'll code in assembly if you will be very much familiar with the concept where your program's flow is going and how can you control that. You will be thinking why am I saying so to keep track of program. The reason is because in C++-java, it is to find where have you written which codes and you most often don't use goto statements in program but here in assembly, everything is based on gotos only where only jumps are used for any conditions, for loops, switches and for everything.

3) Good MATHEMATICS and LOGIC ->
Actually this is the one of the basic requirement for learning any programming language but when comes to assembly it becomes critical. I know if you have come here, you must have scored at least 60/100 in mathematics in all your carrier till now. Even I never scored more than 90 in any of the semesters in mathematics so I'll not consider you Albert Einstein.

4) Enough time to seat on your table ->
This is THE MOST IMPORTANT requirement. If tomorrow is your exam and you have just started learning it then forget everything and go n sleep. Because you can't just learn assembly programming in a midnight and top the exam. It requires good time to be spent and enough practice to be done.

Thats it !!!

NO further skills are required to move ahead. If you have everything whatever is mentioned above then you you'll never find any kind of difficulty in learning.

Further, you require an computer or a laptop where you'll code in a simulator to check your program.
Here are the few well known 8085 simulators that you can use for practice---
1) 8085 SIMULATOR IDE (with 8085 basic compiler)
2) j8085sim - an 8085 simulator in Java!
3) GNU 8085 Simulator
4) 8085 Simulator version 2 Free Download
There are many more you can use.
But personally I use the forth in the list.
That depends upon you flavor what will you prefer to use because every simulators follow the same rules of syntax. It is not like that every c compiler will be having theirs own rule that you must follow.

But wait why we are we using an simulator and not an compiler?
This is because in the days it was launched in the market there weren't any computers or keyboard where will you type stuffs and that will be shown on the screen. There were only assembly kits where you needed to put your instructions in the form of hexadecimal numbers.
Today we don't have those like kits so we prefer to use an simulator which works like an kit to execute instructions.
So lets start!!!