#module
#deffunc meminit int
mref num, 0
dim _mem, num
crnt = 0 : memnum = num
return
#deffunc push int
mref data, 0
crnt++
if crnt > memnum {
repeat memnum - 1
tmp = cnt + 1
_mem.cnt = _mem.tmp
loop
crnt--
}
tmp = crnt - 1
_mem.tmp = data
return
#deffunc pop
mref stt, 64
stt = 0
crnt--
if crnt >= 0 : stt = _mem.crnt
return
#global
meminit 3 // 3個まで保持
push 1 // [1]
push 2 // [1][2]
push 3 // [1][2][3]
pop // [1][2]
mes stat
pop // [1]
mes stat
push 4 // [1][4]
push 5 // [1][4][5]
push 6 // [4][5][6] 3個を超えたので初めの[1]は消滅
pop // [4][5]
mes stat
pop // [4]
mes stat
pop
mes stat
stop
|