More assembly fun! Arrays and array manipulation

And I'm back with more of this excitement. As the title says, I'm on to arrays. I have two number sorting problems to get done, and I figure arrays are going to be the best way to go about it. For those of you who don't know, I am using a program called MARIE, which is basically this program that simulates a super small instruction set.

Ok, on to the problem. I realize I'm going to need to kind of "fake" a pointer to a block of memory. I can do this no problem in C, but I can't figure it out with marie.


1
2
3
4
5
Arr, Dec 0
     Dec 0
     Dec 0
     Dec 0
     Dec 0


This is what I have for an array. Memory locations are implied, but they're all contiguous. So if I get this pointer to Arr figured out, all I have to do is add X to that pointer and I can access any element of the array. I'm not sure how to simulate a pointer with this instruction set though. :(
Actually, I'm on to something. Got some help from a friend, and it makes sense. A pointer to the beginning of the array could be done like this:

1
2
3
4
Loc, Load Arr
       Load Loc
       Subt H1000  //Hex 1000
       Store ArrLoc


Pretty much, Load Loc puts 1Arr in the AC, so subtracting hex 1000 gets rid of the load command (Load is 1 in marie), leaving just the address of Arr
Topic archived. No new replies allowed.