看板 Grad-ProbAsk 關於我們 聯絡資訊
這是關於堆疊指標的問題 Given the following 8 possible solution for a POP or a PUSH operation in a STACK : 1.Read from Mem(SP), Decrement SP ; 2.Read from Mem(SP), Increment SP ; 3.Decrement SP, Read from Mem(SP) ; 4.Increment SP, Read from Mem(SP) ; 5.Write to Mem(SP), Decrement SP ; 6.Write to Mem(SP), Increment SP ; 7.Decrement SP, Write to Mem(SP) ; 8.Increment SP, Write to Mem(SP) ; (1) Solution of a PUSH operation for a Last Full stack that grows ascending. 8.Increment SP, Write to Mem(SP) ; (2) Solution of a POP operation for a Next Empty stack that grows descending. 4.Increment SP, Read from Mem(SP) ; (3) Solution of a PUSH operation for a Next Empty stack that grows ascending. 6.Write to Mem(SP), Increment SP ; (4) Solution of a POP operation for a Last Full stack that grows descending. 2.Read from Mem(SP), Increment SP ; 請問這4題題目該如何翻譯呢?答案又為何是這4個呢? stack的存取規則不是PUSH時 SP<-SP-1 Stack(sp)<-data POP 時 data<-Stack(sp) SP<-SP+1 嗎? 題目後面的 ascending descending 為何有兩種sp移動的方向呢? 希望高手幫忙解答^^~ -- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.228.208.209