answersLogoWhite

0

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

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

RafaRafa
There's no fun in playing it safe. Why not try something a little unhinged?
Chat with Rafa
ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi
MaxineMaxine
I respect you enough to keep it real.
Chat with Maxine
More answers

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.

User Avatar

Wiki User

15y ago
User Avatar

  • 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
User Avatar

Wiki User

12y ago
User Avatar

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.

User Avatar

Wiki User

14y ago
User Avatar

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

User Avatar

Wiki User

12y ago
User Avatar

model largest

data segment

a db 255

data ends

.stack

code segment

assume cs:code,ds:data

start:'

/aljioh

User Avatar

Wiki User

13y ago
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