section .data
    msg db 'Enter A for ascending or D for descending: ', 0
    result_msg db 'Fibonacci Sequence: ', 0

section .bss
    choice resb 1
    n resd 1

section .text
    global _start

_start:
    ; Display message to prompt user for choice
    mov eax, 4
    mov ebx, 1
    mov ecx, msg
    mov edx, 40
    int 0x80

    ; Read user choice
    mov eax, 3
    mov ebx, 0
    mov ecx, choice
    mov edx, 1
    int 0x80

    ; Read n (number of terms) from user
    mov eax, 3
    mov ebx, 0
    mov ecx, n
    mov edx, 4
    int 0x80

    ; Convert ASCII to integer
    mov eax, [n]
    sub eax, '0'
    sub eax, 2Ch ; Subtract ASCII value of '0'
    mov [n], eax

    ; Initialize variables
    mov ecx, [n]
    mov ebx, 0
    mov edx, 0
    mov eax, 1
    mov esi, 1

    ; Display result_msg
    mov eax, 4
    mov ebx, 1
    mov ecx, result_msg
    mov edx, 18
    int 0x80

    ; Loop to generate Fibonacci sequence
    fibonacci_loop:
        ; Display current Fibonacci term
        mov eax, 4
        mov ebx, 1
        mov ecx, esi
        mov edx, 1
        int 0x80

        ; Calculate the next term
        add esi, ebx
        mov ebx, eax

        ; Update loop counter
        dec ecx
        jnz fibonacci_loop

    ; Exit program
    mov eax, 1
    xor ebx, ebx
    int 0x80

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: