Machine-Level Representation of Programs‖l
1 Machine-Level Representation of Programs Ⅱ
Outline Data movement Data manipulation Control structure Suggested read ing -chφp3.4.3.5,3.6
2 Outline • Data movement • Data manipulation • Control structure • Suggested reading – Chap 3.4, 3.5, 3.6
Indexed Addressing Mode Figure 3.3 P137 Most general form Imm (Eb, Ei, s) M[Imm+ R[Eb]+ riE]s Constant displacement"Imm: 1, 2, or 4 bytes Base register Eb: Any of 8 integer registers Index register E;: Any, except for %esp S: Scale: 1.2 4 or 8
3 Indexed Addressing Mode Figure 3.3 P137 • Most general form – Imm(Eb , Ei , s) – M[Imm+ R[Eb ]+ R[Ei ]*s] – Constant “displacement” Imm: 1, 2, or 4 bytes – Base register Eb : Any of 8 integer registers – Index register Ei : Any, except for %esp – S: Scale: 1, 2, 4, or 8
Data Movement Figure 3.4 P139 Instruction Effect Description movI S D DES Move double word moVw SD DES Move word mob S D DES ove byTe movsbl S,DD<SignedExtend( S) Move sign-extended byte movzbl S,DD< ZeroExtend()Move zero-extended byte push R[%esp]+R[%esp]-4 Push M[R[%esp]]<s popl D< MR[Yoesp] Po R[%esp]←R[%esp]+4
4 Data Movement Figure 3.4 P139 Instruction Effect Description movl S, D D S Move double word movw S, D D S Move word movb S, D D S Move byte movsbl S, D D SignedExtend( S) Move sign-extended byte movzbl S, D D ZeroExtend(S) Move zero-extended byte pushl S R[%esp] R[%esp]-4 M[R[%esp]] S Push popl D D M[R[%esp]] R[%esp] R[%esp]+4 Pop
Move Instructions Format movl src, dest src and dest can only be one of the following Immediate (except dest) Register Memory
5 Move Instructions • Format – movl src, dest – src and dest can only be one of the following • Immediate (except dest) • Register • Memory