Author
evelyn-lucas
View
219
Download
0
Tags:
Embed Size (px)
PowerPoint Presentation
Octal to BinaryTechniqueConvert each octal digit to a 3-bit equivalent binary representationIntroduction to basic computer organizations and Architecture
Definition of computer & its block diagramVon man Neumann machineFunctioning of computersBus StructureComputer Organization Computer ArchitetcureComputer Computer : Computer is an electronic machine which accepts the input from input device , transfers, do operation on data and gives the out put.Peripherals or parts of computersInput device : Accepts the data/program . Ex. Keyboard, mouse and so on.Output Device: Used to give the result.Ex. Monitor, printer and so on.Central processing unit(C.P.U.) : Further divided into Arithmetic logic unit(A.L.U)Memory unit(M.U)Control Unit(C.U)Block diagram of computerFigure 1.1. Basic functional units of a computer.I/OProcessorOutputMemoryInputandArithmeticlogicControlMemory unit( M.U): Used to store the data in binary form from the input device and gives to the output to the output device.Two classes of memoryPrimary storageFastPrograms must be stored in memory while they are being executedAddressRAM and memory access timeMemory hierarchy cache, main memorySecondary storage larger and cheaper
Arithmetic Logic Unit(A.L.U.): used to fetch the data from the memory process it and aging send the data to the memory.Performs the Arithmetic and logic operationsControl UnitAll computer operations are controlled by the control unit.The timing signals that govern the I/O transfers are also generated by the control unitBus Structure
There are many ways to connect different parts inside a computer together.A group of lines that serves as a connecting path for several devices is called a bus.Address/data/control
Von Neumann Machine Architecture and its Functions:
Von Neumann ArchitectureVon Neumann Architecture consists of mainly 5 parts.Input Output deviceCentral Processing unit (C.P.U.)Arithmetic Logic Unit (A.L.U).Control Unit (C.U.)Memory Unit (M.U)Out Put Device : It is used to display the result eg: Monitor, printer and so on.Input Device : It is used to enter the data .Eg. Keyboard, mouse and so on.Central Processing Unit : (C.P.U.)Memory Unit (M.U.) : It is used to store the data in the form of binary bits.Data from the keyboard transfers to memory.Memory of 2 types Primary Memory: Used to store the data temporarily.eg. Main memory ,RAM, SRAM, DRAM.Secondary memory : Used to store the data permanently. eg. Magnetic disks, magnetic bubbles and drums.
Computer Functions
Computer Architecture Refers to specification of the relationship between different hardware components of a computer system.It defines high and low level of abstractions.At high level CPU is presented and low level its parts like ALU,MU,CU representedComputer OrganizationOrganization is how features are implementedControl signals, interfaces, memory technology.e.g. Is there a hardware multiply unit or is it done by repeated addition?Computer organization is a study of a Computer Architecture. E.g. Memory, Registers, RAM, ROM, CPU, ALU, 16 bit/ 32 bit/ 64 bit architecture, what different parts makes a computer, etc.
Programming Languages.There are 4 types of programming languages.High Level LanguageMiddle Level LanguageLow level LanguageAssembly Level Language.
Compiler : It is used to translate the Highlevel language (English statements) to low level language (1 0s).Compile entire program one at time. eg. Pascal, Basic, Fortran and so on.Interpreter : Used to translate the program high level language into low level language. It translates instruction by instruction.eg. Java Assembler : Used to translate the Assembly level language (Mnemonics) into low level language.Microprocessor: This is a smallest part of the processor which performs the following functions like Storing data Transferring Performing Arehtmetic and logical operations.Shift Operations and so on.Eg: 8086,80386.
Week 3 Organization of the IBM Personal computers
ArchitectureRegistersMemoriesAddressing modesInstruction setsInterrupts
Organization of the 8088/8086 CAP/IT22119
Organization of the 8088/8086 CAP/IT22120 2 main components: . Execution Unit (EU). . Bus Interface Unit (BIU).EU: ALU + Registers (AX, BX, CX, DX, SI, DI, BP, and SP) + FLAGS register. ALU: performs arithmetic & logic operations. Registers: store data FLAGS register: Individual bits reflect the result of a computation.Organization of the 8088/8086 CAP/IT22121BIU: facilitates communication between the EU & the memory or I/O circuits. Responsible for transmitting addresses, data, and control signals on the buses. Registers (CS, DS, ES, SS, and IP) hold addresses of memory locations. IP (instruction pointer) contain the address of the next instruction to be executed by the EU.Organization of the 8088/8086 16-bit registers, 1M Bytes Memory
Registers:Information is stored in registersRegisters are classified according to the functions they performCAP/IT22122RegistersData registers: 4 general data registers hold data for an operation. Address registers: (segment, pointer and index registers) hold the address of an instruction or data. Status register: FLAG register keeps the current states of the processor. 14 16-bit registersCAP/IT22123Register
CAP/IT22124General Data Register: Used for general data manipulation.They are 16-bit registers that can also be used as two 8 bit registers: low and high bytes can be accessed separately more registers to use when dealing with byte-size data.In addition to being general-purpose registers, they perform special functions
CAP/IT22125AX (Accumulator)Most efficient register for arithmetic, logic operations and data transfer: the use of AX generates the shortest machine code.In multiplication and division operations, one of the numbers involved must be in Al or AXBX (Base)Can hold addresses (offset)
CAP/IT22126CX (Counter)Counter for looping operations: loop counter, in REP instruction, and in the shift and rotate bitsDX (Data):
Used in multiply and divide, also used in I/O operations
CAP/IT22127Pointer Registers SP (Stack Pointer): Used with SS for accessing the stack segment.BP ( Base Pointer): Used with SS to access data on the stack. However, unlike SP, BP can be used to access data in other segments.CAP/IT22128Instruction pointerIP (Instruction pointer): Points to the next instruction. Used with CS.
Flags register Flags: Bits specify status of CPU and information about the results of the arithmetic operations.
CAP/IT22130Registers of x86Carry Flag (CF) - this flag is set to 1 when there is an unsigned overflow .Parity Flag (PF) - this flag is set to 1 when there is even number of one bits in result, and to 0 when there is odd number of one bits .Auxiliary Flag (AF) - set to 1 when there is an unsigned overflow for low nibble (4 bits). Zero Flag (ZF) - set to 1 when result is zero. For non-zero result this flag is set to 0. Registers of x86Sign Flag (SF) - set to 1 when result is negative. When result is positive it is set to 0. (This flag takes the value of the most significant bit.) .Trap Flag (TF) - Used for on-chip debugging .Interrupt enable Flag (IF) - when this flag is set to 1 CPU reacts to interrupts from external devices.Direction Flag (DF) - this flag is used by some instructions to process data chains.Overflow Flag (OF) - set to 1 when there is a signed overflow. For example, when you add bytes 100 + 50 (result is not in range -128...127) MemoriesThere are 3 types of memoriesProgram memory.Data Memory.Stack memory.Program Memory: Can be located any where in the memory.CALL and RETURN Instructions will be used.
Data Memory: the 8086 processor can access data in any one out of 4 available segments, which limits the size of accessible memory to 256 KB .Stack memory can be placed anywhere in memory. The stack can be located at odd memory addresses, but it is not recommended for performance reasons Memory Segment Is a block of 2 (64) K Bytes consecutive memory bytes. Each segment is identified by a 16-bit number called segment number, starting with 0000 up to FFFFh . Segment registers hold segment number.Within a segment, a memory location is specified by giving an offset (16-bit) = It is the number of bytes from the beginning of the segment (0 FFFFh). 16CAP/IT22135Memory Segment00000100002000030000400005000060000700008000090000A0000B0000C0000D0000E0000F0000One Segment8000:00008000:FFFFsegmentoffsetCAP/IT22136Segment : Offset AddressA memory location may be specified by a segment number and offset ( logical address ).Example :
A4FB : 4872 hSegmentOffsetCAP/IT22137Offset : is the distance from the beginning to a particular location in the segment.
Segment number : defines the starting of the segment within the memory space.
CAP/IT22138Interrupts Of X86INTR is a mask able hardware interrupt The interrupt can be enabled/disabled using STI/CLI instructions or using more complicated method of updating the FLAGS register with the help of the POPF instruction.When an interrupt occurs, the processor stores FLAGS register into stack, disables further interrupts
NMI is a non-mask able interrupt. Interrupt is processed in the same way as the INTR interrupt .. Interrupt type of the NMI is 2, i.e. the address of the NMI processing routine is stored in location 0008h. This interrupt has higher priority then the mask able interrupt. Software interrupts INT instruction - breakpoint interrupt. This is a type 3 interrupt. INT instruction - any one interrupt from available 256 interrupts. INTO instruction - interrupt on overflow Single-step interrupt - generated if the TF flag is set. This is a type 1 interrupt. When the CPU processes this interrupt it clears TF flag before calling the interrupt processing routine. Processor exceptions: divide error (type 0), unused opcode (type 6) and escape opcode (type 7).
Instruction SetData moving instructions. Data can be moved from register to register , memory to memory, register to memory and memory to register.Arithmetic - add, subtract, increment, decrement, convert byte/word and compare. Logic - AND, OR, exclusive OR, shift/rotate and test. String manipulation - load, store, move, compare and scan for byte/word. Control transfer - conditional, unconditional, call subroutine and return from subroutine. Input/Output instructions. Other - setting/clearing flag bits, stack operations, software interrupts, etc
Addressing modes
Implied - the data value/data address is implicitly associated with the instruction. Register - references the data in a register or in a register pair. Immediate - the data is provided in the instruction. Direct - the instruction operand specifies the memory address where data is located. Register indirect - instruction specifies a register containing an address, where data is located. This addressing mode works with SI, DI, BX and BP registers. Based - 8-bit or 16-bit instruction operand is added to the contents of a base register (BX or BP), the resulting value is a pointer to location where data resides. Indexed - 8-bit or 16-bit instruction operand is added to the contents of an index register (SI or DI), the resulting value is a pointer to location where data resides. Based Indexed - the contents of a base register (BX or BP) is added to the contents of an index register (SI or DI), the resulting value is a pointer to location where data resides. Based Indexed with displacement - 8-bit or 16-bit instruction operand is added to the contents of a base register (BX or BP) and index register (SI or DI), the resulting value is a pointer to location where data resides.Segmented Memory
linear addressesone segmentCAP/IT22144Pointer and Index RegistersSP, BP, SI, DIUsed for offset of data, often used as pointers. Unlike segment registers, they can be used in arithmetic and other operations.CAP/IT22145Index RegistersSI (Source Index): Source of string operations. Used with DS (or ES).DI (Destination Index): Destination of string operation. Used with ES (or DS).
CAP/IT22146Instruction SetData moving instructions. Data can be moved from register to register , memory to memory, register to memory and memory to register.Arithmetic - add, subtract, increment, decrement, convert byte/word and compare. Logic - AND, OR, exclusive OR, shift/rotate and test. String manipulation - load, store, move, compare and scan for byte/word. Control transfer - conditional, unconditional, call subroutine and return from subroutine. Input/Output instructions. Other - setting/clearing flag bits, stack operations, software interrupts, etc
Addressing modes
Implied - the data value/data address is implicitly associated with the instruction. Register - references the data in a register or in a register pair. Immediate - the data is provided in the instruction. Direct - the instruction operand specifies the memory address where data is located. Register indirect - instruction specifies a register containing an address, where data is located. This addressing mode works with SI, DI, BX and BP registers. Based - 8-bit or 16-bit instruction operand is added to the contents of a base register (BX or BP), the resulting value is a pointer to location where data resides. Indexed - 8-bit or 16-bit instruction operand is added to the contents of an index register (SI or DI), the resulting value is a pointer to location where data resides. Based Indexed - the contents of a base register (BX or BP) is added to the contents of an index register (SI or DI), the resulting value is a pointer to location where data resides. Based Indexed with displacement - 8-bit or 16-bit instruction operand is added to the contents of a base register (BX or BP) and index register (SI or DI), the resulting value is a pointer to location where data resides.Week 4 & 5Introduction to number systems Number systems and heir conversionsDecimal, Binary, Octal, Hex decimal
Arithmetic operations Binary AdditionBinary SubtractionBinary MultiplicationsBinary DivisionSigned and Magnitude numbersComplement numbersBinary Coded decimal numbers
Common Number SystemsSystemBaseSymbolsUsed by humans?Used in computers?Decimal100, 1, 9YesNoBinary20, 1NoYesOctal80, 1, 7NoNoHexa-decimal160, 1, 9,A, B, FNoNoQuantities/Counting (2 of 3) DecimalBinaryOctalHexa-decimal810001089100111910101012A11101113B12110014C13110115D14111016E15111117FQuantities/Counting (3 of 3) DecimalBinaryOctalHexa-decimal1610000201017100012111181001022121910011231320101002414211010125152210110261623101112717Etc.Conversion Among BasesThe possibilities:HexadecimalDecimalOctalBinarypp. 40-46Binary to DecimalHexadecimalDecimalOctalBinaryBinary to DecimalTechniqueMultiply each bit by 2n, where n is the weight of the bitThe weight is the position of the bit, starting from 0 on the rightAdd the resultsExample1010112 => 1 x 20 = 11 x 21 = 20 x 22 = 01 x 23 = 80 x 24 = 01 x 25 = 324310Bit 0Octal to DecimalHexadecimalDecimalOctalBinaryOctal to DecimalTechniqueMultiply each bit by 8n, where n is the weight of the bitThe weight is the position of the bit, starting from 0 on the rightAdd the resultsExample7248 => 4 x 80 = 42 x 81 = 167 x 82 = 44846810Hexadecimal to DecimalHexadecimalDecimalOctalBinaryHexadecimal to DecimalTechniqueMultiply each bit by 16n, where n is the weight of the bitThe weight is the position of the bit, starting from 0 on the rightAdd the resultsExampleABC16 =>C x 160 = 12 x 1 = 12 B x 161 = 11 x 16 = 176 A x 162 = 10 x 256 = 2560 274810Decimal to BinaryHexadecimalDecimalOctalBinaryDecimal to BinaryTechniqueDivide by two, keep track of the remainderFirst remainder is bit 0 (LSB, least-significant bit)Second remainder is bit 1Etc.
Example12510 = ?22 125 62 12 31 02 15 12 7 12 3 12 1 12 0 112510 = 11111012Octal to BinaryHexadecimalDecimalOctalBinaryExample7058 = ?2 7 0 5
111 000 1017058 = 1110001012Hexadecimal to BinaryHexadecimalDecimalOctalBinaryHexadecimal to BinaryTechniqueConvert each hexadecimal digit to a 4-bit equivalent binary representationExample10AF16 = ?2 1 0 A F
0001 0000 1010 111110AF16 = 00010000101011112Decimal to OctalHexadecimalDecimalOctalBinaryDecimal to OctalTechniqueDivide by 8Keep track of the remainderExample123410 = ?88 1234 154 28 19 28 2 38 0 2123410 = 23228Decimal to HexadecimalHexadecimalDecimalOctalBinaryOctal to HexadecimalTechniqueUse binary as an intermediaryExample10768 = ?16 1 0 7 6
001 000 111 110
2 3 E10768 = 23E16Hexadecimal to OctalHexadecimalDecimalOctalBinaryHexadecimal to OctalTechniqueUse binary as an intermediaryExample1F0C16 = ?8 1 F 0 C
0001 1111 0000 1100
1 7 4 1 41F0C16 = 174148Exercise Convert ...Dont use a calculator!DecimalBinaryOctalHexa-decimal3311101017031AFSkip answerAnswerExercise Convert DecimalBinaryOctalHexa-decimal3310000141211171110101165754511110000117031C34311101011116571AFAnswerCommon Powers (1 of 2)Base 10PowerPrefaceSymbol10-12picop10-9nanon10-6micro10-3millim103kilok106megaM109gigaG1012teraTValue.000000000001.000000001.000001.0011000100000010000000001000000000000Common Powers (2 of 2)Base 2PowerPrefaceSymbol210kilok220megaM230GigaGValue102410485761073741824 What is the value of k, M, and G? In computing, particularly w.r.t. memory, the base-2 interpretation generally appliesDecimal to HexadecimalTechniqueDivide by 16Keep track of the remainderExample123410 = ?16123410 = 4D21616 1234 77 216 4 13 = D16 0 4Binary to OctalHexadecimalDecimalOctalBinaryBinary to OctalTechniqueGroup bits in threes, starting on rightConvert to octal digitsExample10110101112 = ?81 011 010 111
1 3 2 7 10110101112 = 13278Binary to HexadecimalHexadecimalDecimalOctalBinaryBinary to HexadecimalTechniqueGroup bits in fours, starting on rightConvert to hexadecimal digitsExample10101110112 = ?1610 1011 1011
B B 10101110112 = 2BB16Octal to HexadecimalHexadecimalDecimalOctalBinaryOctal to HexadecimalTechniqueUse binary as an intermediaryExample10768 = ?16 1 0 7 6
001 000 111 110
2 3 E10768 = 23E16Hexadecimal to OctalHexadecimalDecimalOctalBinaryHexadecimal to OctalTechniqueUse binary as an intermediaryExample1F0C16 = ?8 1 F 0 C
0001 1111 0000 1100
1 7 4 1 41F0C16 = 174148Exercise Convert ...Dont use a calculator!DecimalBinaryOctalHexa-decimal3311101017031AFSkip answerAnswerExercise Convert DecimalBinaryOctalHexa-decimal3310000141211171110101165754511110000117031C34311101011116571AFAnswerFractionsDecimal to decimal (just for fun)pp. 46-503.14 =>4 x 10-2 = 0.041 x 10-1 = 0.1 3 x 100 = 3 3.14FractionsBinary to decimalpp. 46-5010.1011 => 1 x 2-4 = 0.06251 x 2-3 = 0.1250 x 2-2 = 0.01 x 2-1 = 0.50 x 20 = 0.01 x 21 = 2.0 2.6875FractionsDecimal to binaryp. 503.14579 .14579x 20.29158x 20.58316x 21.16632x 20.33264x 20.66528x 21.33056etc.11.001001...Exercise Convert ...Dont use a calculator!DecimalBinaryOctalHexa-decimal29.8101.11013.07C.82Skip answerAnswerExercise Convert DecimalBinaryOctalHexa-decimal29.811101.11001135.631D.CC5.8125101.11015.645.D3.10937511.0001113.073.1C12.50781251100.1000001014.404C.82AnswerTU/e Processor Design 5Z032107 Sign Magnitude: One's Complement Two's Complement000 = +0000 = +0000 = +0001 = +1001 = +1001 = +1010 = +2010 = +2010 = +2011 = +3011 = +3011 = +3100 = -0100 = -3100 = -4101 = -1101 = -2101 = -3110 = -2110 = -1110 = -2111 = -3111 = -0111 = -1
Issues: balance, number of zeros, ease of operationsWhich one is best? Why? Signed binary numbersPossible representations:9/1/2015107Common Powers (1 of 2)Base 10PowerPrefaceSymbol10-12picop10-9nanon10-6micro10-3millim103kilok106megaM109gigaG1012teraTValue.000000000001.000000001.000001.0011000100000010000000001000000000000Common Powers (2 of 2)Base 2PowerPrefaceSymbol210kilok220megaM230GigaGValue102410485761073741824 What is the value of k, M, and G? In computing, particularly w.r.t. memory, the base-2 interpretation generally appliesBinary Addition (1 of 2)Two 1-bit valuespp. 36-38ABA + B0000111011110twoBinary Addition (2 of 2)Two n-bit valuesAdd individual bitsPropagate carriesE.g., 10101 21+ 11001 + 25 101110 4611CS1104-2Binary Arithmetic Operations113Binary Arithmetic Operations (3/6)SUBTRACTIONTwo numbers can be subtracted by subtracting each pair of digits together with borrowing, where needed.
CS1104-2Binary Arithmetic Operations114Binary Arithmetic Operations (4/6)Digit subtraction table:
Borrow
CS1104-2Binary Arithmetic Operations115Binary Arithmetic Operations (5/6)MULTIPLICATIONTo multiply two numbers, take each digit of the multiplier and multiply it with the multiplicand. This produces a number of partial products which are then added.
CS1104-2Binary Arithmetic Operations116Binary Arithmetic Operations (6/6)Digit multiplication table:DIVISION can you figure out how this is done?Exercise: Think of the division technique (shift & subtract) used for decimal numbers and apply it to binary numbers.
Multiplication (1 of 3)Decimal (just for fun)pp. 39 35x 105 175 000 35 3675Multiplication (2 of 3)Binary, two 1-bit valuesABA B000010100111Multiplication (3 of 3)Binary, two n-bit valuesAs with decimal valuesE.g., 1110 x 1011 1110 1110 0000 111010011010CS1104-2Negative Numbers: Sign-and-Magnitude120Negative Numbers: Sign-and-Magnitude (1/4)Negative numbers are usually written by writing a minus sign in front.Example:- (12)10 , - (1100)2In sign-and-magnitude representation, this sign is usually represented by a bit:0 for +1 for -CS1104-2Negative Numbers:Sign-and-Magnitude121Negative Numbers:Sign-and-Magnitude (2/4)Example: an 8-bit number can have 1-bit sign and 7-bit magnitude.signmagnitudeCS1104-21s and 2s Complement1221s and 2s ComplementTwo other ways of representing signed numbers for binary numbers are: 1s-complement 2s-complementThey are preferred over the simple sign-and-magnitude representation. CS1104-21s Complement1231s Complement (1/3)Given a number x which can be expressed as an n-bit binary number, its negative value can be obtained in 1s-complement representation using: - x = 2n - x - 1
Example: With an 8-bit number 00001100, its negative value, expressed in 1s complement, is obtained as follows: -(00001100)2 = - (12)10 = (28 - 12 - 1)10 = (243)10 = (11110011)1sCS1104-21s Complement1241s Complement (2/3)Essential technique: invert all the bits.Examples: 1s complement of (00000001)1s = (11111110)1s 1s complement of (01111111)1s = (10000000)1s Largest Positive Number: 0 1111111 +(127)10Largest Negative Number: 1 0000000 -(127)10Zeroes: 0 0000000 1 1111111 Range: -(127)10 to +(127)10The most significant bit still represents the sign: 0 = +ve; 1 = -ve.CS1104-21s Complement1251s Complement (3/3)Examples (assuming 8-bit binary numbers):(14)10 = (00001110)2 = (00001110)1s -(14)10 = -(00001110)2 = (11110001)1s -(80)10 = -( ? )2 = ( ? )1s
CS1104-22s Complement1262s Complement (1/4)Given a number x which can be expressed as an n-bit binary number, its negative number can be obtained in 2s-complement representation using: - x = 2n - x Example: With an 8-bit number 00001100, its negative value in 2s complement is thus: -(00001100)2 = - (12)10 = (28 - 12)10 = (244)10 = (11110100)2sCS1104-22s Complement1272s Complement (2/4)Essential technique: invert all the bits and add 1.Examples: 2s complement of(00000001)2s = (11111110)1s (invert) = (11111111)2s (add 1) 2s complement of(01111110)2s = (10000001)1s (invert) = (10000010)2s (add 1)CS1104-22s Complement1282s Complement (3/4)Largest Positive Number: 0 1111111 +(127)10Largest Negative Number: 1 0000000 -(128)10Zero: 0 0000000 Range: -(128)10 to +(127)10The most significant bit still represents the sign: 0 = +ve; 1 = -ve.CS1104-22s Complement1292s Complement (4/4)Examples (assuming 8-bit binary numbers):(14)10 = (00001110)2 = (00001110)2s -(14)10 = -(00001110)2 = (11110010)2s -(80)10 = -( ? )2 = ( ? )2s
CS1104-2Binary Coded Decimal (BCD)130Binary Coded Decimal (BCD) (1/3)Decimal numbers are more natural to humans. Binary numbers are natural to computers. Quite expensive to convert between the two.If little calculation is involved, we can use some coding schemes for decimal numbers.One such scheme is BCD, also known as the 8421 code.Represent each decimal digit as a 4-bit binary code.CS1104-2Binary Coded Decimal (BCD)131Binary Coded Decimal (BCD) (2/3)Some codes are unused, eg: (1010)BCD, (1011) BCD, , (1111) BCD. These codes are considered as errors.Easy to convert, but arithmetic operations are more complicated.Suitable for interfaces such as keypad inputs and digital readouts.
CS1104-2Binary Coded Decimal (BCD)132Binary Coded Decimal (BCD) (3/3)Examples:(234)10 = (0010 0011 0100)BCD(7093)10 = (0111 0000 1001 0011)BCD(1000 0110)BCD = (86)10(1001 0100 0111 0010)BCD = (9472)10Notes: BCD is not equivalent to binary.Example: (234)10 = (11101010)2
Week 6:Over view of Assembly Language 8086.
Syntax Program data variables program structure sample programs.
Overview of Assembly language Executable InstructionsProgram consists of statements one per lineEach statement is instruction which assembler translates to machine code.Generate machine code for the processor to execute at runtimeInstructions tell the processor what to doAssembler DirectivesProvide information to the assembler while translating a programUsed to define data, select memory model, etc.Non-executable: directives are not part of instruction setSyntax of instructionsShorthand notation for a group of statementsSequence of instructions, directives, or other macros Assembly language instructions have the format:name OperationOperandsComments STARTMOVCX,5 ;Initialize counterSyntax of instructionsNAME FIELD : may be instruction labels, procedure names, and variables names.1-31 character long may be consists of letters, digits, and special char.Eg: COUNTER1 @Character SUM_OF_DIGITSOPERATION FIELD: Symbolic code MOV ADD SUB NOP INC AXCOMMENT FIELD: say some thing about the statement.OPERANDSArgument listProgram DataNumbers: binary, hex decimal, decimalCharacters: Characters must be enclosed in double quotes. AStrings: Strings must be enclosed single quotes hello.Variables: Name of the data types and is assigned a memory locations by the program.Byte variables: The assembler derivative that defines a byte variable takes the following formsname DB initial valueEx: ALPHA DB 4Memory is associated
Word variables: The assembler defines for defining a word variable has the following formsName DWinitial_valueArrays: Just sequence of memory bytes of words.SymbolAddress ConstantsB_ARRAY 200h10h B_ARRAY+1201h20hB_ARRAY+2202h30hW-Array DW 1000,40,29887,329Set up array of four words with initial values 1000 40,29887,329SymbolAddress ConstantsW-ARRAYDW1000,40,29887,329Set up array of four words with initial values Few Basic InstructionsMOV Destination , sourceMOV AX,WORD1 ; contents of word 1 will be moved to register AXMOV AX,BX ; contents of BX will be moved to register AXXCHG AH,BL Before AH 1A AL 00 BH 00 BL 05After AH 05 AL 00 BH 00 BL 1AADD,SUB,INC,DECADD Destination , source same for other operationsINC DestinationDEC Destination
Program StructureMemory modelsThe size of code and data a program can have is determined by specifying memory model using the .MODELSMALL Code and data in one segmentMEDIUM code in more than one segment and data in one segment.Data segment : Contains all the variable functions.DATAWord1 DW 2Word 2DW 5Stack Segment: Set a block of memory.STACK Size.Stack 100HCode Segment: Contains the program instructionsName proc;body of the procedureName ENDP.Code MAIN PROC ; main procedure instructionsMAIN END P ;other procedures go here
(11001)2
- (10011)2
(00110)2
(627)10
- (537)10
(090)10
1
0
0
1
1
1
1
0
0
0
0
1
1
0
0
0
0
0
0
0
BINARYDECIMAL
0 - 0 - 0 = 0 00 - 0 - 0 = 0 0
0 - 1 - 0 = 1 10 - 1 - 0 = 1 9
1 - 0 - 0 = 0 10 - 2 - 0 = 1 8
1 - 1 - 0 = 0 0
0 - 0 - 1 = 1 10 - 9 - 1 = 1 0
0 - 1 - 1 = 1 01 - 0 - 1 = 0 0
1 - 0 - 1 = 0 0
1 - 1 - 1 = 1 19 - 9 - 1 = 1 9
(11001)2
- (10011)2
(00110)2
0
1
1
0
0
0
0
1
1
1
(11001)2 (214)10Multiplicand
x (10101)2 x (152)10Multiplier
(11001)2 (428)10
(11001)2 (1070)10 Partial
+(11001)2 +(214)10 products
(1000001101)2 (32528)10Result
BINARYDECIMAL
0 X 0 = 00 X 0= 0
0 X 1= 00 X 1= 0
1 X 0 = 0
1 X 1= 11 X 8 = 8
1 X 9= 9
9 X 8 = 72
9 X 9 = 81
Decimal digit01234
BCD00000001001000110100
Decimal digit56789
BCD01010110011110001001
Decimal digit01234
BCD00000001001000110100
Decimal digit56789
BCD01010110011110001001