Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

Draw the stack memory map for each of the following program- How many.docx

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Nächste SlideShare
8086 instructions
8086 instructions
Wird geladen in …3
×

Hier ansehen

1 von 2 Anzeige

Draw the stack memory map for each of the following program- How many.docx

Herunterladen, um offline zu lesen

Draw the stack memory map for each of the following program. How many times does each program jump back to the label REPEAT?
START   ORG $1000
MOVEA.L #$2000,A7
MOVE.L #11,(A7)
MOVE.L #3,D0
REPEAT
MOVE.L D0,-(A7)
CMP.L #2,D0
DBPL D0,REPEAT
STOP #$2700
END START
Solution
START   ORG $1000 //orgin of program is 1000
MOVEA.L #$2000,A7 // Stack pointer is 2000
MOVE.L #11,(A7) // move 11 (hex B) to stack
MOVE.L #3,D0 // move 3 to D0
REPEAT
MOVE.L D0,-(A7) // Decrement stack pointer and move D0
CMP.L #2,D0 // compare D0 with 2
DBPL D0,REPEAT // If result of compare is positive decrement D0 and branch to repeat
STOP #$2700 // Stop after loading 2700 to base register
END START
Hence
Stack
As it is clear the loop will run 3 times.
since first time 3 will become 2 (3-2 positive) second time ( 2-2 positive ; 0 is positive) 1-2 is negative loop will exit.

.

Draw the stack memory map for each of the following program. How many times does each program jump back to the label REPEAT?
START   ORG $1000
MOVEA.L #$2000,A7
MOVE.L #11,(A7)
MOVE.L #3,D0
REPEAT
MOVE.L D0,-(A7)
CMP.L #2,D0
DBPL D0,REPEAT
STOP #$2700
END START
Solution
START   ORG $1000 //orgin of program is 1000
MOVEA.L #$2000,A7 // Stack pointer is 2000
MOVE.L #11,(A7) // move 11 (hex B) to stack
MOVE.L #3,D0 // move 3 to D0
REPEAT
MOVE.L D0,-(A7) // Decrement stack pointer and move D0
CMP.L #2,D0 // compare D0 with 2
DBPL D0,REPEAT // If result of compare is positive decrement D0 and branch to repeat
STOP #$2700 // Stop after loading 2700 to base register
END START
Hence
Stack
As it is clear the loop will run 3 times.
since first time 3 will become 2 (3-2 positive) second time ( 2-2 positive ; 0 is positive) 1-2 is negative loop will exit.

.

Anzeige
Anzeige

Weitere Verwandte Inhalte

Ähnlich wie Draw the stack memory map for each of the following program- How many.docx (20)

Weitere von edwardk6 (20)

Anzeige

Aktuellste (20)

Draw the stack memory map for each of the following program- How many.docx

  1. 1. Draw the stack memory map for each of the following program. How many times does each program jump back to the label REPEAT? STARTÂ Â ORG $1000 MOVEA.L #$2000,A7 MOVE.L #11,(A7) MOVE.L #3,D0 REPEAT MOVE.L D0,-(A7) CMP.L #2,D0 DBPL D0,REPEAT STOP #$2700 END START Solution STARTÂ Â ORG $1000 //orgin of program is 1000 MOVEA.L #$2000,A7 // Stack pointer is 2000 MOVE.L #11,(A7) // move 11 (hex B) to stack MOVE.L #3,D0 // move 3 to D0 REPEAT MOVE.L D0,-(A7) // Decrement stack pointer and move D0
  2. 2. CMP.L #2,D0 // compare D0 with 2 DBPL D0,REPEAT // If result of compare is positive decrement D0 and branch to repeat STOP #$2700 // Stop after loading 2700 to base register END START Hence Stack As it is clear the loop will run 3 times. since first time 3 will become 2 (3-2 positive) second time ( 2-2 positive ; 0 is positive) 1-2 is negative loop will exit. Memory Address Value 2000 B 1FFF 3 1FFE 2

×