dComNet1 ISA-niveauet (2)
dComNet2 Niveauer af virtuelle maskiner ISA niveauet / maskinkodeniveauet / maskinniveau
dComNet3 ISA - Fra sidst ISA-niveauet og von-Neumann maskine: Maskininstruktioner og instruktionsformat. Absolut maskinkode. Registre og lagermodellen. IJVM maskinen: Registre: PC, SP, LV, CPP. Lagermodel: method area, constant pool, stakken. Metodekald og stakafsnit, parametre og lokale variable. IJVM simulatoren
dComNet4 IJVM Lagermodel Opdelt i tre områder (konstant pool, stakken, method area):.. indlejret i et lineært lager: celler (1 byte/celle). 32 bit 8 bit
dComNet5 IJVM registre Program Counter (PC): 32-bit register Udpeger aktuel instruktion (byte) i method area. Constant Pool Pointer: 32-bit register Udpeger bunden (word) af konstant pool i lageret Stack Pointer (SP) : 32-bit register Udpeger øverste element (word) på stakken. Local Variable Frame Pointer (LV): 32-bit register Udpeger bunden (word) af det aktuelle stakafsnit.
dComNet6 invokevirtual
dComNet7 ireturn
dComNet8.method main // int main.args 3 // ( int a, int b ).define a = 1.define b = 2 // { bipush 88 // Push object reference. iload a iload b invokevirtual min ireturn // return min (a,b); // }.method min // int min.args 3 // ( int a, int b ){.define a = 1.define b = 2.locals 1 // int r;.define r = 3 iload a // if ( a >= b ) iload b isub // stack = a-b;a-b a < b iflt else iload b // r = b; istore r goto end_if else: iload a // r = a; istore r end_if:iload r // return r; ireturn // }
dComNet9.method main // int main.args 3 // ( int a, int b ).define a = 1.define b = 2 // { bipush 88 // Push object reference. iload a iload b invokevirtual min ireturn // return min ( a, b ); // } test.j
dComNet10.method min // int min.args 3 // ( int a, int b ){.define a = 1.define b = 2.locals 1 // int r;.define r = 3 iload a // if ( a >= b ) iload b isub // stack = a - b,... ; a - b a < b iflt else iload b // r = b; istore r goto end_if else: // else iload a // r = a; istore r end_if: iload r // return r; ireturn // }
dComNet11 test.j main index: 0 method area: 40 bytes b ac b 00 0a a ac constant pool: 2 words e oversættes til ijvm-asm test.j test.bc fortolkes af ijvm test.bc IJVM simulator
dComNet12 main index: 0 method area: 40 bytes bipush iload iload 2 10b invokevirtual 1 13acireturn iload iload isub 239b 00 0aiflt iload istore 3 30a goto iload istore iload 3 39acireturn constant pool: 2 words e Antal argumenter for main Antal lokale variable for main Start adresse for main Start adresse for min
dComNet13 IJVM Trace of foo stack = 0, 1, 43, 77, 15 bipush 88 [10 58] stack = 88, 0, 1, 43, 77, 15 iload 1 [15 01] stack = 77, 88, 0, 1, 43, 77, 15 iload 2 [15 02] stack = 43, 77, 88, 0, 1, 43, 77, 15 invokevirtual 1 [b ] stack = 12, 13, 0, 43, 77, 21, 0, 1 iload 1 [15 01] stack = 77, 12, 13, 0, 43, 77, 21, 0 iload 2 [15 02] stack = 43, 77, 12, 13, 0, 43, 77, 21 isub [64] stack = 34, 12, 13, 0, 43, 77, 21, 0 iflt 10 [9b 00 0a] stack = 12, 13, 0, 43, 77, 21, 0, 1 iload 2 [15 02] stack = 43, 12, 13, 0, 43, 77, 21, 0 istore 3 [36 03] stack = 12, 13, 43, 43, 77, 21, 0, 1 goto 7 [a ] stack = 12, 13, 43, 43, 77, 21, 0, 1 iload 3 [15 03] stack = 43, 12, 13, 43, 43, 77, 21, 0 ireturn [ac] stack = 43, 0, 1, 43, 77, 15 ireturn [ac] stack = 43 return value: 43 ijvm test.bc 77 43
dComNet14 IJVM Maskinarkitekturen Instruktionssæt: 20 instruktioner. Instruktionsformat: 1-5 bytes længde og 1 byte opkode. Datatyper: heltal (med og uden fortegn) Lagermodel: 3-delt 4Gb lineært lager. Stakmaskine: operander udpeges ved stak addressering.
dComNet15 Datatyper Intel 8051 Pentium
dComNet16 Addresseringsformer (1) Hvordan specificeres operander for instruktioner. Immediate addressing - operand er en del af instruktionen: bipush 42 Register addressing - operand ligger i et register: ADD R1,R2 (”R1 = R1 + R2”) Direct addressing - addresse på operand er en del af instruktionen: ADD R1,(1096) (”R1 = R1 + m[1096]”)
dComNet17 Addresseringsformer (2) Register indirect - operand udpeges af register indhold: ADD R1,(R2) (”R1 = R1 + m[R2]”) Indexed addressing - operand udpeges af offset og register indhold: iload x, istore x (m[LV+x]) invokevirtual x (m[CPP+x]) ldc_w x (m[CPP+x]) ADD R1,R2(4) (”R1 = R1 + m[R2+4]”) ADD R1,1096(R2) (”R1 = R1 + m[1096+R2]”)
dComNet18 Addresseringsformer (3) Adressering også krævet ifm. hopinstruktioner: PC relative addressing - hop relativt til indhold af PC: goto x, ifeq x, ilft x, if_icmpeq x (”PC = PC + x”) Øvrige adresseringsformer også mulige for hop-instruktioner.
dComNet19 Instruktionsformat Antal operander (addresser på operander): Instruktionslængde (fast eller varieret):
dComNet20 ISA design Er et samspil mellem mange ting: –Adresseringsformer. –Instruktionsformat. –Lagermodellen. –Registre. –… under hensyntagen til: –Tidseffektivitet – udførsel af instruktioner. –Pladseffektivitet – størrelsen på programmer. –Bagud-kompatibilitet. –…