mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-27 14:54:05 -06:00
vault backup: 2022-09-05 10:19:46
This commit is contained in:
parent
d45d5ae14c
commit
4ba9f6c861
@ -6,5 +6,50 @@ tags:
|
|||||||
- lecture
|
- lecture
|
||||||
---
|
---
|
||||||
|
|
||||||
# compiler
|
compiler ⇒ converts high level language description of program into assembly description of the program
|
||||||
converts high level language description of program into machine code description of the program
|
assembler ⇒ converts assebly language description into machine code description
|
||||||
|
loader ⇒ loads program into memory, loaded at $4000
|
||||||
|
|
||||||
|
data has an address in memory, so does the application. Therefore functions must also have an address in memory which we can access
|
||||||
|
|
||||||
|
# pointers to routines
|
||||||
|
|
||||||
|
```
|
||||||
|
int (*method)(int param)
|
||||||
|
```
|
||||||
|
|
||||||
|
to assign a pointer to a routine
|
||||||
|
|
||||||
|
```
|
||||||
|
method = square;
|
||||||
|
```
|
||||||
|
|
||||||
|
to call the routine
|
||||||
|
```
|
||||||
|
result = method(6);
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## basic example
|
||||||
|

|
||||||
|
|
||||||
|
## pointer as member of a struct;
|
||||||
|
pointers to routines can beused anyqhere variables can
|
||||||
|
|
||||||
|
- member of struct
|
||||||
|

|
||||||
|
|
||||||
|
- parameter to other routine
|
||||||
|

|
||||||
|
|
||||||
|
# modules
|
||||||
|
we can break programs into functional modules
|
||||||
|
- each modules excapsulates one behaviour
|
||||||
|
- give us a way of data hiding
|
||||||
|
|
||||||
|
add pointer to structs as parameters to methods in modules
|
||||||
|
- call this an abstract data type ADT
|
||||||
|
- we communicatre with an ADT via its public interface
|
||||||
|
- so that the implementation details are hidden
|
||||||
|
|
||||||
|

|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user