⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chap.3.assemblylang.ps

📁 嵌入开发笔记 用ps阅读器打开
💻 PS
📖 第 1 页 / 共 5 页
字号:
2754(instruction)X3192(on)X3314(the)X3458(line)X3629(labeled)X3934(`1100')X4216(to)X576 3984(the)N730(line)X911(following)X1321(line)X1502(`1100'.)X1818(Let's)X2052(call)X2228(this)X2403(line)X2584(`1200'.)X2900(Furthermore,)X3441(this)X3616(``jump'')X3978(must)X4200(be)X3 f576 4096(unconditional)N1 f1141(.)X1203(I.e.,)X1388(no)X1522(condition)X1925(need)X2146(be)X2276(tested)X2540(before)X2825(executing)X3239(the)X3396(``jump''.)X3785(The)X3974(result)X4227(is)X576 4208(shown)N850(in)X949(Figure)X1224(3.7.)X7 f2304 4368(MOVE)N2880(1000,D0)X2304 4480(MOVE)N2880(1001,D1)X2304 4592(CMP)N2880(D1,D0)X2304 4704(BLT)N2880(1100)X2304 4816(MOVE)N2880(D0,1002)X2304 4928(JMP)N2880(1200)X1728 5040(1100)N2304(MOVE)X2880(D1,1002)X1728 5152(1200)N2304(......)X2710(program)X3174 0.4219(continues)AX3754(here)X3 f1139 5360(Figure)N1436(3.7.)X1604(Correct)X1949(M68000)X2304(Code)X2541(Corresponding)X3183(to)X3287(Figure)X3584(3.4.)X25 p%%Page: 25 812 s 0 xH 0 xS 3 f1 f3 f576 400(57:017)N872(CIE)X1 f2329(-)X2385(25)X2505(-)X3 f3717(Lecture)X4062(Notes)X1 f576 803(Believe)N908(it)X999(or)X1116(not,)X1300(there)X1530(is)X1631(really)X1888(only)X2096(one)X2272(more)X2507(control)X2818(\257ow)X3026(construct)X3417(needed)X3728(to)X3841(provide)X4173(the)X576 915(same)N798(capability)X1203(as)X1307(most)X1518(high-level)X1933(languages)X2342(such)X2542(as)X2646(C.)X2758(This)X2953(is)X3041(the)X2 f3183(looping)X1 f3501(construct.)X3 f576 1139(3.3.3.)N840(Iterating)X1227(or)X1342(Looping)X1 f776 1279(Let)N933(us)X1046(now)X1239(consider)X1593(an)X1712(example)X2067(of)X2175(a)X2246(very)X2445(common)X2810(program)X3164(control-\257ow)X3667(construct)X4048(\320)X4173(the)X576 1391(loop.)N7 f1728 1551(x)N1844(=)X1960(0;)X1728 1663(for)N1960(\(i=1;)X2308(i<=20;)X2714(i++\))X2304 1775(x)N2420(=)X2536(x)X2652(+)X2768(i;)X3 f1743 1983(Figure)N2040(3.8.)X2208(C)X2301(For-loop)X2683(Statement.)X1 f576 2171(Let)N729(us)X838(assume)X1145(the)X1287(following)X1685(correspondence)X2313(of)X2417(the)X2559(variable)X7 f2928(x)X1 f3010(to)X3109(a)X3176(memory)X3521(location.)X7 f1728 2331(x)N1844(:)X1960(memory)X2366(location)X2888(1000)X1 f576 2491(Because)N7 f959(i)X1 f1045(is)X1137(only)X1336(used)X1540(as)X1648(a)X1719(control)X2020(variable)X2359(within)X2633(the)X2779(context)X3091(of)X3199(the)X3345(loop,)X3568(there)X3789(is)X3881(no)X4005(need)X4216(to)X576 2603(assign)N847(a)X921(memory)X1273(location)X1615(to)X1721(it.)X1854(For)X2018(the)X2167(code)X2380(segment)X2732(which)X2998(implements)X3478(this)X3647(loop,)X3872(we)X4014(will)X4194(let)X576 2715(data)N761(register)X1074(D1)X1215(hold)X1410(the)X1552(value)X1785(of)X7 f1923(i)X1 f1981(.)X776 2855(First,)N1000(we)X1136(assign)X1400(0)X1472(\(zero\))X1726(to)X7 f1859(x)X1 f1941(as)X2045(required)X2390(in)X2489(the)X2631(\256rst)X2804(line)X2973(of)X3077(Figure)X3352(3.8.)X7 f2304 3015(MOVE)N2880(#0,1000)X1 f576 3175(Next,)N811(we)X947(will)X1121(make)X1354(a)X1421(copy)X1632(of)X7 f1770(x)X1 f1852(in)X1951(a)X2018(data)X2203(register.)X7 f2304 3335(MOVE)N2880(1000,D0)X1 f576 3495(Now,)N810(we)X946(initialize)X1309(data)X1494(register)X1807(D1,)X1972(which)X2231(is)X2319(being)X2557(used)X2757(to)X2856(hold)X3051(the)X3193(loop)X3388(index)X7 f3660(i)X1 f3718(.)X7 f2304 3655(MOVE)N2880(#1,D1)X1 f576 3815(In)N694(addition)X1048(to)X1161(the)X1317(loop)X1526(index)X1779(itself,)X2035(we)X2186(need)X2407(to)X2521(have)X2742(a)X2824(value)X3072(to)X3186(compare)X3557(with,)X3791(to)X3905(determine)X576 3927(whether)N910(the)X1052(loop)X1247(is)X1335(\256nished)X1663(or)X1767(not.)X1938(For)X2095(this)X2258(loop)X2453(limit)X2660(value)X2893(we)X3029(will)X3203(use)X3355(data)X3540(register)X3853(D2.)X7 f2304 4087(MOVE)N2880(#20,D2)X1 f576 4247(We)N734(now)X924(begin)X1163(the)X1306(main)X1524(body)X1741(of)X1846(the)X1989(loop,)X2209(and)X2373(let's)X2564(simply)X2851(label)X3064(this)X3228(line)X3398(`1100',)X3703(so)X3813(we)X3950(can)X4109(refer)X576 4359(to)N678(it)X759(later.)X982(This)X1180(line)X1352(will)X1529(simply)X1818(add)X1984(the)X2129(loop)X2326(index)X2566(to)X2667(the)X2811(accumulated)X3325(value)X3560(of)X7 f3700(x)X1 f3784(being)X4024(held)X4216(in)X576 4471(D0.)N7 f1728 4631(1100)N2304(ADD)X2880(D1,D0)X1 f576 4791(The)N759(line)X937(above)X1200(comprises)X2 f1623(all)X1 f1758(of)X1871(the)X2022(code)X2237(needed)X2544(to)X2653(execute)X2982(the)X3134(main)X3361(body)X3587(of)X3701(the)X3853(loop.)X4082(What)X576 4903(remains)N922(is)X1027(the)X1186(``overhead'')X1707(code)X1929(to)X2044(manipulate)X2513(and)X2692(test)X2866(the)X3024(loop)X3235(index,)X3513(and)X3692(branch)X3994(back)X4216(to)X576 5015(`1100')N856(if)X939(necessary.)X7 f2304 5175(ADD)N2880(#1,D1)X2304 5287(CMP)N2880(D2,D1)X2304 5399(BLE)N2880(1100)X1 f576 5559(the)N721(\256rst)X897(line)X1069(increments)X1519(the)X1664(loop)X1862(counter,)X2202(the)X2347(second)X2641(line)X2813(compares)X3209(the)X3355(loop)X3554(counter)X3871(to)X3974(the)X4120(loop)X576 5671(limit,)N812(and)X980(the)X1127(last)X1290(line)X1464(will)X1643(branch)X1934(back)X2145(to)X2249(`1100')X2534(if)X2622(the)X2768(value)X3005(stored)X3268(in)X3371(D1)X3516(is)X3608(less)X3780(than)X3974(or)X4082(equal)X576 5783(to)N680(that)X854(stored)X1118(in)X1222(D2.)X1416(Note,)X1656(if)X1744(we)X1885(had)X2053(used)X7 f2292(BLT)X1 f2466(,)X2519(then)X2714(we)X2855(would)X3124(fail)X3282(to)X3386(execute)X3710(the)X3857(loop)X4057(for)X7 f4233(i)X26 p%%Page: 26 912 s 0 xH 0 xS 7 f3 f576 400(57:017)N872(CIE)X1 f2329(-)X2385(26)X2505(-)X3 f3717(Lecture)X4062(Notes)X7 f576 803(=)N695(20)X1 f811(.)X886(Finally,)X1210(we)X1349(have)X1558(to)X1660(store)X1874(the)X2018(resulting)X2381(value)X2616(of)X7 f2756(x)X1 f2840(back)X3048(to)X3149(memory)X3496(location)X2 f3833($)X1 f(1000)S4099(upon)X576 915(termination)N1045(from)X1256(the)X1398(loop.)X7 f2304 1075(MOVE)N2880(D0,1000)X1 f576 1263(Figure)N861(3.9)X1015(shows)X1289(the)X1442(complete)X1831(M68000)X2191 0.2548(implementation)AX2832(of)X2947(the)X3100(C)X7 f3233(for)X1 f3407(-loop)X3645(shown)X3930(in)X4040(Figure)X576 1375(3.8.)N7 f2304 1535(MOVE)N2880(#0,1000)X2304 1647(MOVE)N2880(1000,D0)X2304 1759(MOVE)N2880(#1,D1)X2304 1871(MOVE)N2880(#20,D2)X1728 1983(1100)N2304(ADD)X2880(D1,D0)X2304 2095(ADD)N2880(#1,D1)X2304 2207(CMP)N2880(D2,D1)X2304 2319(BLE)N2880(1100)X2304 2431(MOVE)N2880(D0,1000)X3 f1311 2639(Figure)N1608(3.9.)X1776(M68000)X2131(Code)X2368(Corresponding)X3010(to)X3114(Figure)X3411(3.8.)X576 2911(3.4.)N768(Control,)X1136(Operands,)X1589(and)X1767(Operations)X1 f776 3051(With)N1000(the)X1149(three)X1373(brief)X1586(examples)X1981(so)X2097(far,)X2259(we)X2402(have)X2615(covered)X2951(quite)X3175(a)X3249(few)X3424(concepts.)X3816(This)X4018(section)X576 3163(will)N750(brie\257y)X1025(summarize)X1472(the)X1614(main)X1831(points)X2090(covered)X2419(so)X2528(far.)X776 3303(The)N950(\256rst)X1124(general)X1433(idea)X1619(is)X1708(that)X1878(of)X3 f1983(control)X2302(\257ow)X1 f2472(.)X2521(We)X2680(have)X2887(illustrated)X3298(M68000)X3648(implementations)X576 3415(of)N686(three)X909(fundamental)X1421(control)X1724(\257ow)X1924(constructs;)X2 f2370(sequencing,)X2856(alternation,)X1 f3337(and)X2 f3505(iteration.)X1 f3914(These)X4173(are)X576 3527(depicted)N927(graphically)X1385(in)X1484(Figure)X1759(3.10.)X10 s2462 3720 MXY0 259 Dl2448 3921 MXY14 57 Dl2477 3921 MXY-14 57 Dl2462 3979 MXY-259 259 Dl2234 4188 MXY-30 50 Dl2254 4208 MXY-50 30 Dl2462 3979 MXY259 259 Dl2671 4208 MXY50 30 Dl2691 4188 MXY30 50 Dl2657 4355(ELSE)N2171(IF)X2301 3688(Statement)N2641(1)X1685 4342 MXY0 259 Dl1670 4544 MXY14 57 Dl1699 4544 MXY-14 57 Dl3953 MY0 259 Dl1670 4155 MXY14 57 Dl1699 4155 MXY-14 57 Dl2203 4472 MXY259 259 Dl0 129 Dl2448 4803 MXY14 57 Dl2477 4803 MXY-14 57 Dl2722 4472 MXY-259 259 Dl3370 3824 MXY0 259 Dl3355 4025 MXY14 57 Dl3384 4025 MXY-14 57 Dl4342 MY0 259 Dl3355 4544 MXY14 57 Dl3384 4544 MXY-14 57 Dl4342 MYD~  -129 129 -129 -129 0 -388 259 129 0 129 D~~3355 4155 MXY14 57 Dl3384 4155 MXY-14 57 Dl1523 4303(Statement)N1863(2)X1523 4672(Statement)N1863(3)X1523 3921(Statement)N1863(1)X3208 3791(Statement)N3548(1)X12 s2268 5285(Alternation)N3201 5288(Iteration)N1497 5281(Sequencing)N10 s2294 4993(Statement)N2634(3)X3181 4731(Statement)N3521(3)X2041 4432(Statement)N2381(2)X2566(Statement)X2906(2)X3201 4303(Statement)N3541(2)X3 f12 s1342 5496(Figure)N1639(3.10.)X1855(Three)X2125(Primary)X2497(Control)X2841(Flow)X3068(Structures.)X1 f776 5684(The)N956(second)X1253(general)X1567(concept)X1897(is)X1991(that)X2166(of)X2276(an)X3 f2397(addressing)X2869(mode)X1 f3093(.)X3171(We)X3335(have)X3547(seen)X3748(three)X3971(address-)X576 5796(ing)N723(modes)X998(so)X1107(far.)X1262(They)X1484(are:)X27 p%%Page: 27 1012 s 0 xH 0 xS 1 f3 f576 400(57:017)N872(CIE)X1 f2329(-)X2385(27)X2505(-)X3 f3717(Lecture)X4062(Notes)X1 f776 803(1.)N3 f920(Data)X1141(Register)X1507(Direct.)X1 f1812(The)X1986(operand)X2320(is)X2408(in)X2507(a)X2574(register.)X920 963(e.g.,)N7 f1107(MOVE)X1496(D0,D1)X1 f2072(;)X2 f2099(both)X2294(operands)X1 f776 1151(2.)N3 f920(Immediate)X1387(Data.)X1 f1632(The)X1806(operand)X2140(appears)X2458(in)X2557(the)X2699(instruction.)X920 1311(e.g.,)N7 f1107(MOVE)X1496(#1,D1)X1 f2072(;)X2 f2099(left)X2247(operand)X2591(only)X1 f776 1499(3.)N3 f920(Absolute.)X1 f1330(The)X1504(memory)X1849(address)X2161(of)X2265(the)X2407(operand)X2741(appears)X3059(in)X3158(the)X3300(instruction.)X920 1659(e.g.,)N7 f1107(MOVE)X1496 0.4219(1000,2000)AX1 f2072(;)X2 f2099(both)X2294(operands)X1 f576 1847(We)N745(have)X962(also)X1152(already)X1471(encountered)X1977(a)X2055(small)X2299(subset)X2574(of)X2689(the)X2842(M68000)X3202(instruction)X3649(set.)X3815(So)X3951(far)X4093(these)X576 1959(instructions)N1049(include:)X10 f776 2071(g)N7 f868(MOVE)X1 f1124(\320)X1244(Move)X1492(from)X1703(source)X1978(to)X2077(destination)X10 f776 2183(g)N7 f868(ADD)X1 f1066(\320)X1186(Add)X1375(source)X1650(to)X1749(destination)X10 f776 2295(g)N7 f868(CMP)X1 f1066(\320)X1186(Compare)X1563(source)X1838(and)X2001(destination)X10 f776 2407(g)N7 f868(BLT)X1 f1066(\320)X1186(Branch)X1488(if)X1571(Less)X1771(Than)X1993(to)X2092(target)X2336(address)X10 f776 2519(g)N7 f868(BLE)X1 f1066(\320)X1186(Branch)X1488(if)X1571(Less)X1771(than)X1961(or)X2065(Equal)X2314(to)X2413(target)X2657(address)X10 f776 2631(g)N7 f868(JMP)X1 f1066(\320)X1186(Jump)X1418(unconditionally)X2047(to)X2146(target)X2390(address)X576 2771(Finally,)N904(we)X1047(have)X1261(seen)X1464(how)X1661(we)X1805(refer)X2019(to)X2126(one)X2297(instruction)X2741(from)X2960(within)X3238(another)X3559(instruction.)X4027(So)X4160(far,)X576 2883(we)N717(have)X927(arbitrarily)X1341(assigned)X1700(``address)X2080(labels'')X2397(to)X2500(lines)X2710(that)X2883(were)X3098(the)X3244(target)X3492(of)X3600(a)X3671(branch)X3961(or)X4069(jump.)X576 2995(For)N733(example,)X1108(we)X

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -