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

📄 chap.4.io.ps

📁 嵌入开发笔记 用ps阅读器打开
💻 PS
📖 第 1 页 / 共 5 页
字号:
2854(what)X3067(is)X3157(happening)X3584(in)X3685(the)X3829(disk)X4015(device.)X576 2063(For)N745(example,)X1132(after)X1345(writing)X1659(a)X1738(``Read'')X2100(command)X2517(to)X2629(the)X2 f2784(Control)X1 f3120(register,)X3470(the)X3625(CPU)X3848(would)X4125(then)X576 2175(read)N785(\(sometimes)X1272(called)X1545(polling\))X1892(the)X2 f2052(Status)X1 f2329(register)X2660(to)X2777(determine)X3205(when)X3455(the)X3615(disk)X3817(has)X3987(\256nished)X576 2287(locating)N911(the)X1053(requested)X1446(data)X1631(and)X1794(has)X1946(placed)X2222(that)X2391(data)X2576(in)X2675(the)X2 f2817(Data)X3033(Read)X1 f3255(register.)X3 f576 2511(4.6.)N768(Brief)X1001(Example:)X1420(The)X1604(TTY)X1825(Terminal)X1 f776 2651(Assume)N1109(the)X1251(simple)X1532(3)X1604(register)X1917(device)X2193(interface)X2555(to)X2654(a)X2721(terminal)X3067(device)X3343(as)X3447(shown)X3721(in)X3820(Figure)X4095(4.5.)X11 s2146 3176 MXY0 -288 Dl1152 0 Dl0 288 Dl-1152 0 Dl3608 MY0 -288 Dl1152 0 Dl0 288 Dl-1152 0 Dl4040 MY0 -288 Dl1152 0 Dl0 288 Dl-1152 0 Dl2289 3751 MXY0 288 Dl2432 3751 MXY0 288 Dl2576 3751 MXY0 288 Dl2720 3751 MXY0 288 Dl2864 3751 MXY0 288 Dl3008 3751 MXY0 288 Dl3152 3751 MXY0 288 Dl2289 3319 MXY0 288 Dl2432 3319 MXY0 288 Dl2576 3319 MXY0 288 Dl2720 3319 MXY0 288 Dl2864 3319 MXY0 288 Dl3008 3319 MXY0 288 Dl3152 3319 MXY0 288 Dl2887 MY0 288 Dl3008 2887 MXY0 288 Dl2864 2887 MXY0 288 Dl2720 2887 MXY0 288 Dl2576 2887 MXY0 288 Dl2432 2887 MXY0 288 Dl2289 2887 MXY0 288 Dl2217 4255 MXY0 -216 Dl2231 4096 MXY-14 -57 Dl2202 4096 MXY14 -57 Dl2360 4147 MXY0 -108 Dl2374 4096 MXY-14 -57 Dl2346 4096 MXY14 -57 Dl14 s1569 3465(TTYDATA)N1604 3909(STATUS)N1569 3031(KBDATA)N12 s2217 2818(7)N3224 2815(0)N2360(6)X2792(3)X3080(1)X2936(2)X2648(4)X2504(5)X2289 4219(Cout)N2145 4327(Cin)N3 f1493 4535(Figure)N1790(4.5.)X1958(Simple)X2265(3)X2337(Register)X2703(Device)X3000(Interface)X1992 4647(to)N2096(a)X2168(Terminal)X2577(Device.)X1 f576 4835(KBDATA)N1006(will)X1187(contain)X1502(the)X1651(8-bit)X1864(ASCII)X2145(code)X2358(for)X2501(the)X2650(most)X2868(recent)X3136(character)X3522(pressed)X3842(on)X3970(the)X4120(key-)X576 4947(board.)N869(It)X954(is)X1043(read)X1234(by)X1355(the)X1498(CPU.)X1757(TTYDATA)X2235(is)X2324(written)X2622(to)X2722(by)X2843(the)X2986(CPU)X3197(and,)X3385(once)X3592(written)X3890(to,)X4014(the)X4157(ter-)X576 5059(minal)N820(device)X1096(will)X1270(display)X1572(the)X1714(character)X2092(whose)X2361(8-bit)X2567(ASCII)X2841(code)X3047(was)X3220(placed)X3496(in)X3595(TTYDATA.)X600 5171(STATUS)N986(is)X1074(read)X1264(by)X1384(the)X1526(CPU.)X1784(The)X1958(two)X2126(bits)X2289(of)X2393(most)X2604(importance)X3062(are:)X576 5311(Cin:)N960(Set)X1112(\(to)X1248(1\))X1357(when)X1594(a)X1666(character)X2049(has)X2206(been)X2417(typed)X2660(on)X2785(the)X2933(keyboard.)X3369(Cleared)X3699(\(set)X3868(to)X3973(0\))X4083(when)X960 5423(the)N1102(CPU)X1312(reads)X1539(the)X1681(value)X1914(from)X2125(KBDATA.)X576 5563(Cout:)N960(Set)X1112(when)X1349(the)X1496(CPU)X1711(writes)X1975(a)X2047(new)X2237(ASCII)X2517(code)X2729(to)X2834(TTYDATA.)X3365(Cleared)X3695(by)X3821(the)X3969(terminal)X960 5675(once)N1166(the)X1308(last)X1466(character)X1844(in)X1943(TTYDATA)X2420(has)X2572(been)X2778(displayed.)X44 p%%Page: 44 912 s 0 xH 0 xS 1 f3 f576 400(57:017)N872(CIE)X1 f2329(-)X2385(44)X2505(-)X3 f3717(Lecture)X4062(Notes)X1 f576 803(These)N831(two)X1000(bits,)X1188(and)X1352(their)X1554(function,)X1924(de\256ne)X2184(a)X2252(protocol)X2598(between)X2944(the)X3088(CPU)X3300(\(or)X3438(user)X3624(program\))X4008(and)X4173(the)X576 915(TTY)N799(device.)X1135(Now,)X1381(consider)X1743(the)X1897(program)X2259(segment)X2616(which)X2887(will)X3073(read)X3275(a)X3354(character)X3744(from)X3967(the)X4120(key-)X576 1027(board)N819(into)X993(the)X1135(C)X1223(variable)X7 f1592(ch)X1 f1708(:)X7 f1152 1187(unsigned)N1674(char)X1964(ch;)X1152 1411(/*)N1326(READ)X1616(*/)X1152 1523(while)N1500 0.4091(\(\(*STATUSreg)AX2254(&)X2370(0x80\))X2718(==)X2892(0\);)X3124(/*)X3298(do)X3472(nothing)X3936(*/)X1152 1635(ch)N1326(=)X1442(*KBreg;)X1152 1747(.)N1326(.)X1500(.)X1 f576 1935(Assuming)N999(that)X1178(the)X1330(three)X1557(registers)X1917(of)X2031(this)X2204(device)X2490(have)X2706(been)X2922("wired")X3253(to)X3362(the)X3514(CPU)X3734(such)X3945(that)X4125(they)X576 2047(have)N806(memory)X1175(addresses)X1591($10000,)X1950($10001,)X2309(and)X2495($10002,)X2854(the)X3019(following)X3440(would)X3727(need)X3956(to)X4078(to)X4200(be)X576 2159(included)N932(in)X1031(the)X1173(program)X1523(prior)X1734(to)X1833(the)X1975(preceding)X2379(code)X2585(segment:)X7 f1152 2319(#define)N1728 0.4167(KBDATAaddr)AX2880($10000)X1152 2431(#define)N1728 0.4125(TTYDATAaddr)AX2880($10001)X1152 2543(#define)N1728 0.4167(STATUSaddr)AX2880($10002)X1152 2767(unsigned)N1674(char)X1964(*KBreg,)X2428 0.4125(*STATUSreg;)AX1152 2991(KBreg)N1500(=)X1616(KBaddr;)X1152 3103 0.4219(STATUSreg)AN1732(=)X1848 0.4125(STATUSaddr;)AX1 f576 3291(The)N754(\256rst)X931(three)X1152(lines)X1362(set)X1497(up)X1621(the)X1767(constants)X2153(to)X2257(represent)X2639(the)X2786(addresses)X3183(of)X3292(the)X3439(device)X3720(addresses.)X4141(The)X576 3403(4th)N738(line)X922(declares)X1276(the)X1432(2)X1518(pointer)X1829(\(or)X1979(address\))X2337(variables)X2723(that)X2906(are)X3062(needed)X3373(to)X3486(reference)X3883(the)X4039(device)X576 3515(registers.)N975(The)X1150(5th)X1298(and)X1462(6th)X1610(lines)X1817(initialize)X2181(these)X2404(pointers)X2739(to)X2839(actually)X3170(point)X3394(to)X3495(the)X3639(desired)X3943(locations)X576 3627(\(i.e.,)N779(the)X926(device)X1207(registers\).)X1641(Now,)X1879(referring)X2244(back)X2454(to)X2557(the)X7 f2737(READ)X1 f2997(segment,)X3370(the)X3516(while)X3758(statement)X4156(is)X4248(a)X576 3739(polling)N873(loop)X1068(which)X1327(forces)X1586(the)X1728(segment)X2073(to)X2172("wait")X2440(until)X2641(a)X2708(key)X2871(is)X2960(pressed.)X3297(This)X3493(is)X3582(done)X3794(by)X3915(the)X4058(use)X4211(of)X576 3851(the)N748(expression)X7 f1247 0.4091(\(\(*STATUSreg)AX2031(&)X2177(0x80\))X2555(==)X2759(0\))X1 f2875(,)X2952(which)X3240(masks)X3533(off)X3698(all)X3848(bits)X4040(of)X4173(the)X576 3963(STATUS)N964(register)X1279(except)X1557(for)X1695(Cin)X1860(\(bit)X2020(7\),)X2150(and)X2315(then)X2507(testing)X2790(the)X2934(resulting)X3297(byte)X3489(for)X3627(zero)X3819(or)X3925(non-zero.)X576 4075(As)N713(long)X915(as)X1026(Cin)X1196(is)X1291(0,)X1394(the)X1543(program)X1900(will)X2081(not)X2234(progress)X2589(beyond)X2902(the)X3050(while)X3294(loop.)X3519(This)X3720(type)X3916(of)X4026(loop)X4227(is)X576 4187(called)N841(a)X918(``busy-wait'')X1459(loop)X1664(because)X2003(it)X2091(forces)X2360(the)X2512(program)X2873(to)X2983(be)X3109(busy,)X3349(while)X3598(waiting)X3922(for)X4069(input.)X576 4299(The)N755(second)X1051(line)X1225(of)X1334(the)X1481(READ)X1771(segment)X2121(actually)X2456(reads)X2688(the)X2835(data)X3025(out)X3177(of)X3286(KBDATA)X3714(into)X3892(a)X3963(the)X4109(vari-)X576 4411(able)N7 f805(ch)X1 f921(.)X979(Recall,)X1284(according)X1698(to)X1807(the)X1959(de\256nition)X2363(of)X2478(Cin,)X2676(this)X2850(operation)X3249(also)X3439(clears)X3699(Cin)X3873(so)X3993(that)X4173(the)X576 4523(next)N772(this)X941(segment)X1292(of)X1402(code)X1614(\()X7 f1646(READ)X1 f1878(\))X1940(is)X2034(executed,)X2431(the)X2579(CPU)X2795(will)X2975(have)X3187(to)X3292("wait")X3565(for)X3706(the)X3853(next)X4048(key)X4216(to)X576 4635(be)N691(pressed.)X776 4775(Now,)N1030(consider)X1400(a)X1487(C)X1595(code)X1821(segment)X2186(that)X2375(echos)X2638(the)X2800(character)X3198(read)X3408(in)X3527(above)X3801(on)X3941(the)X4104(TTY)X576 4887(display.)N7 f1152 5047(unsigned)N1674(char)X1964(*TTYreg;)X1152 5271(TTYreg)N1558(=)X1674(TTYaddr;)X1152 5495(/*)N1326(ECHO)X1616(*/)X1152 5607(while)N1500 0.4091(\(\(*STATUSreg)AX2254(&)X2370 0.4219(0x40\)!=0\))AX2950(;)X3066(/*)X3240(do)X3414(nothing)X3878(*/)X1152 5719(*TTYreg)N1616(=)X1732(ch;)X1152 5831(.)N1326(.)X1500(.)X45 p%%Page: 45 1012 s 0 xH 0 xS 7 f3 f576 400(57:017)N872(CIE)X1 f2329(-)X2385(45)X2505(-)X3 f3717(Lecture)X4062(Notes)X1 f576 803(The)N757(structure)X1125(of)X1236(this)X1406(segment)X1758(is)X1853(very)X2055(similar)X2354(to)X2460(READ.)X2800(The)X7 f3015(while)X1 f3336(statement)X3737(polls)X3955(the)X4104(Cout)X576 915(bit)N708(\(bit)X872(6\))X982(of)X1092(STATUS)X1484(to)X1589(be)X1710(sure)X1900(that)X2075(the)X2223(most)X2440(recent)X2706(previously-written)X3447(character)X3830(has)X3987(\256nished)X576 1027(being)N822(displayed)X1223(by)X1351(the)X1501(TTY)X1720(device.)X2052(Once)X2287(the)X2437(Cout)X2656(bit)X2790(changes)X3132(to)X3239(0,)X3343(the)X3493(test)X3659(contained)X4066(in)X4173(the)X7 f576 1139(while)N1 f892(statement)X1288(will)X1464(fail)X1619(\(because)X7 f2016 0.4125(\(*STATUSreg)AX2714(&0x40\))X1 f3088(will)X3264(be)X3381(zero\))X3605(and)X3770(control)X4068(of)X4173(the)X576 1251(program)N931(will)X1110(proceed)X1444(to)X1549(the)X1697(line)X1872(immediately)X2385(following)X2789(the)X2937(while)X3181(loop.)X3406(This)X3607(line)X3782(will)X3962(copy)X4179(\(or)X576 1363(write\))N832(the)X976(ASCII)X1252(code)X1460(in)X7 f1595(ch)X1 f1737(into)X1913(TTYDATA.)X2440(Recall,)X2737(this)X2902(also)X3083(sets)X3253(Cout)X3466(again)X3701(so)X3812(that)X3982(the)X4125(next)X576 1475(time)N781(the)X932(ECHO)X1226(segment)X1581(is)X1679(executed,)X2080(it)X2168(will)X2352(have)X2568(to)X2677("wait")X2955(until)X3166(the)X3318(TTY)X3539(device)X3825(has)X3987(\256nished)X576 1587(displaying)N1001(the)X1143(character.)X3 f576 1811(4.7.)N768(Basic)X1011(I/O)X1174(Concepts:)X1632(A)X1725(Preview)X1 f776 1951(The)N950(following)X1348(is)X1436(a)X1503(list)X1645(of)X1749(the)X1891(major)X2140(concepts)X2501(to)X2600(be)X2715(covered)X3044(in)X3143(our)X3295(study)X3527(of)X3631(I/O:)X776 2091(1.)N920(Parallel)X1239(I/O)X776 2231(2.)N920(Timers)X776 2371(3.)N920(Polled)X1190(I/O)X776 2511(4.)N920(Analog)X1227(to)X1326(Digital)X1618(Conversion)X776 2651(5.)N920(Digital)X1212(to)X1311(Analog)X1618(Conversion)X776 2791(6.)N920(Interrupt-driven)X1559(I/O)X776 2931(7.)N920(Serial)X1169(Data)X1375(Transmission)X1917(or)X2021(Serial)X2270(I/O)X576 3071(These)N830(topics)X1084(will)X1258(be)X1374(covered)X1704(in)X1804(detail)X2044(in)X2144(the)X2287(following)X2686(Chapters)X3053(as)X3158(well)X3349(as)X3454(the)X3597(laboratory)X4018(experi-)X576 3183(ments.)N46 p%%Page: 46 1112 s 0 xH 0 xS 1 f3 f576 400(57:017)N872(CIE)X1 f2329(-)X2385(46)X2505(-)X3 f3717(Lecture)X4062(Notes)X1516 2867(-)N1572(THIS)X1825(PAGE)X2116(INTENTIONALLY)X2954(BLANK)X3319(-)X11 p%%Trailerxtxs

⌨️ 快捷键说明

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