600 likes | 689 Views
F28PL1 Programming Languages. Lecture 5: Assembly Language 4. Subroutines. block of code with: single entry point ability to return to instruction after call basis of methods/procedures/functions subroutine call must: remember address of instruction for return
E N D
F28PL1 Programming Languages Lecture 5: Assembly Language 4
Subroutines • block of code with: • single entry point • ability to return to instruction after call • basis of methods/procedures/functions • subroutine call must: • remember address of instruction for return • transfer control to address of start of subroutine • R14 == LR • link register • holds return address
Subroutine call BLlabel • copy PC+4 to LR • i.e. set LR to address following BL instruction • branch to label • i.e. set PC to address for label • so: • label is name of subroutine • after call, LR holds return address
Subroutine return BX label • branch indirect on label • i.e. set PC to address from label • so: • BX LR returns to instruction after last BL
Example: R4 = R2*R2+R3*R3 MOV R2,#3 MOV R3,#4 BL SQ1 B ENDL ... SQ1 MUL R4,R2,R2 MUL R5,R3,R3 ADD R4,R5 BX LR ...
Example: R4 = R2*R2+R3*R3 MOV R2,#3 MOV R3,#4 BL SQ1 B ENDL SQ1 MUL R4,R2,R2 MUL R5,R3,R3 ADD R4,R5 BX LR ENDL ... R2 R3 PC LR R4 R5 MOV R2,#3 0x08000128 0x08000128 MOV R3,#4 0x0800012B BL SQ1 0x0800012F B ENDL 0x08000134 SQ1 MUL R4,... 0x08000138 MUL R5,... 0x0800013B ADD R4,R5 0x0800013F BX LR 0x08000144
Example: R4 = R2*R2+R3*R3 MOV R2,#3 MOV R3,#4 BL SQ1 B ENDL SQ1 MUL R4,R2,R2 MUL R5,R3,R3 ADD R4,R5 BX LR ENDL ... R2 R3 R4 PC R5 LR 0x03 MOV R2,#3 0x08000128 0x0800012B MOV R3,#4 0x0800012B BL SQ1 0x0800012F B ENDL 0x08000134 SQ1 MUL R4,... 0x08000138 MUL R5,... 0x0800013B ADD R4,R5 0x0800013F BX LR 0x08000144
Example: R4 = R2*R2+R3*R3 MOV R2,#3 MOV R3,#4 BL SQ1 B ENDL SQ1 MUL R4,R2,R2 MUL R5,R3,R3 ADD R4,R5 BX LR ENDL ... LR PC R4 R5 R2 R3 0x04 0x03 MOV R2,#3 0x08000128 0x0800012F MOV R3,#4 0x0800012B BL SQ1 0x0800012F B ENDL 0x08000134 SQ1 MUL R4,... 0x08000138 MUL R5,... 0x0800013B ADD R4,R5 0x0800013F BX LR 0x08000144
Example: R4 = R2*R2+R3*R3 MOV R2,#3 MOV R3,#4 BL SQ1 B ENDL SQ1 MUL R4,R2,R2 MUL R5,R3,R3 ADD R4,R5 BX LR ENDL ... R2 R3 R4 PC LR R5 0x03 0x04 0x08000134 MOV R2,#3 0x08000128 0x08000138 MOV R3,#4 0x0800012B BL SQ1 0x0800012F B ENDL 0x08000134 SQ1 MUL R4,... 0x08000138 MUL R5,... 0x0800013B ADD R4,R5 0x0800013F BX LR 0x08000144
Example: R4 = R2*R2+R3*R3 MOV R2,#3 MOV R3,#4 BL SQ1 B ENDL SQ1 MUL R4,R2,R2 MUL R5,R3,R3 ADD R4,R5 BX LR ENDL ... LR PC R4 R5 R2 R3 0x09 0x04 0x03 0x08000134 MOV R2,#3 0x08000128 0x0800013B MOV R3,#4 0x0800012B BL SQ1 0x0800012F B ENDL 0x08000134 SQ1 MUL R4,... 0x08000138 MUL R5,... 0x0800013B ADD R4,R5 0x0800013F BX LR 0x08000144
Example: R4 = R2*R2+R3*R3 MOV R2,#3 MOV R3,#4 BL SQ1 B ENDL SQ1 MUL R4,R2,R2 MUL R5,R3,R3 ADD R4,R5 BX LR ENDL ... R2 R3 R4 PC LR R5 0x03 0x04 0x09 0x10 0x08000134 MOV R2,#3 0x08000128 0x0800013F MOV R3,#4 0x0800012B BL SQ1 0x0800012F B ENDL 0x08000134 SQ1 MUL R4,... 0x08000138 MUL R5,... 0x0800013B ADD R4,R5 0x0800013F BX LR 0x08000144
Example: R4 = R2*R2+R3*R3 MOV R2,#3 MOV R3,#4 BL SQ1 B ENDL SQ1 MUL R4,R2,R2 MUL R5,R3,R3 ADD R4,R5 BX LR ENDL ... R2 R3 R4 PC LR R5 0x03 0x04 0x19 0x10 0x08000134 MOV R2,#3 0x08000128 0x08000144 MOV R3,#4 0x0800012B BL SQ1 0x0800012F B ENDL 0x08000134 SQ1 MUL R4,... 0x08000138 MUL R5,... 0x0800013B ADD R4,R5 0x0800013F BX LR 0x08000144
Example: R4 = R2*R2+R3*R3 MOV R2,#3 MOV R3,#4 BL SQ1 B ENDL SQ1 MUL R4,R2,R2 MUL R5,R3,R3 ADD R4,R5 BX LR ENDL ... R2 R3 R4 PC LR R5 0x03 0x04 0x19 0x10 0x08000134 MOV R2,#3 0x08000128 0x08000134 MOV R3,#4 0x0800012B BL SQ1 0x0800012F B ENDL 0x08000134 SQ1 MUL R4,... 0x08000138 MUL R5,... 0x0800013B ADD R4,R5 0x0800013F BX LR 0x08000144
Parameter passing • registers • fast • ties up specific registers • may not have enough spare registers • on stack • push from registers before call • pop into registers in subroutine • not register specific • slower
Example: stack parameter passing PUSH {R2} PUSH {R3} BL SQ2 POP {R4} B ENDL SQ2 POP {R6} POP {R5} MUL R5,R5 MUL R6,R6 ADD R5,R6 PUSH {R5} BX LR ENDL
Example: stack parameter passing 0x20000200 ... PUSH {R2} PUSH {R3} BL SQ2 POP {R4} B ENDL SQ2 POP {R6} POP {R5} MUL R5,R5 MUL R6,R6 ADD R5,R6 PUSH {R5} BX LR ENDL PC R2 LR R3 R6 R5 SP R4 0x04 0x03 0x200001FC 0x200001F8 PUSH {R2} 0x08000138 PUSH {R3} 0x0800013F BL SQ2 0x08000144 0x20000200 POP {R4} 0x08000148 B ENDL 0x0800014F 0x08000138 SQ2 POP {R6} 0x08000154 POP {R5} 0x08000158 MUL R5,R5 0x0800015F ... PUSH {R5} 0x0800016F BX LR 0x08000174
Example: stack parameter passing 0x20000200 ... PUSH {R2} PUSH {R3} BL SQ2 POP {R4} B ENDL SQ2 POP {R6} POP {R5} MUL R5,R5 MUL R6,R6 ADD R5,R6 PUSH {R5} BX LR ENDL R4 R5 SP LR PC R3 R2 R6 0x03 0x04 0x200001FC 0x200001F8 PUSH {R2} 0x08000138 PUSH {R3} 0x0800013F BL SQ2 0x08000144 0x20000200 POP {R4} 0x08000148 B ENDL 0x0800014F 0x08000138 SQ2 POP {R6} 0x08000154 POP {R5} 0x08000158 MUL R5,R5 0x0800015F ... PUSH {R5} 0x0800016F BX LR 0x08000174
Example: stack parameter passing 0x03 0x20000200 ... PUSH {R2} PUSH {R3} BL SQ2 POP {R4} B ENDL SQ2 POP {R6} POP {R5} MUL R5,R5 MUL R6,R6 ADD R5,R6 PUSH {R5} BX LR ENDL R2 R3 R4 PC R5 SP R6 LR 0x03 0x04 0x200001FC 0x200001F8 PUSH {R2} 0x08000138 PUSH {R3} 0x0800013F BL SQ2 0x08000144 0x200001FC POP {R4} 0x08000148 B ENDL 0x0800014F 0x0800013F SQ2 POP {R6} 0x08000154 POP {R5} 0x08000158 MUL R5,R5 0x0800015F ... PUSH {R5} 0x0800016F BX LR 0x08000174
Example: stack parameter passing 0x03 0x20000200 ... PUSH {R2} PUSH {R3} BL SQ2 POP {R4} B ENDL SQ2 POP {R6} POP {R5} MUL R5,R5 MUL R6,R6 ADD R5,R6 PUSH {R5} BX LR ENDL R2 R3 R4 PC R5 SP R6 LR 0x03 0x04 0x04 0x200001FC 0x200001F8 PUSH {R2} 0x08000138 PUSH {R3} 0x0800013F BL SQ2 0x08000144 0x200001F8 POP {R4} 0x08000148 B ENDL 0x0800014F 0x08000144 SQ2 POP {R6} 0x08000154 POP {R5} 0x08000158 MUL R5,R5 0x0800015F ... PUSH {R5} 0x0800016F BX LR 0x08000174
Example: stack parameter passing 0x03 0x20000200 ... PUSH {R2} PUSH {R3} BL SQ2 POP {R4} B ENDL SQ2 POP {R6} POP {R5} MUL R5,R5 MUL R6,R6 ADD R5,R6 PUSH {R5} BX LR ENDL R2 R3 R4 PC R5 SP R6 LR 0x03 0x04 0x04 0x200001FC 0x200001F8 PUSH {R2} 0x08000138 PUSH {R3} 0x0800013F BL SQ2 0x08000144 0x200001F8 POP {R4} 0x08000148 0x08000148 B ENDL 0x0800014F 0x08000154 SQ2 POP {R6} 0x08000154 POP {R5} 0x08000158 MUL R5,R5 0x0800015F ... PUSH {R5} 0x0800016F BX LR 0x08000174
Example: stack parameter passing 0x03 0x20000200 ... PUSH {R2} PUSH {R3} BL SQ2 POP {R4} B ENDL SQ2 POP {R6} POP {R5} MUL R5,R5 MUL R6,R6 ADD R5,R6 PUSH {R5} BX LR ENDL R3 PC R4 R2 R5 SP R6 LR 0x04 0x04 0x03 0x04 0x200001FC 0x200001F8 PUSH {R2} 0x08000138 PUSH {R3} 0x0800013F BL SQ2 0x08000144 0x200001FC POP {R4} 0x08000148 0x08000148 B ENDL 0x0800014F 0x08000158 SQ2 POP {R6} 0x08000154 POP {R5} 0x08000158 MUL R5,R5 0x0800015F ... PUSH {R5} 0x0800016F BX LR 0x08000174
Example: stack parameter passing 0x03 0x20000200 ... PUSH {R2} PUSH {R3} BL SQ2 POP {R4} B ENDL SQ2 POP {R6} POP {R5} MUL R5,R5 MUL R6,R6 ADD R5,R6 PUSH {R5} BX LR ENDL R3 PC R4 R2 R5 SP R6 LR 0x03 0x04 0x03 0x04 0x04 0x200001FC 0x200001F8 PUSH {R2} 0x08000138 PUSH {R3} 0x0800013F BL SQ2 0x08000144 0x20000200 POP {R4} 0x08000148 0x08000148 B ENDL 0x0800014F 0x0800015F SQ2 POP {R6} 0x08000154 POP {R5} 0x08000158 MUL R5,R5 0x0800015F ... PUSH {R5} 0x0800016F BX LR 0x08000174
Example: stack parameter passing 0x03 0x20000200 ... PUSH {R2} PUSH {R3} BL SQ2 POP {R4} B ENDL SQ2 POP {R6} POP {R5} MUL R5,R5 MUL R6,R6 ADD R5,R6 PUSH {R5} BX LR ENDL R3 PC R4 R2 R5 SP R6 LR 0x19 0x10 0x03 0x04 0x04 0x200001FC 0x200001F8 PUSH {R2} 0x08000138 PUSH {R3} 0x0800013F BL SQ2 0x08000144 0x20000200 POP {R4} 0x08000148 0x08000148 B ENDL 0x0800014F 0x0800016F SQ2 POP {R6} 0x08000154 POP {R5} 0x08000158 MUL R5,R5 0x0800015F ... PUSH {R5} 0x0800016F BX LR 0x08000174
Example: stack parameter passing 0x19 0x20000200 ... PUSH {R2} PUSH {R3} BL SQ2 POP {R4} B ENDL SQ2 POP {R6} POP {R5} MUL R5,R5 MUL R6,R6 ADD R5,R6 PUSH {R5} BX LR ENDL R3 PC R4 R2 R5 R13 R6 LR 0x19 0x10 0x03 0x04 0x04 0x200001FC 0x200001F8 PUSH {R2} 0x08000138 PUSH {R3} 0x0800013F BL SQ2 0x08000144 0x200001FC POP {R4} 0x08000148 0x08000148 B ENDL 0x0800014F 0x08000174 SQ2 POP {R6} 0x08000154 POP {R5} 0x08000158 MUL R5,R5 0x0800015F ... PUSH {R5} 0x0800016F BX LR 0x08000174
Example: stack parameter passing 0x19 0x20000200 ... PUSH {R2} PUSH {R3} BL SQ2 POP {R4} B ENDL SQ2 POP {R6} POP {R5} MUL R5,R5 MUL R6,R6 ADD R5,R6 PUSH {R5} BX LR ENDL R3 PC R4 R2 R5 SP R6 LR 0x19 0x10 0x03 0x04 0x04 0x200001FC 0x200001F8 PUSH {R2} 0x08000138 PUSH {R3} 0x0800013F BL SQ2 0x08000144 0x200001FC POP {R4} 0x08000148 0x08000148 B ENDL 0x0800014F 0x08000148 SQ2 POP {R6} 0x08000154 POP {R5} 0x08000158 MUL R5,R5 0x0800015F ... PUSH {R5} 0x0800016F BX LR 0x08000174
Example: stack parameter passing 0x19 0x20000200 ... PUSH {R2} PUSH {R3} BL SQ2 POP {R4} B ENDL SQ2 POP {R6} POP {R5} MUL R5,R5 MUL R6,R6 ADD R5,R6 PUSH {R5} BX LR ENDL PC R3 R4 R2 R5 SP R6 LR 0x19 0x19 0x03 0x10 0x04 0x04 0x200001FC 0x200001F8 PUSH {R2} 0x08000138 PUSH {R3} 0x0800013F BL SQ2 0x08000144 0x20000200 POP {R4} 0x08000148 0x08000148 B ENDL 0x0800014F 0x0800014F SQ2 POP {R6} 0x08000154 POP {R5} 0x08000158 MUL R5,R5 0x0800015F ... PUSH {R5} 0x0800016F BX LR 0x08000174
Nested subroutines • push LR (& working registers) onto stack before nested call • pop LR (& working registers) off stack after nested return
Example: R4 = R44 0x20000200 MOV R4,#2 BL QUAD B ENDL SQ MUL R4,R4 BX LR QUAD PUSH {LR} BL SQ BL SQ POP {LR} BX LR ENDL ... SP LR PC R4 0x200001FC 0x200001F8 MOV R4,#2 0x08000138 BL QUAD 0x0800013F B ENDL 0x08000144 0x20000200 SQ MUL R4,R4 0x08000148 BX LR 0x0800014F 0x08000138 QUAD PUSH {LR} 0x08000154 BL SQ 0x08000158 BL SQ 0x0800015F POP {LR} 0x08000164 BX LR 0x08000168
Example: R4 = R44 0x20000200 MOV R4,#2 BL QUAD B ENDL SQ MUL R4,R4 BX LR QUAD PUSH {LR} BL SQ BL SQ POP {LR} BX LR ENDL ... SP LR PC R4 0x02 0x200001FC 0x200001F8 MOV R4,#2 0x08000138 BL QUAD 0x0800013F B ENDL 0x08000144 0x20000200 SQ MUL R4,R4 0x08000148 BX LR 0x0800014F 0x0800013F QUAD PUSH {LR} 0x08000154 BL SQ 0x08000158 BL SQ 0x0800015F POP {LR} 0x08000164 BX LR 0x08000168
Example: R4 = R44 0x20000200 MOV R4,#2 BL QUAD B ENDL SQ MUL R4,R4 BX LR QUAD PUSH {LR} BL SQ BL SQ POP {LR} BX LR ENDL ... SP LR R4 PC 0x02 0x200001FC 0x200001F8 MOV R4,#2 0x08000138 BL QUAD 0x0800013F B ENDL 0x08000144 0x20000200 SQ MUL R4,R4 0x08000148 0x08000144 BX LR 0x0800014F 0x08000154 QUAD PUSH {LR} 0x08000154 BL SQ 0x08000158 BL SQ 0x0800015F POP {LR} 0x08000164 BX LR 0x08000168
Example: R4 = R44 0x08000144 0x20000200 MOV R4,#2 BL QUAD B ENDL SQ MUL R4,R4 BX LR QUAD PUSH {LR} BL SQ BL SQ POP {LR} BX LR ENDL ... SP LR R4 PC 0x02 0x200001FC 0x200001F8 MOV R4,#2 0x08000138 BL QUAD 0x0800013F B ENDL 0x08000144 0x20000200 SQ MUL R4,R4 0x08000148 0x08000144 BX LR 0x0800014F 0x08000158 QUAD PUSH {LR} 0x08000154 BL SQ 0x08000158 BL SQ 0x0800015F POP {LR} 0x08000164 BX LR 0x08000168
Example: R4 = R44 0x08000144 0x20000200 MOV R4,#2 BL QUAD B ENDL SQ MUL R4,R4 BX LR QUAD PUSH {LR} BL SQ BL SQ POP {LR} BX LR ENDL ... SP LR R4 PC 0x02 0x200001FC 0x200001F8 MOV R4,#2 0x08000138 BL QUAD 0x0800013F B ENDL 0x08000144 0x200001FC SQ MUL R4,R4 0x08000148 0x0800015F BX LR 0x0800014F 0x08000148 QUAD PUSH {LR} 0x08000154 BL SQ 0x08000158 BL SQ 0x0800015F POP {LR} 0x08000164 BX LR 0x08000168
Example: R4 = R44 0x08000144 0x20000200 MOV R4,#2 BL QUAD B ENDL SQ MUL R4,R4 BX LR QUAD PUSH {LR} BL SQ BL SQ POP {LR} BX LR ENDL ... SP LR R4 PC 0x04 0x200001FC 0x200001F8 MOV R4,#2 0x08000138 BL QUAD 0x0800013F B ENDL 0x08000144 0x200001FC SQ MUL R4,R4 0x08000148 0x0800015F BX LR 0x0800014F 0x0800014F QUAD PUSH {LR} 0x08000154 BL SQ 0x08000158 BL SQ 0x0800015F POP {LR} 0x08000164 BX LR 0x08000168
Example: R4 = R44 0x08000144 0x20000200 MOV R4,#2 BL QUAD B ENDL SQ MUL R4,R4 BX LR QUAD PUSH {LR} BL SQ BL SQ POP {LR} BX LR ENDL ... SP LR R4 PC 0x04 0x200001FC 0x200001F8 MOV R4,#2 0x08000138 BL QUAD 0x0800013F B ENDL 0x08000144 0x200001FC SQ MUL R4,R4 0x08000148 0x0800015F BX LR 0x0800014F 0x0800015F QUAD PUSH {LR} 0x08000154 BL SQ 0x08000158 BL SQ 0x0800015F POP {LR} 0x08000164 BX LR 0x08000168
Example: R4 = R44 0x08000144 0x20000200 MOV R4,#2 BL QUAD B ENDL SQ MUL R4,R4 BX LR QUAD PUSH {LR} BL SQ BL SQ POP {LR} BX LR ENDL ... SP LR R4 PC 0x04 0x200001FC 0x200001F8 MOV R4,#2 0x08000138 BL QUAD 0x0800013F B ENDL 0x08000144 0x200001FC SQ MUL R4,R4 0x08000148 0x08000164 BX LR 0x0800014F 0x08000148 QUAD PUSH {LR} 0x08000154 BL SQ 0x08000158 BL SQ 0x0800015F POP {LR} 0x08000164 BX LR 0x08000168
Example: R4 = R44 0x08000144 0x20000200 MOV R4,#2 BL QUAD B ENDL SQ MUL R4,R4 BX LR QUAD PUSH {LR} BL SQ BL SQ POP {LR} BX LR ENDL ... SP LR R4 PC 0x10 0x200001FC 0x200001F8 MOV R4,#2 0x08000138 BL QUAD 0x0800013F B ENDL 0x08000144 0x200001FC SQ MUL R4,R4 0x08000148 0x08000164 BX LR 0x0800014F 0x0800014F QUAD PUSH {LR} 0x08000154 BL SQ 0x08000158 BL SQ 0x0800015F POP {LR} 0x08000164 BX LR 0x08000168
Example: R4 = R44 0x08000144 0x20000200 MOV R4,#2 BL QUAD B ENDL SQ MUL R4,R4 BX LR QUAD PUSH {LR} BL SQ BL SQ POP {LR} BX LR ENDL ... SP LR R4 PC 0x10 0x200001FC 0x200001F8 MOV R4,#2 0x08000138 BL QUAD 0x0800013F B ENDL 0x08000144 0x200001FC SQ MUL R4,R4 0x08000148 0x08000164 BX LR 0x0800014F 0x08000164 QUAD PUSH {LR} 0x08000154 BL SQ 0x08000158 BL SQ 0x0800015F POP {LR} 0x08000164 BX LR 0x08000168
Example: R4 = R44 0x08000144 0x20000200 MOV R4,#2 BL QUAD B ENDL SQ MUL R4,R4 BX LR QUAD PUSH {LR} BL SQ BL SQ POP {LR} BX LR ENDL ... SP LR R4 PC 0x10 0x200001FC 0x200001F8 MOV R4,#2 0x08000138 BL QUAD 0x0800013F B ENDL 0x08000144 0x20000200 SQ MUL R4,R4 0x08000148 0x08000144 BX LR 0x0800014F 0x08000168 QUAD PUSH {LR} 0x08000154 BL SQ 0x08000158 BL SQ 0x0800015F POP {LR} 0x08000164 BX LR 0x08000168
Example: R4 = R44 0x08000144 0x20000200 MOV R4,#2 BL QUAD B ENDL SQ MUL R4,R4 BX LR QUAD PUSH {LR} BL SQ BL SQ POP {LR} BX LR ENDL ... SP LR R4 PC 0x10 0x200001FC 0x200001F8 MOV R4,#2 0x08000138 BL QUAD 0x0800013F B ENDL 0x08000144 0x20000200 SQ MUL R4,R4 0x08000148 0x08000144 BX LR 0x0800014F 0x08000144 QUAD PUSH {LR} 0x08000154 BL SQ 0x08000158 BL SQ 0x0800015F POP {LR} 0x08000164 BX LR 0x08000168
Recursion: R4 = R2R3 pow(int R2, int R3, int R4) { if(R3==0) return R4; pow(R2,R3-1,R4*R2); } pow (2,3,1) pow (2,2,2) pow (2,1,4) pow (2,0,8) 8 MOV R2,#2 MOV R3,#3 MOV R4,#1 BL POW ... POW CMP R3,#0 BEQ ENDPOW MUL R4,R2 SUB R3,#1 PUSH {LR} BL POW POP {LR} ENDPOW BX LR
Summarising language characteristics • how does a language abstract away from underlying byte machines? • types • data abstraction • control abstraction • what are pragmatic consequences of language characteristics? • i.e. how do characteristics affect use?
Types • values & operations • what are base types? • e.g. Java: int, float, char etc • what are structured types? • e.g. Java: object, array, String etc
Types • how do types constrain language? • weak v strong typing • i.e. whether type associated with entity can (weak) or can’t (strong)change • e.g. Java: strong typing • static v dynamic typing • i.e. whether types checked at compile time (static) or run time (dynamic) • e.g. Java: static typing
Polymorphism • type abstraction • can types be generalised? • polymorphism == many shapes • ad-hoc v parametric polymorphism • ad-hoc == “for this” • i.e. language/context specific • parametric == controlled by parameters
Polymorphism • e.g. Java • ad-hoc polymorphism • operator overloading • i.e. can use some operators with different types e.g. arithmetic • parametric polymorphism • i.e. generic types with type variables
Data abstraction • memory abstraction • variable as name/value abstraction from address/contents • e.g. Java: variables • where may variables be introduced? • e.g. Java: class fields, method formal parameters, block/method bodies, iteration control
Data abstraction • how may variables be bound to values? • e.g Java: • initialising declaration • assignment • parameter passing
Data abstraction • scope • i.e. where is something visible? • lexical v dynamic scope • i.e. constrained or not by site of definition/declaration • extent • i.e. how long does something exist?
Data abstraction • e.g. Java: lexical scope • class field/method names visible via object • variables in block/ method body visible in block unless redefined • method formal parameter visible in method body only • e.g. Java: block extent • variables only exist in defining block/method body
Control abstraction • structured operations as commands • how are calculations performed? • e.g. Java: expression • how is memory accessed? • e.g. Java: use variable name in expression context • how is memory changed? • e.g. Java: assignment to variable