Assembly Language (Cambridge (CIE) A Level Computer Science): Flashcards

Exam code: 9618

1/54

0Still learning

Know0

  • Define machine code.

Cards in this collection (54)

  • Define machine code.

    Machine code is a first-generation language, written in binary code, whose instructions are directly executable by the processor.

  • Define assembly code.

    Assembly code is a second-generation language written using mnemonics, abbreviated text commands that let programmers write human-readable programs corresponding almost exactly to machine code.

  • How many machine code instructions does one assembly instruction translate to?

    One — one assembly language instruction translates to one machine code instruction.

  • Define instruction set.

    An instruction set is a list of all the commands that can be processed by a CPU, each with a binary code which is the machine code.

  • What is the opcode?

    The part of an instruction that tells the CPU what operation to perform — short for operation code.

  • What is the operand?

    The data or memory address the opcode will work with, giving the extra detail the CPU needs — often a memory address, a value or a label.

  • What does LDM #n do?

    Immediate addressing — it loads the number n into the accumulator.

  • What does LDD <address> do?

    Direct addressing — it loads the contents of the location at the given address into the ACC.

  • What does LDI <address> do?

    Indirect addressing — it uses the value at the given address as a new address, and loads the contents of that into the ACC.

  • What does LDX <address> do?

    Indexed addressing — it uses address plus the index register to get the final address, and loads the contents into the ACC.

  • What is the difference between LDM #n and LDR #n?

    LDM loads the number n into the accumulator, while LDR loads it into the index register (IX).

  • What is the difference between JPE and JPN?

    JPE jumps to the address if the previous compare result was true (equal); JPN jumps if it was false (not equal).

  • In the 9618 instruction set,        denotes a denary number, B denotes binary and & denotes hexadecimal.

    In the 9618 instruction set, # denotes a denary number, B denotes binary and & denotes hexadecimal.

  • What do IN and OUT do?

    IN takes input from the keyboard and stores its ASCII value in the ACC; OUT outputs to the screen the character stored in the ACC.

  • True or False?

    Assembly code can be executed directly by the processor.

    False.

    Assembly needs to be translated into machine code before the computer can execute it; only machine code is directly executable.

  • Define two-pass assembler.

    A two-pass assembler translates assembly language into machine code in two stages, scanning the source code twice.

  • What happens in the first pass of a two-pass assembler?

    It identifies all labels and records their memory addresses, building a symbol table, but does not translate the instructions yet.

  • What happens in the second pass of a two-pass assembler?

    It replaces the labels with the correct memory addresses in the machine code, ensuring the final machine code is accurate and ready to execute.

  • What does a two-pass assembler produce, and what is needed to run it?

    It produces an object program that can be stored, loaded and run later; another utility called a loader is needed to execute it.

  • The first pass of a two-pass assembler builds a                      table of labels and their addresses.

    The first pass of a two-pass assembler builds a symbol table of labels and their addresses.

  • Why is a second pass needed at all?

    Because a label may be used before it is defined, so the assembler must first record every label's address before it can substitute the correct addresses.

  • Define trace table.

    A trace table is a table used to manually track the values of variables as a program runs, following the flow of the program line by line.

  • Name four uses of a trace table.

    To understand how a program works, to debug errors in the logic, to predict outputs before running the program, and to check variable values at each step.

  • In a trace, what does LOAD X do to the accumulator?

    It sets ACC = memory[X].

  • In a trace, what does ADD X do to the accumulator?

    It sets ACC = ACC + memory[X].

  • In a trace, what does STORE X do?

    It sets memory[X] = ACC.

  • Trace LOAD A, ADD B, STORE C, HALT where A = 4 and B = 2. What are ACC and C at the end?

    ACC = 6 and C = 6 — LOAD A puts 4 in the ACC, ADD B makes it 6, and STORE C writes 6 into C.

  • What is a program's object code, in the context of assembly?

    The machine code output by the assembler, which can be stored, loaded and run later.

  • True or False?

    A two-pass assembler translates each instruction into machine code during the first pass.

    False.

    The first pass only assigns memory addresses to labels; translation into machine code happens in the second pass.

  • Name the five categories of assembly language instruction.

    Data movement, input and output of data, arithmetic operations, unconditional and conditional instructions, and compare instructions.

  • What is the difference between LOAD A and STORE B?

    LOAD A loads the value stored at memory location A into the accumulator; STORE B stores the value from the accumulator into memory location B.

  • What does MOV A, B do?

    It copies the value from register or memory A to register or memory B.

  • What do CLEAR ACC and DATA do?

    CLEAR ACC clears the accumulator, setting it to 0; DATA declares a constant or data value.

  • What do IN and OUT do?

    IN takes input from a user or input device and stores it in the accumulator; OUT outputs the value in the accumulator to a screen or output device.

  • What do ADD A and SUB B do?

    ADD A adds the value at memory location A to the accumulator; SUB B subtracts the value at memory location B from the accumulator.

  • What do INC and DEC do?

    INC increments the accumulator by 1 and DEC decrements the accumulator by 1.

  •          jumps to a label unconditionally, without testing anything first.

    JMP jumps to a label unconditionally, without testing anything first.

  • What is the difference between JZ and JNZ?

    JZ jumps to the label if the accumulator is zero; JNZ jumps if the accumulator is not zero.

  • What does JC do?

    It jumps to the label if the carry flag is set.

  • What does HLT do?

    It stops the program, halting execution.

  • What is the difference between CMP A and TEST A?

    CMP A compares the accumulator with the value at memory location A, while TEST A performs a logical AND between the accumulator and A, setting flags with no output.

  • True or False?

    The TEST instruction produces an output value like ADD does.

    False.

    TEST performs a logical AND and sets flags, with no output — it is used to check a condition, not to produce a result.

  • Define addressing method.

    An addressing method is a way in which an instruction in assembly language or machine code can access data stored in memory.

  • Name the five main addressing methods.

    Immediate, direct, indirect, indexed and relative.

  • What is immediate addressing?

    The operand is a constant value included directly in the instruction.

  • What is direct addressing?

    The exact memory address of the operand is given in the instruction.

  • What is indirect addressing?

    A register contains the memory address of the operand.

  • What is indexed addressing?

    It uses a base register and an index to calculate the memory address.

  • What is relative addressing, and what is it used for?

    The operand is an offset relative to the current instruction address, and it is used in branching.

  • In indexed addressing, if the base register holds 0050h and the index holds 1000h, which address is used?

    1050h, because the base and the index are added together to give the effective address.

  • What is the key difference between direct and indirect addressing?

    In direct addressing the instruction gives the address of the operand itself; in indirect addressing a register holds that address, so there is an extra step to reach the data.

  • In                      addressing the operand is a constant value written into the instruction itself.

    In immediate addressing the operand is a constant value written into the instruction itself.

  • What does an instruction like JMP +5 do?

    It tells the program to jump forward 5 instructions from the current line, using relative addressing.

  • True or False?

    In immediate addressing the value in the instruction is treated as a memory address.

    False.

    In immediate addressing the operand is the constant value itself; it is direct addressing where the value given is a memory address.

Sign up to unlock flashcards

or