Assembly Language Discussion Thread

Anish

Spectre
Re: Assembly language programing in 8086up......!!

Sorry dude, not yet tried any simulator yet....
 
OP
RITESH

RITESH

Broken In
Re: Assembly language programing in 8086up......!!

OK, i want make a program for dividing two no's ................
What will be the logic for it??
 

doomgiver

Warframe
Re: Assembly language programing in 8086up......!!

the DIV or IDIV operator will do fine

EMU8086 <-best site to learn from, imho

org <whatever>

mov <stuff var here>
mov <>
div <>

8086 instructions
 
OP
RITESH

RITESH

Broken In
Re: Assembly language programing in 8086up......!!

I know 8086 dividing program, i want to know about 8085 up.....
 

Anish

Spectre
Re: Assembly language programing in 8086up......!!

repeated subtraction is the logic..

1. Get the divisor and divident
2. subtract the divisor as many times as you can without a carry
3. The number of times you can subtract without getting a carry is the quotient

For example, to divide 4 by two,
I am just writing the algorithm..
Code:
         move 4,r1   //4 is loaded in register 1
         move 2,r2   //2 is loaded in register 2
         clear r3      //register 3 is cleared to hold the quotient
start: sub r1,r2     //r2 contents (2) is subtrated from r1 contents(4) and answer is placed in r1
         inc r3         //r3 is incremented .i.e. we have succesfully subtracted 2 from 4 once
         jnc start     // if carry flag isnt set, go to the label start and continue the loop
end                    //if carry flag is set, end the program
 
OP
RITESH

RITESH

Broken In
Re: Assembly language programing in 8086up......!!

Hi,

move 4,r1 ??
it should be mov r1,4....

& the program is not clear i have doubt pls explain it...........
 

Anish

Spectre
Re: Assembly language programing in 8086up......!!

^^ have i not stated that its just an algorithm dude?? ofcourse I didnt use the exact keywords
 
Re: Assembly language programing in 8086up......!!

Finished this course last semester and learnt 8086 and PIC16 assembly languages... Sheesh, wish I'd seen this thread sooner....
 

Anish

Spectre
Re: Assembly language programing in 8086up......!!

Hi ritesh, here is the program for dividing two numbers. In my example, i took 23h and divided it by 05h and the quotient is 07h. I've made quotient to appear in the register A.

Code:
 mvi a,23h
 mvi c,05h
 inr b
 sub c
 jnc 0004h
 dcr b
 mov a,b
 hlt

Here, you can replace 23h and 05h by any 8 bit number.:smile:
 

Prime_Coder

I'm a Wannabe Hacker
Re: Assembly language programing in 8086up......!!

Anybody here, will you please elaborate what the following code does?

org 100
inp a
inp b
lod a
add b
str c
out a
b blo 1
c blo 1
hlt

I could guess that this code is for addition of 2 numbers, but what about that "str c" and all the next part? I couldn't understand that completely.
 

Anish

Spectre
Re: Assembly language programing in 8086up......!!

where did you get that code? please do refine it.
 

doomgiver

Warframe
Re: Assembly language programing in 8086up......!!

it will check the carry flag, if it is not set, it will go to 0004h
 

Anish

Spectre
Re: Assembly language programing in 8086up......!!

in this jump where it will go, at sub c??

yeah.. it will repeat sub c until the carry flag is set. And the carry flag is set when the number is no more divisible.
 
OP
RITESH

RITESH

Broken In
Re: Assemble language discussion thread

The program is working, but i don't understand its alog.....
 

Anish

Spectre
Re: Assemble language discussion thread

First understand how division is preformed in computers... To us all computer is a wonderful machine which does all sorts of work.. But actually, this machine knows nothing more than addition!. Subtraction is addition of negative numbers, multiplication is repeated addition, division is repeated addition of complementary dividend.

now, for example, what is 12/4?
answer is 3. we get it by a long hand division(remember grade 2 math)
but the computer does it some what like this:
takes 12 and calculates how many times 4 can be subtracted from it! its just simple as it is. 12-4=8(1 time) 8-4=4(2 times) 4-4=0(3 times). It can no longer subtract 4 from 0 with out carry. so it assumes the quotient to be 3.!

So, let me explain it line by line...

mvi a,23h - loads the a register with 23h
mvi c,05h - loads the c register with 05h
sub c - subtracts 05h from 23h and places the answer in a register
inr b - increments b register for each subtraction count of 05h from 23h
jnc 0004h - if the carry flag is not set, then it jumps to 4th memory location.
dcr b - this is for adjusting the calculation
mov a,b - This is needed just to move the answer to a register.
hlt - stops the program.
 
OP
RITESH

RITESH

Broken In
Hi again,

How to use SOD & SID in oshon 8085...

& write a program for 1 sec delay.........

Thanks.....!!
 
Top Bottom