Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

HOW TO ADD 2BINARY NUMBER USING microcontroller

Status
Not open for further replies.

bero

New Member
i need to design a cct that add 2 binary numbers each is 4 bit using microcontrol using assemply
 
So you simply want to add 2 4-bit numbers to get a 5 bit result ?
What platform (what controller/language) are we talking about?
 
hi boys
can any one tell me how i can perform multiplication for two bytes
what i remmember is is to add onebyte to it self for loop of second byte
there is other way by make shift in onebyte(register) but i donot remmber
so if any one know pls tell me
 
besho741 said:
hi boys
can any one tell me how i can perform multiplication for two bytes
what i remmember is is to add onebyte to it self for loop of second byte
there is other way by make shift in onebyte(register) but i donot remmber
so if any one know pls tell me

To multiple by two (or powers of 2) you can simply shift the required number of times (you can divide by powers of 2 in the same way). Anything else, you need to use loops.

You don't mention the processor you are using, but there's likely to be plenty of code on the net if you google for +multiply +processor name.
 
add 2 binary numbers

There are instruction set for each mocro controllers.
By using instructions, small assembly program can be write to add two binary numbers.
Each instruction is explaind with example on the micro controller manual

I wil give small example.

lets take tw0 numbers as 12 and 8

in Hex decimal it is c and 8


lda c 'load accumulator A with c
ldb 8 'load accumulator B with 8
add ' add accumulator B to A and store result into A
sta 0100 'store the result into memory location 0100 Hex.

instruction of assembly is look similar to "lda, ldb etc.
numbers and memory locations is much easy to write in HEx than binary.

Read micro controller instruction book or technical manual or user guide. it is very easy to understand

good luck

Mahinda
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top