John Delmark Aguilar
Would you like to react to this message? Create an account in a few clicks or log in to continue.
John Delmark Aguilar

Personal Forum
 
HomeSearchLatest imagesRegisterLog in

 

 Fibonacci Assembly Language Code

Go down 
AuthorMessage
dElmARk
Admin
Admin
dElmARk


Posts : 92
Join date : 09/04/2012

Fibonacci Assembly Language Code Empty
PostSubject: Fibonacci Assembly Language Code   Fibonacci Assembly Language Code Icon_minitimeMon Dec 10, 2012 10:09 am

Code:
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
Back to top Go down
https://delmark.forumtl.com
 
Fibonacci Assembly Language Code
Back to top 
Page 1 of 1
 Similar topics
-
» Factorial Assembly Language Code
» Language Basics

Permissions in this forum:You cannot reply to topics in this forum
John Delmark Aguilar :: dElmARk Productions :: Assembly Language-
Jump to: