Ask Experts Questions for FREE Help !
Ask
    Manik's Avatar
    Manik Posts: 1, Reputation: 1
    New Member
     
    #1

    Sep 25, 2005, 04:22 PM
    Help with an Assembly Language program
    I've been taking an IBM Assembly Language class and for our first program, I have to print the first ten numbers of the Fibonacci numbers (0, 1, 1, 2, 3, 5, 8, 13, 21, 34), yet the slides and sample programs don't make any sense to me, are there any tutorials or examples that are on the net that would help me? Also here is what I was able to make so far, based off one of the examples.


    title sumNumbers Adds the first 10 number of fibonacci numbers
    .model small
    ;---------------------------------------------------------------------
    .data
    number word 0 ; Starting integer and 1st fibonacci number
    number2 word 1 ; 2nd number of Fibonacci
    count word 10 ; Number of additions
    type word 'Fibonocci' ; The type of numbers
    ;---------------------------------------------------------------------
    .code
    main proc far
    mov ax,@data ; Initialize
    mov ds,ax ; segment registers

    mov cx,count ; Initialize to count 10 numbers
    mov ax,number ; Move the first number to

    CountNum:
    inc ax ; Push ten numbers
    push ax ; incrementally
    inc bx ;
    push bx ;
    dec cx ; onto the
    jnz CountNum ; stack



    mov cx,count ; Initialize to add 10 numbers
    mov ax,00 ; Zero-out registers
    mov bx,00 ; used for addition


    AddNum:
    pop bx ; Restore value from stack
    add ax,bx ; Add restored value to sum
    dec cx ; One addition completed
    jnz AddNum ; Keep adding until count=0

    call decimal ; Display sum

    mov ax,4c00h ; End
    int 21h ; processing
    ;----------------------------------------------------------------------

    DECIMAL PROC ;Converts contents of ax to
    MOV SI,10 ; decimal and prints it
    MOV CX,0
    NONZERO: MOV DX,0
    DIV SI
    PUSH DX
    INC CX
    CMP AX,0
    JNE NONZERO
    DIGITLOOP: POP DX
    ADD DL,30H
    MOV AH,2
    INT 21H
    LOOP DIGITLOOP
    RET
    DECIMAL ENDP
    ;----------------------------------------------------------------------
    main endp
    end main

Check out some similar questions!

Replace Tub Drain Assembly? [ 2 Answers ]

I tracked down a tub leak coming from where the brass tub drain/overflow assembly connects with the ABS drain pipe (installed 30+ years ago). This will make the third similar repair I have done within the last 18 months. Is this typical for a 30+ year old house? Since I had to cut into the...

Leak in New Tub Drain Assembly [ 3 Answers ]

I just installed a new bath drain kit. Upon testing there is a small leak at the connection of the brass waste shoe and the brass tee connector. In this kit a slipnut tightens a rubber washer to seal that connection. Is there anything else I can use to seal that connection? Thanks. Steve

How to access memory cells under windows in visual c++ or assembly language [ 1 Answers ]

Dear sir or madam I am very fund of computer software specially in visual c++ or assembly language , but I do not know how to access memeory cells using these Languages . I may face some errors running the compiled source. Yours...

First language literacy and second language litera [ 1 Answers ]

What are the differences between first language literacy and second language literacy?


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.