摘要:本水位监测报警器使用5V低压直流电源(也可以用3节5号电池代替)就可以对5~15厘米的水位进行监测,用LED显示和数码管显示水位,并可以对不再此范围内的水位发出报警。主要采用CD4066、74LS86、74LS32、CD4511芯片,再加上数码管、蜂鸣器、发光二极管、电阻这些器件组成一个简单而灵敏的监测报警电路,操作简单,接通电源即可工作。因为大部分电路采用数字电路,所以本水位监测报警器还具有耗能低、准确性高的特点。关键字:译码电路 报警电路 监测电路 Abstract: The water level alarm monitoring the use of 5 V low-voltage DC power (can also use three batteries replaced on the 5th) will be able to 5 to 15 centimeters of water level monitoring, with LED display and digital display of water level, and this can no longer Within the scope of a water level alarm. Mainly CD4066, 74LS86, 74LS32, CD4511 chips, coupled with digital control, buzzer, light-emitting diode, the resistance of these devices composed of a simple and sensitive monitoring alarm circuits. Because the majority of circuits using digital circuitry, so the water level monitored alarm system also has low energy consumption, high accuracy of the characteristics. Keyword: Decoding circuit alarm circuit monitoring circuit
上传时间: 2013-11-05
上传用户:王庆才
The C500 microcontroller family usually provides only one on-chip synchronous serialchannel (SSC). If a second SSC is required, an emulation of the missing interface mayhelp to avoid an external hardware solution with additional electronic components.The solution presented in this paper and in the attached source files emulates the mostimportant SSC functions by using optimized SW routines with a performance up to 25KBaud in Slave Mode with half duplex transmission and an overhead less than 60% atSAB C513 with 12 MHz. Due to the implementation in C this performance is not the limitof the chip. A pure implementation in assembler will result in a strong reduction of theCPU load and therefore increase the maximum speed of the interface. In addition,microcontrollers like the SAB C505 will speed up the interface by a factor of two becauseof an optimized architecture compared with the SAB C513.Moreover, this solution lays stress on using as few on-chip hardware resources aspossible. A more excessive consumption of those resources will result in a highermaximum speed of the emulated interface.Due to the restricted performance of an 8 bit microcontroller a pin compatible solution isprovided only; the internal register based programming interface is replaced by a set ofsubroutine calls.The attached source files also contain a test shell, which demonstrates how to exchangeinformation between an on-chip HW-SSC and the emulated SW-SSC via 5 external wiresin different operation modes. It is based on the SAB C513 (Siemens 8 bit microcontroller).A table with load measurements is presented to give an indication for the fraction of CPUperformance required by software for emulating the SSC.
标签: synchronous Emulating serial
上传时间: 2014-01-31
上传用户:z1191176801
The solution presented in this paper and in the attached source files emulates the mostimportant SSC functions by using SW routines implemented in C. The code is focused onthe SAB C513, but will fit to all C500 derivatives.Beyond the low level software drivers a test shell is delivered. This shell allows a quicktest of the software drivers by an emulator or a starter kit demo board.
上传时间: 2013-11-24
上传用户:363186
Internal Interrupts are used to respond to asynchronous requests from a certain part of themicrocontroller that needs to be serviced. Each peripheral in the TriCore as well as theBus Control Unit, the Debug Unit, the Peripheral Control Processor (PCP) and the CPUitself can generate an Interrupt Request.So what is an external Interrupt?An external Interrupt is something alike as the internal Interrupt. The difference is that anexternal Interrupt request is caused by an external event. Normally this would be a pulseon Port0 or Port1, but it can be even a signal from the input buffer of the SSC, indicatingthat a service is requested.The User’s Manual does not explain this aspect in detail so this ApNote will explain themost common form of an external Interrupt request. This ApNote will show that there is aneasy way to react on a pulse on Port0 or Port1 and to create with this impulse an InterruptService Request. Later in the second part of the document, you can find hints on how todebounce impulses to enable the use of a simple switch as the input device.Note: You will find additional information on how to setup the Interrupt System in theApNote “First steps through the TriCore Interrupt System” (AP3222xx)1. It would gobeyond the scope of this document to explain this here, but you will find selfexplanatoryexamples later on.
上传时间: 2013-10-27
上传用户:zhangyigenius
The Infineon TriCore provides an Interrupt System with a high safety standard. Thisdocument contains some instructions on how to initiate an Interrupt from an externaldevice. First it will show you how to trigger an Interrupt Service Request by an impulseon Port 0 or Port 1. Then in the second part of the document you can find hints how todebounce impulses to enable the use of a simple switch as input device.Authors: Thomas Bliem, CQ Nguyen / Infineon SMI MD Apps
上传时间: 2013-11-05
上传用户:uuuuuuu
All inputs of the C16x family have Schmitt-Trigger input characteristics. These Schmitt-Triggers are intended to always provide proper internal low and high levels, even if anundefined voltage level (between TTL-VIL and TTL-VIH) is externally applied to the pin.The hysteresis of these inputs, however, is very small, and can not be properly used in anapplication to suppress signal noise, and to shape slow rising/falling input transitions.Thus, it must be taken care that rising/falling input signals pass the undefined area of theTTL-specification between VIL and VIH with a sufficient rise/fall time, as generally usualand specified for TTL components (e.g. 74LS series: gates 1V/us, clock inputs 20V/us).The effect of the implemented Schmitt-Trigger is that even if the input signal remains inthe undefined area, well defined low/high levels are generated internally. Note that allinput signals are evaluated at specific sample points (depending on the input and theperipheral function connected to it), at that signal transitions are detected if twoconsecutive samples show different levels. Thus, only the current level of an input signalat these sample points is relevant, that means, the necessary rise/fall times of the inputsignal is only dependant on the sample rate, that is the distance in time between twoconsecutive evaluation time points. If an input signal, for instance, is sampled throughsoftware every 10us, it is irrelevant, which input level would be seen between thesamples. Thus, it would be allowable for the signal to take 10us to pass through theundefined area. Due to the sample rate of 10us, it is assured that only one sample canoccur while the signal is within the undefined area, and no incorrect transition will bedetected. For inputs which are connected to a peripheral function, e.g. capture inputs, thesample rate is determined by the clock cycle of the peripheral unit. In the case of theCAPCOM unit this means a sample rate of 400ns @ 20MHz CPU clock. This requiresinput signals to pass through the undefined area within these 400ns in order to avoidmultiple capture events.For input signals, which do not provide the required rise/fall times, external circuitry mustbe used to shape the signal transitions.In the attached diagram, the effect of the sample rate is shown. The numbers 1 to 5 in thediagram represent possible sample points. Waveform a) shows the result if the inputsignal transition time through the undefined TTL-level area is less than the time distancebetween the sample points (sampling at 1, 2, 3, and 4). Waveform b) can be the result ifthe sampling is performed more than once within the undefined area (sampling at 1, 2, 5,3, and 4).Sample points:1. Evaluation of the signal clearly results in a low level2. Either a low or a high level can be sampled here. If low is sampled, no transition willbe detected. If the sample results in a high level, a transition is detected, and anappropriate action (e.g. capture) might take place.3. Evaluation here clearly results in a high level. If the previous sample 2) had alreadydetected a high, there is no change. If the previous sample 2) showed a low, atransition from low to high is detected now.
上传时间: 2013-10-23
上传用户:copu
All inputs of the C16x family have Schmitt-Trigger input characteristics. These Schmitt-Triggers are intended to always provide proper internal low and high levels, even if anundefined voltage level (between TTL-VIL and TTL-VIH) is externally applied to the pin.The hysteresis of these inputs, however, is very small, and can not be properly used in anapplication to suppress signal noise, and to shape slow rising/falling input transitions.Thus, it must be taken care that rising/falling input signals pass the undefined area of theTTL-specification between VIL and VIH with a sufficient rise/fall time, as generally usualand specified for TTL components (e.g. 74LS series: gates 1V/us, clock inputs 20V/us).The effect of the implemented Schmitt-Trigger is that even if the input signal remains inthe undefined area, well defined low/high levels are generated internally. Note that allinput signals are evaluated at specific sample points (depending on the input and theperipheral function connected to it), at that signal transitions are detected if twoconsecutive samples show different levels. Thus, only the current level of an input signalat these sample points is relevant, that means, the necessary rise/fall times of the inputsignal is only dependant on the sample rate, that is the distance in time between twoconsecutive evaluation time points. If an input signal, for instance, is sampled throughsoftware every 10us, it is irrelevant, which input level would be seen between thesamples. Thus, it would be allowable for the signal to take 10us to pass through theundefined area. Due to the sample rate of 10us, it is assured that only one sample canoccur while the signal is within the undefined area, and no incorrect transition will bedetected. For inputs which are connected to a peripheral function, e.g. capture inputs, thesample rate is determined by the clock cycle of the peripheral unit. In the case of theCAPCOM unit this means a sample rate of 400ns @ 20MHz CPU clock. This requiresinput signals to pass through the undefined area within these 400ns in order to avoidmultiple capture events.
上传时间: 2014-04-02
上传用户:han_zh
CAN与RS232转换节点的设计与实现 介绍将CAN总线接口与RS232总线接口相互转换的设计方法和2种总线电平转换关系,实现CAN总线与各模块的接口设计,制定了相应的软硬件设计方案,并给出软件设计流程图以及部分硬件设计原理图。为CAN总线与RS232总线互联提供了一种方法,对CAN总线与RS232总线接口设备的互联和广泛应用的实现具有重要意义。关键词:CAN总线;RS-232总线;串行通信Design and Realization of CAN and RS232 Transformation NodeZHOU Wei, CHENG Xiao-hong(Information Institute, Wuhan University of Technology, Wuhan 430070)【Abstract】This paper introduces one design method of the CAN bus interface and the RS232 bus interface interconversion, emphasizes two kindof bus level transformation relations, realizes the CAN bus and various modules connection design, formulates the design proposal of correspondingsoftware and hardware, and gives the flow chart of software design as well as the partial schematic diagram of hardware design. It providesonemethod for the CAN bus and the RS232 bus interconnection, has the vital significance to widespread application realization of the CAN busand theRS232 bus interface equipment interconnection.【Key words】CAN bus; RS-232 bus; serial communication
上传时间: 2013-11-04
上传用户:leesuper
九.输入/输出保护为了支持多任务,80386不仅要有效地实现任务隔离,而且还要有效地控制各任务的输入/输出,避免输入/输出冲突。本文将介绍输入输出保护。 这里下载本文源代码。 <一>输入/输出保护80386采用I/O特权级IPOL和I/O许可位图的方法来控制输入/输出,实现输入/输出保护。 1.I/O敏感指令输入输出特权级(I/O Privilege Level)规定了可以执行所有与I/O相关的指令和访问I/O空间中所有地址的最外层特权级。IOPL的值在如下图所示的标志寄存器中。 标 志寄存器 BIT31—BIT18 BIT17 BIT16 BIT15 BIT14 BIT13—BIT12 BIT11 BIT10 BIT9 BIT8 BIT7 BIT6 BIT5 BIT4 BIT3 BIT2 BIT1 BIT0 00000000000000 VM RF 0 NT IOPL OF DF IF TF SF ZF 0 AF 0 PF 1 CF I/O许可位图规定了I/O空间中的哪些地址可以由在任何特权级执行的程序所访问。I/O许可位图在任务状态段TSS中。 I/O敏感指令 指令 功能 保护方式下的执行条件 CLI 清除EFLAGS中的IF位 CPL<=IOPL STI 设置EFLAGS中的IF位 CPL<=IOPL IN 从I/O地址读出数据 CPL<=IOPL或I/O位图许可 INS 从I/O地址读出字符串 CPL<=IOPL或I/O位图许可 OUT 向I/O地址写数据 CPL<=IOPL或I/O位图许可 OUTS 向I/O地址写字符串 CPL<=IOPL或I/O位图许可 上表所列指令称为I/O敏感指令,由于这些指令与I/O有关,并且只有在满足所列条件时才可以执行,所以把它们称为I/O敏感指令。从表中可见,当前特权级不在I/O特权级外层时,可以正常执行所列的全部I/O敏感指令;当特权级在I/O特权级外层时,执行CLI和STI指令将引起通用保护异常,而其它四条指令是否能够被执行要根据访问的I/O地址及I/O许可位图情况而定(在下面论述),如果条件不满足而执行,那么将引起出错码为0的通用保护异常。 由于每个任务使用各自的EFLAGS值和拥有自己的TSS,所以每个任务可以有不同的IOPL,并且可以定义不同的I/O许可位图。注意,这些I/O敏感指令在实模式下总是可执行的。 2.I/O许可位图如果只用IOPL限制I/O指令的执行是很不方便的,不能满足实际要求需要。因为这样做会使得在特权级3执行的应用程序要么可访问所有I/O地址,要么不可访问所有I/O地址。实际需要与此刚好相反,只允许任务甲的应用程序访问部分I/O地址,只允许任务乙的应用程序访问另一部分I/O地址,以避免任务甲和任务乙在访问I/O地址时发生冲突,从而避免任务甲和任务乙使用使用独享设备时发生冲突。 因此,在IOPL的基础上又采用了I/O许可位图。I/O许可位图由二进制位串组成。位串中的每一位依次对应一个I/O地址,位串的第0位对应I/O地址0,位串的第n位对应I/O地址n。如果位串中的第位为0,那么对应的I/O地址m可以由在任何特权级执行的程序访问;否则对应的I/O地址m只能由在IOPL特权级或更内层特权级执行的程序访问。如果在I/O外层特权级执行的程序访问位串中位值为1的位所对应的I/O地址,那么将引起通用保护异常。 I/O地址空间按字节进行编址。一条I/O指令最多可涉及四个I/O地址。在需要根据I/O位图决定是否可访问I/O地址的情况下,当一条I/O指令涉及多个I/O地址时,只有这多个I/O地址所对应的I/O许可位图中的位都为0时,该I/O指令才能被正常执行,如果对应位中任一位为1,就会引起通用保护异常。 80386支持的I/O地址空间大小是64K,所以构成I/O许可位图的二进制位串最大长度是64K个位,即位图的有效部分最大为8K字节。一个任务实际需要使用的I/O许可位图大小通常要远小于这个数目。 当前任务使用的I/O许可位图存储在当前任务TSS中低端的64K字节内。I/O许可位图总以字节为单位存储,所以位串所含的位数总被认为是8的倍数。从前文中所述的TSS格式可见,TSS内偏移66H的字确定I/O许可位图的开始偏移。由于I/O许可位图最长可达8K字节,所以开始偏移应小于56K,但必须大于等于104,因为TSS中前104字节为TSS的固定格式,用于保存任务的状态。 1.I/O访问许可检查细节保护模式下处理器在执行I/O指令时进行许可检查的细节如下所示。 (1)若CPL<=IOPL,则直接转步骤(8);(2)取得I/O位图开始偏移;(3)计算I/O地址对应位所在字节在I/O许可位图内的偏移;(4)计算位偏移以形成屏蔽码值,即计算I/O地址对应位在字节中的第几位;(5)把字节偏移加上位图开始偏移,再加1,所得值与TSS界限比较,若越界,则产生出错码为0的通用保护故障;(6)若不越界,则从位图中读对应字节及下一个字节;(7)把读出的两个字节与屏蔽码进行与运算,若结果不为0表示检查未通过,则产生出错码为0的通用保护故障;(8)进行I/O访问。设某一任务的TSS段如下: TSSSEG SEGMENT PARA USE16 TSS <> ;TSS低端固定格式部分 DB 8 DUP(0) ;对应I/O端口00H—3FH DB 10000000B ;对应I/O端口40H—47H DB 01100000B ;对用I/O端口48H—4FH DB 8182 DUP(0ffH) ;对应I/O端口50H—0FFFFH DB 0FFH ;位图结束字节TSSLen = $TSSSEG ENDS 再假设IOPL=1,CPL=3。那么如下I/O指令有些能正常执行,有些会引起通用保护异常: in al,21h ;(1)正常执行 in al,47h ;(2)引起异常 out 20h,al ;(3)正常实行 out 4eh,al ;(4)引起异常 in al,20h ;(5)正常执行 out 20h,eax ;(6)正常执行 out 4ch,ax ;(7)引起异常 in ax,46h ;(8)引起异常 in eax,42h ;(9)正常执行 由上述I/O许可检查的细节可见,不论是否必要,当进行许可位检查时,80386总是从I/O许可位图中读取两个字节。目的是为了尽快地执行I/O许可检查。一方面,常常要读取I/O许可位图的两个字节。例如,上面的第(8)条指令要对I/O位图中的两个位进行检查,其低位是某个字节的最高位,高位是下一个字节的最低位。可见即使只要检查两个位,也可能需要读取两个字节。另一方面,最多检查四个连续的位,即最多也只需读取两个字节。所以每次要读取两个字节。这也是在判别是否越界时再加1的原因。为此,为了避免在读取I/O许可位图的最高字节时产生越界,必须在I/O许可位图的最后填加一个全1的字节,即0FFH。此全1的字节应填加在最后一个位图字节之后,TSS界限范围之前,即让填加的全1字节在TSS界限之内。 I/O许可位图开始偏移加8K所得的值与TSS界限值二者中较小的值决定I/O许可位图的末端。当TSS的界限大于I/O许可位图开始偏移加8K时,I/O许可位图的有效部分就有8K字节,I/O许可检查全部根据全部根据该位图进行。当TSS的界限不大于I/O许可位图开始偏移加8K时,I/O许可位图有效部分就不到8K字节,于是对较小I/O地址访问的许可检查根据位图进行,而对较大I/O地址访问的许可检查总被认为不可访问而引起通用保护故障。因为这时会发生字节越界而引起通用保护异常,所以在这种情况下,可认为不足的I/O许可位图的高端部分全为1。利用这个特点,可大大节约TSS中I/O许可位图占用的存储单元,也就大大减小了TSS段的长度。 <二>重要标志保护输入输出的保护与存储在标志寄存器EFLAGS中的IOPL密切相关,显然不能允许随便地改变IOPL,否则就不能有效地实现输入输出保护。类似地,对EFLAGS中的IF位也必须加以保护,否则CLI和STI作为敏感指令对待是无意义的。此外,EFLAGS中的VM位决定着处理器是否按虚拟8086方式工作。 80386对EFLAGS中的这三个字段的处理比较特殊,只有在较高特权级执行的程序才能执行IRET、POPF、CLI和STI等指令改变它们。下表列出了不同特权级下对这三个字段的处理情况。 不同特权级对标志寄存器特殊字段的处理 特权级 VM标志字段 IOPL标志字段 IF标志字段 CPL=0 可变(初POPF指令外) 可变 可变 0 不变 不变 可变 CPL>IOPL 不变 不变 不变 从表中可见,只有在特权级0执行的程序才可以修改IOPL位及VM位;只能由相对于IOPL同级或更内层特权级执行的程序才可以修改IF位。与CLI和STI指令不同,在特权级不满足上述条件的情况下,当执行POPF指令和IRET指令时,如果试图修改这些字段中的任何一个字段,并不引起异常,但试图要修改的字段也未被修改,也不给出任何特别的信息。此外,指令POPF总不能改变VM位,而PUSHF指令所压入的标志中的VM位总为0。 <三>演示输入输出保护的实例(实例九)下面给出一个用于演示输入输出保护的实例。演示内容包括:I/O许可位图的作用、I/O敏感指令引起的异常和特权指令引起的异常;使用段间调用指令CALL通过任务门调用任务,实现任务嵌套。 1.演示步骤实例演示的内容比较丰富,具体演示步骤如下:(1)在实模式下做必要准备后,切换到保护模式;(2)进入保护模式的临时代码段后,把演示任务的TSS段描述符装入TR,并设置演示任务的堆栈;(3)进入演示代码段,演示代码段的特权级是0;(4)通过任务门调用测试任务1。测试任务1能够顺利进行;(5)通过任务门调用测试任务2。测试任务2演示由于违反I/O许可位图规定而导致通用保护异常;(6)通过任务门调用测试任务3。测试任务3演示I/O敏感指令如何引起通用保护异常;(7)通过任务门调用测试任务4。测试任务4演示特权指令如何引起通用保护异常;(8)从演示代码转临时代码,准备返回实模式;(9)返回实模式,并作结束处理。
上传时间: 2013-12-11
上传用户:nunnzhy
微处理器及微型计算机的发展概况 第一代微处理器是以Intel公司1971年推出的4004,4040为代表的四位微处理机。 第二代微处理机(1973年~1977年),典型代表有:Intel 公司的8080、8085;Motorola公司的M6800以及Zlog公司的Z80。 第三代微处理机 第三代微机是以16位机为代表,基本上是在第二代微机的基础上发展起来的。其中Intel公司的8088。8086是在8085的基础发展起来的;M68000是Motorola公司在M6800 的基础发展起来的; 第四代微处理机 以Intel公司1984年10月推出的80386CPU和1989年4月推出的80486CPU为代表, 第五代微处理机的发展更加迅猛,1993年3月被命名为PENTIUM的微处理机面世,98年PENTIUM 2又被推向市场。 INTEL CPU 发展历史Intel第一块CPU 4004,4位主理器,主频108kHz,运算速度0.06MIPs(Million Instructions Per Second, 每秒百万条指令),集成晶体管2,300个,10微米制造工艺,最大寻址内存640 bytes,生产曰期1971年11月. 8085,8位主理器,主频5M,运算速度0.37MIPs,集成晶体管6,500个,3微米制造工艺,最大寻址内存64KB,生产曰期1976年 8086,16位主理器,主频4.77/8/10MHZ,运算速度0.75MIPs,集成晶体管29,000个,3微米制造工艺,最大寻址内存1MB,生产曰期1978年6月. 80486DX,DX2,DX4,32位主理器,主频25/33/50/66/75/100MHZ,总线频率33/50/66MHZ,运算速度20~60MIPs,集成晶体管1.2M个,1微米制造工艺,168针PGA,最大寻址内存4GB,缓存8/16/32/64KB,生产曰期1989年4月 Celeron一代, 主频266/300MHZ(266/300MHz w/o L2 cache, Covington芯心 (Klamath based),300A/333/366/400/433/466/500/533MHz w/128kB L2 cache, Mendocino核心 (Deschutes-based), 总线频率66MHz,0.25微米制造工艺,生产曰期1998年4月) Pentium 4 (478针),至今分为三种核心:Willamette核心(主频1.5G起,FSB400MHZ,0.18微米制造工艺),Northwood核心(主频1.6G~3.0G,FSB533MHZ,0.13微米制造工艺, 二级缓存512K),Prescott核心(主频2.8G起,FSB800MHZ,0.09微米制造工艺,1M二级缓存,13条全新指令集SSE3),生产曰期2001年7月. 更大的缓存、更高的频率、 超级流水线、分支预测、乱序执行超线程技术 微型计算机组成结构单片机简介单片机即单片机微型计算机,是将计算机主机(CPU、 内存和I/O接口)集成在一小块硅片上的微型机。 三、计算机编程语言的发展概况 机器语言 机器语言就是0,1码语言,是计算机唯一能理解并直接执行的语言。汇编语言 用一些助记符号代替用0,1码描述的某种机器的指令系统,汇编语言就是在此基础上完善起来的。高级语言 BASIC,PASCAL,C语言等等。用高级语言编写的程序称源程序,它们必须通过编译或解释,连接等步骤才能被计算机处理。 面向对象语言 C++,Java等编程语言是面向对象的语言。 1.3 微型计算机中信息的表示及运算基础(一) 十进制ND有十个数码:0~9,逢十进一。 例 1234.5=1×103 +2×102 +3×101 +4×100 +5×10-1加权展开式以10称为基数,各位系数为0~9,10i为权。 一般表达式:ND= dn-1×10n-1+dn-2×10n-2 +…+d0×100 +d-1×10-1+… (二) 二进制NB两个数码:0、1, 逢二进一。 例 1101.101=1×23+1×22+0×21+1×20+1×2-1+1×2-3 加权展开式以2为基数,各位系数为0、1, 2i为权。 一般表达式: NB = bn-1×2n-1 + bn-2×2n-2 +…+b0×20 +b-1×2-1+… (三)十六进制NH十六个数码0~9、A~F,逢十六进一。 例:DFC.8=13×162 +15×161 +12×160 +8×16-1 展开式以十六为基数,各位系数为0~9,A~F,16i为权。 一般表达式: NH= hn-1×16n-1+ hn-2×16n-2+…+ h0×160+ h-1×16-1+… 二、不同进位计数制之间的转换 (二)二进制与十六进制数之间的转换 24=16 ,四位二进制数对应一位十六进制数。举例:(三)十进制数转换成二、十六进制数整数、小数分别转换 1.整数转换法“除基取余”:十进制整数不断除以转换进制基数,直至商为0。每除一次取一个余数,从低位排向高位。举例: 2. 小数转换法“乘基取整”:用转换进制的基数乘以小数部分,直至小数为0或达到转换精度要求的位数。每乘一次取一次整数,从最高位排到最低位。举例: 三、带符号数的表示方法 机器数:机器中数的表示形式。真值: 机器数所代表的实际数值。举例:一个8位机器数与它的真值对应关系如下: 真值: X1=+84=+1010100B X2=-84= -1010100B 机器数:[X1]机= 01010100 [X2]机= 11010100(二)原码、反码、补码最高位为符号位,0表示 “+”,1表示“-”。 数值位与真值数值位相同。 例 8位原码机器数: 真值: x1 = +1010100B x2 =- 1010100B 机器数: [x1]原 = 01010100 [x2]原 = 11010100原码表示简单直观,但0的表示不唯一,加减运算复杂。 正数的反码与原码表示相同。 负数反码符号位为 1,数值位为原码数值各位取反。 例 8位反码机器数: x= +4: [x]原= 00000100 [x]反= 00000100 x= -4: [x]原= 10000100 [x]反= 111110113、补码(Two’s Complement)正数的补码表示与原码相同。 负数补码等于2n-abs(x)8位机器数表示的真值四、 二进制编码例:求十进制数876的BCD码 876= 1000 0111 0110 BCD 876= 36CH = 1101101100B 2、字符编码 美国标准信息交换码ASCII码,用于计算 机与计算机、计算机与外设之间传递信息。 3、汉字编码 “国家标准信息交换用汉字编码”(GB2312-80标准),简称国标码。 用两个七位二进制数编码表示一个汉字 例如“巧”字的代码是39H、41H汉字内码例如“巧”字的代码是0B9H、0C1H1·4 运算基础 一、二进制数的运算加法规则:“逢2进1” 减法规则:“借1当2” 乘法规则:“逢0出0,全1出1”二、二—十进制数的加、减运算 BCD数的运算规则 循十进制数的运算规则“逢10进1”。但计算机在进行这种运算时会出现潜在的错误。为了解决BCD数的运算问题,采取调整运算结果的措施:即“加六修正”和“减六修正”例:10001000(BCD)+01101001(BCD) =000101010111(BCD) 1 0 0 0 1 0 0 0 + 0 1 1 0 1 0 0 1 1 1 1 1 0 0 0 1 + 0 1 1 0 0 1 1 0 ……调整 1 0 1 0 1 0 1 1 1 进位 例: 10001000(BCD)- 01101001(BCD)= 00011001(BCD) 1 0 0 0 1 0 0 0 - 0 1 1 0 1 0 0 1 0 0 0 1 1 1 1 1 - 0 1 1 0 ……调整 0 0 0 1 1 0 0 1 三、 带符号二进制数的运算 1.5 几个重要的数字逻辑电路编码器译码器计数器微机自动工作的条件程序指令顺序存放自动跟踪指令执行1.6 微机基本结构微机结构各部分组成连接方式1、以CPU为中心的双总线结构;2、以内存为中心的双总线结构;3、单总线结构CPU结构管脚特点 1、多功能;2、分时复用内部结构 1、控制; 2、运算; 3、寄存器; 4、地址程序计数器堆栈定义 1、定义;2、管理;3、堆栈形式
上传时间: 2013-10-17
上传用户:erkuizhang