Add 10 numbers stored in consecutive memory locations

Discussion in 'Assembly Language Programming (ALP)' started by shabbir, Oct 20, 2007.

  1. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83

    Introduction



    More ALP program time and this time its Addition of 10 numbers stored in memory at consecutive locations

    Code with all lines explained



    The subroutine we will use is as follows. This will behave as a delay for our counter
    Code:
        LDA XXXX // Some memory location say 8500
        // Load the accumulator with the address of memory viz 8500    
        MOV D, A
        // Move the accumulator value to the register D
        MVI E, 09
        // Load the E register with the counter 10 - 1
        LXI B, XXXX + 1 // Next memory location from where we have done LDA - 8501
        // Load immediate B C with the memory location
        LDAX B
        // Load Accumulator indirect A=[BC]
        ADD D
        //Add the content of the Accumulator to the Register D
        MOV D, A
        //Move the value in D to the Accumulator or register A
        INX B
        // Increment BC register pairs
        DCR E
        // Decrement the counter register
        JNZ XXXX // LDAX B Location
        // Jump on no zero
        STA XXXX // Suitable memory location
        // Store the output into a memory location   
        HLT
        // Stop the program
    
     
  2. biren

    biren New Member

    Joined:
    Aug 20, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    How do we get square of a number in ALP
     
  3. login33

    login33 New Member

    Joined:
    Aug 25, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    mvi b,09h ; load the number you want to sqaure
    mov c,b ; c is the counter for repeating loop
    mvi a,00h ; empty the contents of accumulator
    repeat: add b ; add n to accumulator, n times e.g add 9, 9 times
    dcr c
    jnz repeat
    hlt ; the answer lies in the accumulator, you can also store it at some mem location or output port
     
  4. rsquareshelke

    rsquareshelke New Member

    Joined:
    Dec 30, 2010
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    0
    what is repeat: means
     
  5. Healthcare

    Healthcare Banned

    Joined:
    Jun 14, 2012
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    REPEAT: This statement will add the content of b with content of accumulator again and again till the value of c is decreased to 0.
     
  6. soorajhaswani

    soorajhaswani New Member

    Joined:
    Jan 13, 2013
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    hi i am using SDK6800 emulator assembly program
    i need to create this below mentioned program
    Create a 6800 program which determines if a number, n, is prime. A prime number has only two factors. Your program should work with any input for n where n >= 0 and n <= 127. If the number is prime, then print the letter Y to the display, otherwise print the letter N.

    The following example has n = 5 and should print Y since n is a prime number.

    n .byte 5

    please help

    thanks
    sooraj
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice