1. active92

    Thread Starter New Member

    Oct 26, 2012
    10
    0
    sstack equ $30000
    ustack equ $20000

    org $10000
    memd0 ds.b $a5


    START ORG $1000
    lea sstack,A7
    andi.w #$dfff,SR
    lea ustack,a7
    jsr init
    move.b #3,d0
    jsr delay
    move.b #3,d0
    jsr ldelay

    trap #15

    org $2000
    init move.b #0,D0
    move.b d0,memd0
    rts

    delay sub.b #1,d0
    bne delay
    rts

    ldelay move.b d0,memd0
    move.b #3,d0
    jsr delay
    move.b memd0,d0
    sub.b #1,d0
    bne ldelay
    rts

    sub.b #1,d1

    END START

    This is a subroutine code. I need to draw a flow chart on this but I really have no idea how to do it. Can anyone help me please?
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,436
    3,360
    That's putting the carriage before the horse. One does not build a house and draw the plans after.

    Flowchart comes before the code. Flowchart dictates the code. Not the other way around.
     
  3. active92

    Thread Starter New Member

    Oct 26, 2012
    10
    0
    But this is my lab work. We are asked to make a flow chart. I don't really understand some of the parts and when I tried to ask, our lecturer doesn't want to answer them until the deadline is over. I need to submit it by tomorrow =(
     
  4. MrChips

    Moderator

    Oct 2, 2009
    12,436
    3,360
    Too bad, your instructor has it backwards and does not understand Top-Down design.
     
  5. active92

    Thread Starter New Member

    Oct 26, 2012
    10
    0
    But can't anyone help me on this? I need it urgently...
     
  6. MrChips

    Moderator

    Oct 2, 2009
    12,436
    3,360
    So what would you learn from this exercise if someone did it for you?
     
  7. active92

    Thread Starter New Member

    Oct 26, 2012
    10
    0
    After submitting it, I can ask the lecturer on all the parts I don't understand ...
     
  8. MrChips

    Moderator

    Oct 2, 2009
    12,436
    3,360
    So you just want the marks.
     
  9. active92

    Thread Starter New Member

    Oct 26, 2012
    10
    0
    marks before understanding it. i don't have a choice.
     
  10. MrChips

    Moderator

    Oct 2, 2009
    12,436
    3,360
    Well, what have you learned or read about flow charts so far?
     
  11. active92

    Thread Starter New Member

    Oct 26, 2012
    10
    0
    I know it started with initialize sstack, clear SR, initialize ustack, followed by subroutine, move 03 to d0 means delaying 3 seconds (not sure if this is right), then subroutine again and again move 03 to d0 and I'm stuck because subroutine started and before it ends, another subroutine started.
     
  12. MrChips

    Moderator

    Oct 2, 2009
    12,436
    3,360
    What do you mean by subroutine started and before it ends?
     
  13. active92

    Thread Starter New Member

    Oct 26, 2012
    10
    0
    its like jsr,jsr then rts. normally it should be jsr, rts, jsr, rts right?
     
  14. MrChips

    Moderator

    Oct 2, 2009
    12,436
    3,360
    No. The rts is in the subroutine.
     
  15. active92

    Thread Starter New Member

    Oct 26, 2012
    10
    0
    INSTRUCTION
    lea sstack, A7
    Andi.w #$dfff,SR
    lea ustack, a7
    jsr init
    move.b #0,D0
    move.b d0,memd0
    rts
    move.b #3,d0
    jsr delay
    sub.b #1,d0
    bne delay
    sub.b #1,d0
    bne delay
    sub.b #1,d0
    bne delay
    rts
    move.b #3,d0
    jsr delay
    move.b d0,memd0
    move.b #3,d0
    jsr delay
    sub.b #1,d0
    bne delay
    sub.b #1,d0
    bne delay
    sub.b #1,d0
    bne delay
    rts

    move.b d0,memd0
    sub.b #1,d0
    bne 1delay
    move.b d0,memd0
    move.b #3,d0
    jsr delay
    sub.b #1,d0
    bne delay
    sub.b #1,d0
    bne delay
    sub.b #1,d0
    bne delay
    rts
    move.b d0,memd0
    sub.b #1,d0
    bne delay
    move.b d0,memd0
    move.b #3,d0
    jsr delay
    sub.b #1,d0
    bne delay
    sub.b #1,d0
    bne delay
    sub.b #1,d0
    bne delay
    rts
    move.b d0,memd0
    sub.b #1,d0
    bne 1delay
    rts
    trap #15

    I dont understand the part highlighted in red.
     
  16. MrChips

    Moderator

    Oct 2, 2009
    12,436
    3,360
    No. You can't do that. You've mess up the original code.
     
  17. active92

    Thread Starter New Member

    Oct 26, 2012
    10
    0
    but we were asked to trace the code this way ...
     
  18. MrChips

    Moderator

    Oct 2, 2009
    12,436
    3,360
    What do you mean by trace the code?
     
  19. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    He's a cobbler.
     
  20. active92

    Thread Starter New Member

    Oct 26, 2012
    10
    0
    trace the code by jotting down the instructions, cycle, stack pointer, memory everytime we execute them