# Continuous memory: Exercise I

**URL:** <https://community.starknet.io/t/continuous-memory-exercise-i/2628>\
**Category:** Support\
**Tags:** cairo\
**Created:** [November 3, 2022, 8:22pm UTC](https://community.starknet.io/t/continuous-memory-exercise-i/2628 "2022-11-03T20:22:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![henryf10h](https://dub1.discourse-cdn.com/flex005/user_avatar/community.starknet.io/henryf10h/32/1041_2.png) [@henryf10h](https://community.starknet.io/u/henryf10h)\
**Post date:** [November 3, 2022, 8:22pm UTC](https://community.starknet.io/t/continuous-memory-exercise-i/2628/1 "2022-11-03T20:22:19Z")

</div>

We need to: “Add one instruction at the end of the function (just before `ret` ) so that there won’t be a memory gap”. Here is the code:

```auto
func main() {
    [ap] = 100;
    [ap + 2] = 200;
    ret;
}

```

---

<div class="post-metadata">

**Author:** ![henryf10h](https://dub1.discourse-cdn.com/flex005/user_avatar/community.starknet.io/henryf10h/32/1041_2.png) [@henryf10h](https://community.starknet.io/u/henryf10h)\
**Post date:** [November 4, 2022, 10:25am UTC](https://community.starknet.io/t/continuous-memory-exercise-i/2628/2 "2022-11-04T10:25:11Z")

</div>

When I debug the above function, this is what I get in memory:

```auto
1 0x400680017fff8000
2 100
3 0x400680017fff8002
4 200
5 0x208b7fff7fff7ffe
6 11
7 11
8 100
10 200

```

Values 100 and 200 are stored at memory locations 0x400680017fff8000 and 0x400680017fff8002 respectively. To fill the gap we need to store the new value at memory location 0x400680017fff8001. This could be done as follows:

```auto
func main() {
    [ap] = 100;
    [ap + 2] = 200;
    [ap + 1] = 67; // the order of access doesn’t matter
    ret;
}

```
