📄 chap.3.assemblylang.ps
字号:
2113(eliminate)X2500(this)X2666(bottleneck)X3095(for)X3234(the)X3379(past)X3561(15)X3684(or)X3791(20)X3914(years,)X4168(but)X576 2131(still)N751(today)X995(there)X1218(has)X1376(been)X1588(no)X2 f1714(widely)X1996(accepted)X1 f2369(alternative)X2807(to)X2912(the)X3060(basic)X3288(structure)X3655(shown)X3935(in)X4040(Figure)X576 2243(3.1.)N3 f576 2467(3.3.2.)N840(Alternation)X1 f776 2607(The)N953(example)X1307(in)X1409(Section)X1725(3.3.1)X1944(illustrates)X2346(how)X2538(the)X2683(simplest)X3031(form)X3246(of)X3354(C)X3446(statement)X3844(can)X4006(be)X4125(exe-)X576 2719(cuted)N821(on)X953(a)X1032(computer.)X1456(Obviously,)X1916(we)X2064(need)X2282(to)X2393(do)X2525(more)X2758(than)X2959(assignments)X3464(of)X3579(values)X3860(to)X3970(memory)X576 2831(locations.)N987(The)X1176(second)X1482(basic)X1719(program)X2084(structure)X2460(we)X2611(look)X2821(at)X2930(is)X3 f3033(alternation)X1 f3487(.)X3550(Alternation)X4029(simply)X576 2943(refers)N821(to)X921(the)X1064(situation)X1421(in)X1521(which)X1781(a)X1849(program)X2200(reaches)X2514(a)X2582(point)X2805(at)X2900(which)X3160(it)X3239(will)X3414(perform)X3749(one)X3913(of)X4018(several)X576 3055(alternatives.)N1069(This)X1264(is)X1352(most)X1563(easily)X1812(illustrated)X2222(by)X2342(an)X2457(example.)X7 f1728 3215(if)N1902(\(x)X2076(<)X2192(y\))X2366(then)X2304 3327(z)N2420(=)X2536(y;)X1728 3439(else)N2304 3551(z)N2420(=)X2536(x;)X3 f1664 3759(Figure)N1961(3.4.)X2129(C)X2222(If-Then-Else)X2763(Statement.)X1 f576 3947(Let)N749(us)X878(assume)X1205(the)X1367(same)X1609(set)X1761(of)X1886(memory)X2252(locations)X2645(are)X2808(reserved)X3179(for)X7 f3370(x)X1 f3428(,)X7 f3531(y)X1 f3589(,)X3658(and)X7 f3876(z)X1 f3979(as)X4104(were)X576 4059(assumed)N946(in)X1060(Section)X1388(3.3.1.)X1666(Here,)X1915(we)X2065(again)X2312(\256rst)X2499(need)X2719(to)X2832(move)X3084(the)X3240(principal)X3621(data)X3820(values)X4104(from)X576 4171(memory)N921(to)X1020(the)X1162(CPU.)X7 f1728 4331(MOVE)N2304(1000,D0)X1728 4443(MOVE)N2304(1001,D1)X1 f576 4631(Now,)N812(to)X913(determine)X1325(which)X1586(half)X1762(of)X1868(the)X7 f2046 0.4091(if-then-else)AX1 f2768(statement)X3164(is)X3254(to)X3356(be)X3474(executed,)X3868(we)X4007(need)X4216(to)X576 4743(evaluate)N922(the)X1064(conditional)X7 f1556(\(x)X1730(<)X1846(y\))X1 f1962(.)X2010(This)X2205(is)X2293(done)X2504(with)X2699(the)X2841(M68000)X7 f3224(CMP)X1 f3422(instruction)X3858(as)X3962(follows.)X7 f1728 4903(CMP)N2304(D1,D0)X1 f576 5091(Be)N722(sure)X921(to)X1035(refer)X1256(to)X1370(the)X1527(M68000/CIE)X2074(manual)X2398(to)X2513(understand)X2999(precisely)X3387(what)X3614(the)X3772(effect)X4032(of)X4152(this)X576 5203(instruction)N1026(is,)X1151(but)X1311(basically,)X1715(the)X1870(difference)X2298(of)X2415(D0)X2569(and)X2745(D1)X2899(\(i.e.,)X3110(D0)X2 f9 f3227(-)X1 f3280(D1\))X3466(is)X3567(computed,)X4008(but)X4168(not)X576 5315(stored)N838(in)X940(either)X1187(D0)X1331(nor)X1486(D1.)X1678(Instead,)X2007(the)X2152(condition)X2543(codes)X2789(in)X2892(the)X3038(CCR)X3258(are)X3404(set)X3539(as)X3647(they)X3841(would)X4109(have)X576 5427(been)N791(if)X883(the)X7 f1068(SUB)X1 f1275(instruction)X1720(had)X1892(been)X2107(executed.)X2507(For)X2673(example,)X3057(if)X3148(the)X3298(values)X3576(in)X3683(D0)X3832(and)X4003(D1)X4152(had)X576 5539(been)N790(equal)X1031(before)X1309(executing)X1716(the)X7 f1900(CMP)X1 f2074(,)X2130(the)X2280(resulting)X2649(difference)X3072(would)X3345(be)X3469(zero,)X3692(and)X3864(as)X3977(a)X4053(result,)X576 5651(the)N722(Z)X809(\257ag)X981(of)X1089(the)X1235(CCR)X1455(would)X1723(be)X1841(set,)X1999(however,)X2381(neither)X2676(D0)X2820(or)X2927(D1)X3071(would)X3338(themselves)X3793(change.)X4141(The)X576 5763(importance)N1045(of)X1160(this)X1334(effect)X1589(comes)X1870(from)X2092(its)X2219(coupling)X2592(with)X2799(the)X2953(``Branch)X3331(on)X3463(Condition)X3884(Code'',)X4211(or)X23 p%%Page: 23 612 s 0 xH 0 xS 1 f3 f576 400(57:017)N872(CIE)X1 f2329(-)X2385(23)X2505(-)X3 f3717(Lecture)X4062(Notes)X7 f576 803(Bcc)N1 f780(instruction.)X1270(For)X1433(the)X7 f1615(Bcc)X1 f1819(instruction,)X2285(selected)X2626(bits)X2795(of)X2905(the)X3053(CCR)X3275(may)X3471(be)X3592(tested)X3847(in)X3951(a)X4023(variety)X576 915(of)N685(ways)X911(to)X1016(alter)X1218(the)X1366(selection)X1739(of)X1849(the)X1997(next)X2193(instruction)X2635(to)X2740(be)X2861(executed.)X3282(If)X3376(it)X3460(was)X3639(desired)X3947(to)X4052(test)X4216(to)X576 1027(see)N725(if)X810(D0)X952(and)X1116(D1)X1258(were)X1470(equal,)X1728(we)X1865(would)X2130(use)X7 f2317(BEQ)X1 f2491(,)X2540(because)X2870(it)X2949(bases)X3182(its)X3298(decision)X3644(about)X3883(what)X4095(to)X4195(do)X576 1139(next)N771(on)X896(the)X1043(value)X1281(stored)X1546(in)X1651(the)X1799(Z)X1888(\257ag)X2062(of)X2172(the)X2320(CCR.)X2566(However,)X2972(for)X3114(the)X3262(C)X3356(statement)X3756(of)X3866(Figure)X4147(3.4,)X576 1251(we)N712(need)X918(to)X1017(test)X1175(to)X1274(see)X1421(if)X1504(D0)X1645(is)X1733(less)X1901(than)X2091(D1.)X2280(We)X2438(do)X2558(this)X2721(with)X2916(the)X3058(following)X3456(instruction:)X7 f1728 1411(BLT)N2304(1100)X1 f576 1599(A)N671(simple)X954(way)X1140(to)X1241(think)X1465(about)X1705(this)X1870(instruction)X2308(is)X2398(that)X2570(if)X2656(D0)X2800(<)X2881(D1,)X3049(then)X3242(we)X3381(``go)X3568(to'')X3734(the)X3879(instruction)X576 1711(at)N679(the)X830(line)X1008(labeled)X1320(`1100'.)X1633(Otherwise)X2061(execute)X2389(the)X2540(instruction)X2985(immediately)X3501(following)X3908(the)X7 f4093(BLT)X1 f4267(.)X576 1823(Therefore,)N1024(the)X1186(instruction\(s\))X1743(immediately)X2270(following)X2688(the)X7 f2884(BLT)X1 f3103(should)X3404(implement)X3862(the)X7 f4059(else)X1 f576 1935(clause)N841(of)X945(Figure)X1220(3.4.)X1388(This)X1583(done)X1794(with)X1989(the)X2131(following:)X7 f1728 2095(MOVE)N2304(D0,1002)X1 f576 2283(This)N773(moves)X1050(the)X1194(value)X1429(of)X7 f1569(x)X1 f1653(\(temporarily)X2161(being)X2401(stored)X2662(in)X2763(D0\))X2938(into)X3114(the)X3258(memory)X3605(location)X3942(allocated)X576 2395(to)N7 f709(z)X1 f767(.)X839(Obviously,)X1287(to)X1386(execute)X1705(the)X7 f1881(if)X1 f2021(clause)X2286(of)X2390(Figure)X2665(3.4,)X2833(we)X2969(need)X3175(to)X3274(do)X3394(the)X3536(following:)X7 f1152 2555(1100)N1728(MOVE)X2304(D1,1002)X1 f576 2715(This)N773(moves)X1050(the)X1194(value)X1429(of)X7 f1569(y)X1 f1653(\(temporarily)X2161(being)X2401(stored)X2662(in)X2763(D1\))X2938(into)X3114(the)X3258(memory)X3605(location)X3942(allocated)X576 2827(to)N7 f710(z)X1 f768(.)X817(Furthermore,)X1347(notice)X1607(that)X1776(we)X1912(label)X2124(this)X2287(line)X2456(with)X2651(`1100'.)X2955(This)X3150(was)X3323(the)X3465(``target'')X3837(of)X3941(the)X7 f4117(BLT)X1 f576 2939(instruction)N1012(shown)X1286(above.)X776 3079(Now,)N1017(if)X1107(we)X1250(try)X1388(to)X1494(put)X1648(this)X1818(sequence)X2202(of)X2313(statements)X2751(together)X3099(into)X3281(a)X3356(program)X3714(segment)X4067(as)X4179(we)X576 3191(did)N724(in)X824(Figure)X1100(3.3)X1245(for)X1381(our)X1533(example)X1884(of)X1988(Section)X2301(3.3.1,)X2541(we)X2677(get)X2819(the)X3 f2961(incorrect)X1 f3360(version)X3667(shown)X3941(in)X4040(Figure)X576 3303(3.5.)N7 f2304 3463(MOVE)N2880(1000,D0)X2304 3575(MOVE)N2880(1001,D1)X2304 3687(CMP)N2880(D1,D0)X2304 3799(BLT)N2880(1100)X2304 3911(MOVE)N2880(D0,1002)X1728 4023(1100)N2304(MOVE)X2880(D1,1002)X3 f1107 4231(Figure)N1404(3.5.)X1572(Incorrect)X1981(M68000)X2336(Code)X2573(Corresponding)X3215(to)X3319(Figure)X3616(3.4.)X1 f576 4391(The)N758(reason)X1041(this)X1212(is)X1308(incorrect)X1683(is)X1779(illustrated)X2198(by)X2327(the)X2478(fact)X2656(that)X2834(no)X2963(matter)X3243(what)X7 f3497(x)X1 f3588(and)X3760(y)X3841(are,)X7 f4050(z)X1 f4141(will)X576 4503(always)N872(end)X1039(up)X1163(with)X1362(the)X1508(value)X1745(from)X7 f1994(y)X1 f2052(.)X2104(This)X2303(is)X2395(graphically)X2857(illustrated)X3271(by)X3395(the)X3541(\257owchart)X3932(of)X4040(Figure)X576 4615(3.6)N720(\(A\).)X24 p%%Page: 24 712 s 0 xH 0 xS 1 f3 f576 400(57:017)N872(CIE)X1 f2329(-)X2385(24)X2505(-)X3 f3717(Lecture)X4062(Notes)X1 f10 s1234 1069 MXY699 220 De1234 1418 MXY699 220 De2919 1069 MXY699 220 De2919 1418 MXY699 220 De2543 2397 MXY699 220 De3314 MX699 220 De852 MX699 220 De1759 2099 MXY699 220 De1591 1179 MXY0 123 Dl1576 1244 MXY14 57 Dl1605 1244 MXY-14 57 Dl1584 1522 MXY0 123 Dl1570 1588 MXY14 57 Dl1599 1588 MXY-14 57 Dl1584 1639 MXY-259 259 Dl259 259 Dl259 -259 Dl-259 -259 Dl1325 1898 MXY-129 0 Dl1195 MX0 388 Dl1181 2229 MXY14 57 Dl1209 2229 MXY-14 57 Dl2507 MY0 168 Dl2676 MY388 0 Dl1584 MX0 213 Dl1570 2832 MXY14 57 Dl1599 2832 MXY-14 57 Dl1591 836 MXY0 122 Dl1576 901 MXY14 57 Dl1605 901 MXY-14 57 Dl3275 1179 MXY0 123 Dl3260 1244 MXY14 57 Dl3290 1244 MXY-14 57 Dl3269 1522 MXY0 123 Dl3255 1588 MXY14 57 Dl3283 1588 MXY-14 57 Dl1639 MY-259 259 Dl259 259 Dl259 -259 Dl-259 -259 Dl3010 1898 MXY-129 0 Dl2880 MX0 388 Dl2866 2229 MXY14 57 Dl2894 2229 MXY-14 57 Dl3528 1898 MXY129 0 Dl3658 MX0 388 Dl3643 2229 MXY14 57 Dl3672 2229 MXY-14 57 Dl2880 2507 MXY0 168 Dl2676 MY388 0 Dl3269 MX0 213 Dl3255 2832 MXY14 57 Dl3283 2832 MXY-14 57 Dl3651 2507 MXY0 168 Dl2676 MY-382 0 Dl3275 836 MXY0 122 Dl3260 901 MXY14 57 Dl3290 901 MXY-14 57 Dl1850 1898 MXY259 0 Dl0 84 Dl2095 1925 MXY14 57 Dl2123 1925 MXY-14 57 Dl2209 MY0 32 Dl2242 MY-913 0 Dl1253 2227 MXY-57 14 Dl1253 2256 MXY-57 -14 Dl2711 1723 MXY0 0 Dl1474 1451(D1)N1592(<-)X1684(y)X1461 1101(D0)N1579(<-)X1671(x)X1454 1898(D0)N1572(<)X1637(D1)X3158 1451(D1)N3276(<-)X3368(y)X3146 1101(D0)N3264(<-)X3356(x)X3139 1898(D0)N3257(<)X3322(D1)X936(YES)X2102 1885(NO)N3729 1989(NO)N2691(YES)X12 s3223 3165(\(B\))N1526 3168(\(A\))N10 s1085 2439(z)N1141(<-)X1233(D1)X1992 2131(z)N2048(<-)X2140(D0)X2763 2436(z)N2819(<-)X2911(D1)X3567(z)X3623(<-)X3715(D0)X3 f12 s1420 3376(Figure)N1717(3.6.)X1885(Flowcharts)X2368(for)X2515(Example)X2902(of)X3006(Figure)X3303(3.4.)X1 f1646 3488(\(A\))N1803(-)X1859(Incorrect)X2231(Flow;)X2479(\(B\))X2631(-)X2687(Correct)X3000(Flow.)X576 3648(Note)N788(that)X958(the)X1101(assignment)X1559(of)X1664(D0)X1806(to)X7 f1940(z)X1 f2023(will)X2198(be)X2314(overwritten)X2783(by)X2904(the)X3047(assignment)X3505(of)X3610(D1)X3752(to)X7 f3886(z)X1 f3944(.)X3993(What)X4227(is)X576 3760(desired)N883(is)X976(the)X1123(control)X1425(\257ow)X1624(shown)X1903(in)X2007(Figure)X2287(3.6)X2436(\(B\).)X2641(Referring)X3039(back)X3249(to)X3352(our)X3508(program)X3862(segment)X4211(of)X576 3872(Figure)N852(3.5,)X1021(what)X1233(is)X1322(needed)X1620(is)X1709(a)X1777(way)X1962(to)X2062(``jump'')X2413(over)X2610(the)X
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -