Level languages uncondimonal branches implement some

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ;>17 (t2) t2 & 8185 Set Up Body Finish University of Washington Another Example int logical(int x, int y) { int t1 = x^y; int t2 = t1 >> 17; int mask = (1<<13) - 7; int rval = t2 & mask; return rval; } logical: pushl %ebp movl %esp,%ebp movl xorl sarl andl 213 = 8192, 213 – 7 = 8185 …0010000000000000, …0001111111111001 movl xorl sarl andl 8(%ebp),%eax 12(%ebp),%eax $17,%eax $8185,%eax eax eax eax eax x86 8(%ebp),%eax 12(%ebp),%eax $17,%eax $8185,%eax movl %ebp,%esp popl %ebp ret = = = = x x^y (t1) t1>>17 (t2) t2 & 8185 Set Up Body Finish University of Washington CondiMonals and Control Flow    A condiMonal branch is sufficient to implement most control flow constructs offered in higher level languages                UncondiMonal branches implement some related control flow constructs       if (condiIon) then {...} else {…} while (condiIon) {…} do {…} while (condiIon) for (iniIalizaIon; condiIon; iteraIve) {...} break, conInue In x86, we’ll refer to branches as “jumps” (either condiMonal or uncondiMonal) x86 University of Washington Jumping   jX InstrucMons   Jump to different part of code depending on condiIon codes jX CondiMon DescripMon jmp 1 UncondiMonal je ZF Equal / Zero jne ~ZF Not Equal / Not Zero js SF NegaMve jns ~SF NonnegaMve jg ~(SF^OF)&~ZF Greater (Signed) jge ~(SF^OF) Greater or Equal (Signed) jl (SF^OF) Less (Signed) jle (SF^OF)|ZF Less or Equal (Signed) ja ~CF&~ZF Above (unsigned) jb CF Below (unsigned) x86 University of Washington Processor State (IA32, ParMal)   InformaMon about currently execuMng program   Temporary data ( %eax, …)   LocaIon of runIme stack ( %ebp,%esp)   LocaIon of current code control point ( %eip )   Status of recent tests %eax %ecx %edx %ebx %esi %edi %esp %ebp General purpose registers Current stack top Current stack frame %eip InstrucMon pointer CF ZF SF OF CondiMon codes ( CF,ZF,SF,OF ) x86 University of Washington CondiMon Codes (Implicit Sexng)   Single ­bit registers CF Carry Flag (for unsigned) ZF Zero Flag   SF Sign Flag (for signed) OF Overflow Flag (for signed) Implicitly set (think of it as side eff...
View Full Document

Ask a homework question - tutors are online