

This is a strange idea at first because the all pointer variables are pointers and they store addresses so you might think that in a simple world all pointer variables would be of the same type - pointer say. That is, a pointer can only point to a variable of one type.

Of course Pascal being a strongly typed language means that pointers are typed as well.

It is worth seeing how it implemented pointers. Pascal was one of the first truly high level languages to include included pointers from very early in its development and the pattern it adopted was used by C# and many other modern languages. That is, a pointer variable contains the address of another variable. A pointer variable implements indirection by being a storage location that has the address of another storage location or in this case variable. Many high level languages stop right there.īut some don't - they re-invent the whole concept of addressing and indirection by way of pointer variables. The addresses are still there but they have been abstracted away into the idea of a variable. You are referring to the contents of SUM and TOTAL and there is no hint of addresses or redirection. There is no doubt that when you write something like TOTAL=SUM+10 When you use a variable you are using an address of a memory location as part of an instruction. When high level languages got going the idea of addresses and the whole idea of memory locations were hidden behind the facade of the variable. Redirection is where it just gets complicated enough for mistakes to be rule rather than the exception and redirection is something pointers allow you to do without thinking twice.Īnd once you have redirection you an easily invent re-redirection and so on - each one more difficult and dangerous than the last. Well so were thousands of novice assembly language programmers. Indirect addressing puts the address of the location that holds the address of the location that holds the data. Direct addressing puts the address that the data is stored at in the instruction. The idea is that the value stored in a memory location can be data or it can be an address of another memory location.

So for example, the command: LDA mean load the A register with the value stored in the memory location whose address is stored in memory location at 2000. Indirect addressing is where the value stored in a memory location is treated as an address to another memory location and it is a common feature of most hardware. Once you know the rules it's easy enough but mistakes are still common - especially when you start using indirect addressing. Means "load the A register with the contents of address 2000". Means "load the A register with the value 2000" and LDA 2000 The ambiguity is usually solved by using an extra symbol if you mean the numeric value: LDA #2000 Mean "load the A register with the value 2000" or "load the A register with the contents of address 2000"? the number 2000 or the thing stored at memory location 2000. The confusion inherent in the idea of a pointer starts at this early stage of development.Īre you talking about the thing itself i.e. In assembly language you refer to a memory location by its address, for example 2000 refers to the memory location at address 2000.
