Very important please

Discussion in 'Assembly Language Programming (ALP) Forum' started by valley, Sep 27, 2009.

  1. valley

    valley New Member

    Joined:
    Sep 22, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Write a program to sort a list of numbers for microprossecer 8051, The numbers will be stored in memory starting at data memory address 0x40. The list will be no more than 5 bytes long. The “end of list” byte will be 0xFF, and that value will not occur in the list of data.
    What i did is that:

    CSEG AT 20
    ?C_START:MOV A,0x40
    CJNE A, #255, NOTEQUAL
    jmp loop
    NOTEQUAL: INC R3
    MOV A,0x41
    CJNE A, #255, NOTEQUAL2
    jmp Final
    NOTEQUAL2: INC R3
    MOV A,0x42
    CJNE A, #255, NOTEQUAL3
    jmp Final
    NOTEQUAL3: INC R3
    MOV A,0x43
    CJNE A, #255, NOTEQUAL4
    jmp Final
    NOTEQUAL4: INC R3
    MOV A,0x44
    CJNE A, #255, NOTEQUAL5
    jmp Final
    NOTEQUAL5: INC R3
    Final: mov R0,#0x40
    mov a,@R0
    mov 0x60, a
    INC R0
    mov a, @R0
    SUB a,0x60
    JC Final

    LOOP: ljmp loop
    PUBLIC ?C_START
    END

    can you fixed it and where I make my mestake
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    It can make it a lot easier if we know what kind of problem we're looking for.
    Did the code assemble without warnings and errors? If not, what were they?
    What does the program do wrong?
    What input values did you give (i.e. what values did you place at 0x40)?
    What was the result of running the code - was it partially sorted, not sorted at all, sorted in the wrong order, or did the program get stuck in an infinite loop or crash, or do something else weird?
    Can you identify which line of code the program started going wrong?

    Did you try dry running the code, executing the instructions one by one yourself as if you were the processor, keeping track of register and memory values with pen(cil) and paper?
     

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