answersLogoWhite

0


Best Answer

Source program :

  • MVI D, COUNT : Initialize counter
  • MVI B, 00 : Initialize variable to store previous number
  • MVI C, 01 : Initialize variable to store current number
  • MOV A, B :[Add two numbers]
  • BACK: ADD C :[Add two numbers]
  • MOV B, C : Current number is now previous number
  • MOV C, A : Save result as a new current number
  • DCR D : Decrement count
  • JNZ BACK : if count 0 go to BACK
  • HLT : Stop.
User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

LXI H, XXXXH :Memory location to store the series MOV M, 00H :Store first number of series INX H :Go to next location MOV M, 01H :Store second number of series INX H :Go to next location MVI D, COUNT :Initialize counter MVI B, 00H :Initialize variable to store previous number MVI C, 01H :Initialize variable to store current number Back : MOV A, B :Load first number in accumulator ADD C :Add two numbers MOV B, C :Current number is now previous number MOV C, A :Save result as a new current number MOV M, A :Store next number in memory INX H :Go to next memory location DCR D :Decrement count JNZ Back :If count=0 go to Back HLT :Stop.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago
  • MVI B, 09 : Initialize counter
  • START : LXI H, 2200H: Initialize memory pointer
  • MVI C, 09H : Initialize counter 2
  • BACK: MOV A, M : Get the number
  • INX H : Increment memory pointer
  • CMP M : Compare number with next number
  • JC SKIP : If less, don't interchange
  • JZ SKIP : If equal, don't interchange
  • MOV D, M
  • MOV M, A
  • DCX H
  • MOV M, D
  • INX H : Interchange two numbers
  • SKIP:DCR C : Decrement counter 2
  • JNZ BACK : If not zero, repeat
  • DCR B : Decrement counter 1
  • JNZ START
  • HLT : Terminate program execution
This answer is:
User Avatar

User Avatar

Wiki User

13y ago

I made this program in C for you:

#include <stdio.h>

#include <stdlib.h>

#include <ctype.h>

#include <string.h>

#include <conio.h>

typedef unsigned long int ulong;

ulong fibonacci( ulong );

int main( void ){

int iNumber, iExit = 0;

char iChoice;

do{

system("cls");

printf( "Fibonacci serie:\n\nEnter number: " );

scanf( "%d", &iNumber );

printf("\nFIB(%d) = \n", iNumber);

for( int i=1; i<=iNumber; i++ ){

// These square brackets highlight

// the last number in the sequence.

if(i==iNumber){ printf("["); }

printf( "%#5d", fibonacci(i) );

if(i==iNumber){ printf("]"); }

if(i<iNumber){ printf(" "); } // Number separator

// Go to next line every 10 numbers

if(i % 10 0 !strchr( "yYnN", (char)iChoice ) );

if( strchr( "nN", (char)iChoice ) ){

iExit = 1;

}

} while ( !iExit );

system( "cls" );

system( "pause" );

return 0;

}

/*

Sequence:

1 1 2 3 5 8 13 21 34 55 89 ...

Definition:

FIB(0) = 0;

FIB(1) = 1;

FIB(2) =

FIB(1) + FIB(0) =

1 + 0 = 1

FIB(3) =

FIB(2) + FIB(1) =

FIB(1) + FIB(0) + FIB(1) =

1 + 0 + 1 = 2

FIB(4) =

FIB(3) + FIB(2) =

FIB(2) + FIB(1) + FIB(2) =

FIB(1) + FIB(0) + FIB(1) + FIB(1) + FIB(0) =

1 + 0 + 1 + 1 + 0 = 3

FIB(5) =

FIB(4) + FIB(3) =

FIB(3) + FIB(2) + FIB(3) =

...

... = 5

And so on...

*/

ulong fibonacci(ulong n){

if( n==0 n==1 ){

return n;

} else {

return fibonacci(n-1) + fibonacci(n-2);

}

}

I added a Pastebin link as a related link, there you'll see the code highlighted and indented.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Readnum macro num

mov ah,01h

int 21h

sub al,'0'

mov bh,0ah

mul bh

mov num,al

mov ah,01h

int 21h

sub al,'0'

add num,al

endm

print macro msg

mov ah,09h

mov dx,offset msg

int 21h

endm

data segment

msg db 'program for generating fibonacci series ..$'

msg1 db 0dh,0ah,'enter the limit of the series..$'

msg2 db 0dh,0ah,'the series is..$'

fib dw 100 dup(0)

num db ?

Newline db 0dh,0ah,'$'

result db 20 dup('$')

data ends

code segment

assume cs:code,ds:data

start:

mov ax,data

mov ds,ax

print msg1

readnum num

mov si,offset fib

mov bx,00

mov word ptr[si],bx

add si,02

inc bx

mov word ptr[si],bx

mov ch,00

mov cl,num

nextfib:

sub si,02

mov ax,word ptr[si]

add si,02

mov dx,word ptr[si]

add ax,dx

add si,02

mov word ptr[si],ax

inc bx

cmp bx,cx

jl nextfib

print msg2

mov bx,00

mov si,offset result

nextprn:

mov ax,word ptr fib[bx]

call hex2asc

print newline

print result

add bx,02

loop nextprn

mov ah,4ch

mov al,00h

int 21h

hex2asc proc near

push ax

push bx

push cx

push dx

push si

mov cx,00h

mov bx,0ah

rpt1:

mov dx,00

div bx

add dl,'0'

push dx

inc cx

cmp ax,0ah

jge rpt1

add al,'0'

mov [si],al

rpt2:

pop ax

inc si

mov [si],al

loop rpt2

inc si

mov al,'$'

mov [si],al

pop si

pop dx

pop cx

pop bx

pop ax

ret

hex2asc endp

code ends

end start

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

model largest

data segment

a db 255

data ends

.stack

code segment

assume cs:code,ds:data

start:'

/aljioh

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a Program for ascending order in 8085 microprocessor?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you write Ascending order program using 8086 microprocessor?

One many find this answer on YouTube. One also may find out how to write ascending order programs using an 8086 microprocessor by looking at the owners manual.


A C program using dynamic memory allocation to sort n names in ascending order?

Writing a C program that uses dynamic memory allocation to sort names in ascending order is a typical computer science assignment. To write this program, you must be in UNIX.


How do you write a program to read set of numbers using by an array and display the ascending order of the given input numbers?

To write a C++ program to display the student details using class and array of object.


How can you write a c program to display numbers in ascending order in array?

I know how to do this and you need to know how to do this. Why don't you do your best at writing this program and if it does not work then ask for help. You will not learn anything if I give you the answer.


What will be the program to arrange numbers stored in array in ascending order using pointers?

sorry


How do you write polynomials in ascending and descending order?

before and after use an conpair the results


Write an Assembly language program which implements sorting algorithm both ascending and descending order and display those numbers with certain delay say of 5sec between successive displays?

das


Write 0.1 0.01 0.9 and 0.09 in ascending order?

0.01, 0.09, 0.1, 0.9


Can data be stored in ascending order?

Data can be stored in ascending order, descending order or no particular order.


What are the multiples of 18 in ascending order?

The multiples of 18 in ascending order are 12345678


Data can only be stored in ascending order?

Data can be stored in ascending order, descending order or no particular order.


Can Data can only be sorted in ascending order.?

No, it can be sorted either in ascending or descending order.