Flashcards
6: Assembly Language Programming
Cards in this deck (33)
- 1OpcodeDefines the action associated with the instruction.
- 2OperandDefines any data needed by the instruction.
- 3Machine Code InstructionA binary code with a defined number of bits that comprises an opcode and, most often, one operand.
- 4give 6 facts about machine code- only language CPU recogniseds is machine code
- machine code consiss of a sequence of instructions
- an instruction contains an opcode
- an instruction may not have an operand but up to 3 are possible
- different processors have different instruction sets assocaiated with them
- different processors will have comparable instructions for same operations, but codding of instructions will be different - 5For a particular procssor, following must be defined for individual machine code instruction: 4 points- total number of bits or bytes for whole instruction
- number of bits that define opcode
- number of operands that are defined in remaining bits
- whether opcode occupies most significiarnt or least signficiant bits - 6take a 16-bit address bus width, system will have accumulator. Number of bits needed for opcode depends on number of different opcodes in instruction set for processor. give example of structureopcode Operand
Operation 4 bits, 16bits
Address mode 2 bits,
register addressing 2 bits
opocde have most sig bits of instruction. Someotimes operand will be memory address so sensible to allocate 16 bits - 7give register transfer notation of transfering bits 16 to 23 from CIR to control unitCU < - [CIR(23:16)]
- 8Assembly LanguageA low-level language related to machine code where opcodes are written as mnemonics and there is a character representation for an operand.
- 9AssemblerA program used to translate an assembly language program into machine code.
- 10DirectiveAn instruction to the assembler program.
- 11What are some dis of machine instructiosn? 2- take long time
- lots of errors
- each processor has an assembly language - 12What are some adv of assembly language and what special features allow 5easier to write
special features:
comments
symbolic names for constants
lables for addresses
macros
directives - 13What are Macros?Sequence of instructions used more than once in a program.
- 14What are Directives?Instruction to assembler as how should construct inal executable machine code - ie how direct memory should be used or defining files or procedures.
- 15Desrcibe dif between symbolic, relative and absolute addressingSymbolic - write code without bothering where code will be stored in memory when run. ie STO MAX
Relative - assumption - special - function base register BR contains base address - contents of register indicated by BR id STO[BR] + 15
Absolute - identifiying actual memory addresses. ie STO 215 - 16Before any translations can be done what has to happen to assembly language? 3- removal of comments
- replacement of macro name (replace with list instrucitons that consitute the macros def)
- removal and storage of directives to be acted upon later - 17What is an instruction set?Set of instructions understood by a CPU
Unique to a CPU/articutecure family
Combinations of binary digits - 18What does a 2-pass assembler do?designed to handle symbolic style programs - contains forward references. Some instructionrs have smbolic address for operand where location of address is unknown at that stage. 2-pass assembler lets first pass the location of address for forward references can be identified. Assembler uses a symbol table during first pass. Code read line by line. Assembler has to count iinstructiosn as read code. For second pass, assmebler uses symbol table and lookup table that contains binary code for each opcode.
- 19What are some points to note for a 2-pass assembler? 6- most of the instructison have an operand which is a 16-bit binary number
- usually this represents an address but for SUB and LDM instructions operand is used as a value
- no operand for IN and END instructions
- changes be needed for addresses when program loaded into memory and ready to be executed
- machine code coded with 1st instruction occupying address 0
- code ins't executable in this form but valid output from assembler - 20Addressing ModeWhen the instruction uses a value that defines how the operand must be used to find the value.
(when instruction requres a value to be loaded into a register there are dif ways of identifying value) - 21Addressing mode 2 bits = 4 different modes. What are the 4 modes and use of operand?Immediate: operand is value to be used in operation ie SUB #48 (data in operand)
Direct: operand is address which holds value to be used in instruciton ie ADD TOTAL (operand contains address in memory)
Indirect: operand is address that holds address whcih has the value to be used in instruction (memory location larger than operand)
Indexed: operand is address which must be added the value currently in IX to get addres which hodls vlaue to be used in insturction. (split into 2 index and address) - 22What are 3 instruction ytpes?arithmetic operations
data transfer
flow control - 23What are the most common categories of assembly language instructions? 5Data Movement
Input and Output
Comparisons and Jumps
Arithmetic Operations: (no * or \)
Shift Operations - 24Describe Data movementie loading data into a register, storing data in memory. Mneumonics define instruction type including register involved and addressing mode
- 25Describe Input and Output2 instructions, only has opcode. Instruction wilth opcode IN: store in ACC the ASCII cavlue of charcter typed in keyboard. Instruciton with opcode OUT used to display on screen character ASCII code is stored in ACC
- 26Describe Comparisons and Jumpsmay need unconditional or may need jump if ocndition met, in 2nd case compare instruction executed first. Comparisons restricted to if 2 values , resutl recorded by a flag in status register. Execution of conditional jump instruction begins by checking wheter or not flag bit been sent - doesn't cause immediate jump as new value has to be supplied to PC so next instruction fetched form this newly specified addres. Incrementing of PC that too place automatically when instruciton fetced in overwritten
- 27Describe shift oepratiosn: 2 shift instructions available what are they?LSL # n (bits in ACC shifted n places to left)
LSR # n (bits shiften to right) - 28Logical ShiftWhere bits in the accumulator are shifted to the right or to the left and a zero moves into the bit position vacated.
- 29Cyclic ShiftSimilar to a logical shift but bits shifted form 1 end reappear at toher end.
(bit moves off 1 end into carry bit then at other end. All bit values in original code retained) - 30Arithmetic ShiftUses the shift to carry out multiplication or division of a signed integer stored in the accumulator.
- 31Describe logical shiftno consideration given as what binary code in acc represtents, as shift operation moves a bit from acc into carry bit in status register - can be used to examin individual bits. For left logical shift, most sig bit moved to carry bit, remaining bits shifted left and a 0 is entered for least sig bit. For right, least sig bit that is moved to carry bit and 0 entered for most sig bit. If acc content represents, unsigned ingeter, left shift operation is fast way to multiply by 2 but only gives correct result if most sig bit is 0. Right shift represents integer / 2. Remainder for / can be found in carry bit. Not awlays accurate, eventulaly get 0 for eveyr bit. ogircal sihft can be used for * or / by 2 when signed ingeter store as may result in sign change
- 32Describe bitwise logic operationoperand referred to as a mask as it can effectively cover some of the bits and only affect specific bits.
- 33What are the flags used in interrupts?Carry flag C - set to 1 if carry
Negative flag N - set to 1 if result negative
Overflow flag V - set to 1 if overflow detected
Information
- Description
- A Level AS Computer Science (Unit 1: Theory Fundamentals) Flashcards on 6: Assembly Language Programming, created by HRYN red on 22/11/2016.
- Created by
- HRYN red
- Views
- 3
- Rating