Complete EXAM #2 Study Guide

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

ADD

The ADD instruction is used to add two operands and store the result in a destination operand. The syntax of the ADD instruction is: ADD destination, source

TYPE

The TYPE operator is used to obtain the data type of a variable or memory location. The syntax of the TYPE operator is: TYPE variable_name

Opcode

The opcode is the instruction code that tells the processor what operation to perform. In the case of the MOV instruction, the opcode is usually MOV.

Overflow flag

The overflow flag is set when the result of a signed arithmetic operation exceeds the range that can be represented in the given number of bits. For example, in a 32-bit processor, after an ADD instruction that results in a value greater than 2^31-1 or less than -2^31, the overflow flag will be set.

Parity flag

The parity flag is set when the result of an arithmetic or logical operation has an even number of set (1) bits. For example, after an AND instruction that results in an even number of set bits, the parity flag will be set.

Sign flag

The sign flag is set when the result of an arithmetic or logical operation is negative. For example, after a SUB instruction that results in a negative value, the sign flag will be set.

Source Operand

The source operand is the data that is being moved. It can be a register, memory location, immediate value, or a combination of these. The source operand is specified after the MOV opcode using a comma-separated syntax.

Zero flag

The zero flag is set when the result of an arithmetic or logical operation is zero. For example, after a SUB instruction that results in a zero, the zero flag will be set

Immediate values

These are constants that are used as operands in an instruction. Immediate values can be expressed in decimal, hexadecimal, or binary notation.

Memory addresses

These are locations in the computer's memory where data can be stored or retrieved. Memory addresses can be expressed as an offset from a segment register, or as an absolute address.

Pointers

These are memory addresses stored in a register or memory location that point to another memory location. Pointers are used for accessing and manipulating data structures, such as arrays and structures.

Registers

These are special-purpose data storage locations within the CPU that can hold integers, floating-point numbers, or memory addresses. MASM provides eight general-purpose registers (EAX, EBX, ECX, EDX, ESI, EDI, EBP, and ESP).

Labels

These are symbolic names that represent a memory address in the program. Labels are used in conjunction with branch and jump instructions

Stack operands

These are values that are pushed onto or popped off of the system stack, which is a region of memory used for temporary storage of data.

AND

This instruction performs a bitwise logical AND operation between two operands and stores the result in the first operand. If both bits are 1, the corresponding bit in the result is also set to 1. Otherwise, the corresponding bit in the result is set to 0. The syntax for the AND instruction is: AND destination, source

NOT

This instruction performs a bitwise logical NOT operation on an operand and stores the result in the same operand. During the operation, each bit in the operand is flipped, with 0 becoming 1 and 1 becoming 0. The syntax for the NOT instruction is: NOT operand

OR

This instruction performs a bitwise logical OR operation between two operands and stores the result in the first operand. If either bit is 1, the corresponding bit in the result is set to 1. Otherwise, the corresponding bit in the result is set to 0. The syntax for the OR instruction is: OR destination, source

XOR

This instruction performs a bitwise logical XOR operation between two operands and stores the result in the first operand. If the bits are different (one is 1 and the other is 0), the corresponding bit in the result is set to 1. Otherwise, the corresponding bit in the result is set to 0. The syntax for the XOR instruction is: XOR destination, source

Clrscr

This procedure clears the console screen

ReadChar

This procedure reads a single character from the console and returns its ASCII code in the AL register.

ReadInt

This procedure reads an integer value from the console and returns it in the EAX register

ReadDec

This procedure reads an integer value from the console and returns it in the EAX register.

ReadString

This procedure takes a pointer to a buffer in the EDI register and the maximum number of characters to read in the ECX register. It reads characters from the console until a newline or carriage return character is entered or the maximum number of characters is reached. The input characters are stored in the buffer, which is null-terminated.

DumpMem

This procedure takes a pointer to a memory buffer in the ECX register and the number of bytes to dump in the EDX register. It displays the hexadecimal and ASCII representation of the memory contents to the console.

WriteString

This procedure takes a pointer to a null-terminated string in the ECX register and writes the string to the console.

Delay

This procedure takes a time delay value in milliseconds in the ECX register and waits for that amount of time before returning

WriteDec

This procedure takes an integer value in the ECX register and writes its decimal representation to the console

WriteHex

This procedure takes an integer value in the ECX register and writes its hexadecimal representation to the console.

Crlf

This procedure writes a carriage return and line feed sequence to the console.

SP (stack pointer)

This register holds the offset address of the top of the stack. As data is pushed onto the stack, the SP register is decremented, and as data is popped from the stack, the SP register is incremented.

SS (stack segment)

This register holds the segment address of the stack segment. This register is typically initialized by the operating system when the program is executed.

BP (base pointer)

This register is used for accessing local variables and parameters on the stack. The BP register is typically initialized to the current value of the SP register, and then used as a reference point for accessing stack-based variables.

ESP (extended stack pointer)

This register is used to manage the operand stack, which is used for storing operands during arithmetic and logical operations. The ESP register is decremented as operands are pushed onto the stack, and incremented as operands are popped from the stack.

How to declare a function.

You need to use the CALL instruction to transfer control to a function. Here's an example of how to call the myfunction function that takes no parameters: CALL myfunction

Zero extension

Zero extension is a technique used to extend the size of a binary value by adding zeros to the left-most bits. For example, to extend an 8-bit value to a 16-bit value, the left-most 8 bits can be set to zero. In MASM, zero extension can be achieved using the MOVZX (Move with Zero-Extend) instruction.

LOOPZ (Loop while Zero)

and LOOPNZ (Loop while Not Zero) are two similar loop instructions that differ in the condition for exiting the loop.

CMP

instruction is typically used to compare two values and set the status flags accordingly. For example, to compare the values in the EAX and EBX registers, you could use the following code: CMP EAX, EBX

TEST

instruction is typically used to test a single bit in a register or memory location. For example, to test the least significant bit of the EAX register, you could use the following code: TEST EAX, 1

LOOPZ

instruction will decrement the CX register by one, and if CX is not zero and the zero flag (ZF) is set, then the control jumps to the specified destination label. Otherwise, the execution continues with the next instruction following the LOOPZ instruction.

How the TEST and CMP instructions work.

....62

Parts of MOV instruction

.

The valid syntax uses to declare a MOV instruction

......12

From Irvine32.inc library, know how the following procedure calls work:

.....45

· How to use AND, OR, XOR, NOT, instructions.

.....57

Stack and what registers are associated with it.

A stack is a data structure used for storing and retrieving data. Here are the registers associated with the stack in MASM:

· Know how to write the following in assembly:

If statements = .data num1 dword 4 num2 dword 4 val dword 0 .code mov eax, num2 cmp num1, eax jne end_of_program mov eax, num1 mov val, eax end_of_program:

How to get an address of a variable

In MASM (Microsoft Macro Assembler), you can get the address of a variable using the OFFSET operator. The OFFSET operator returns the offset address of a variable, which is the distance between the start of the segment and the start of the variable.

Zero Extension and Sign extension.

In MASM (Microsoft Macro Assembler), zero extension and sign extension are techniques used to extend the size of a binary value.

How do JMP and LOOP instructions work?

In MASM, JMP and LOOP are two branching instructions that allow the program to jump to a different location in the code based on certain conditions.

· What are LOOPZ, LOOPNZ

In MASM, LOOPZ and LOOPNZ instructions are used to create loops that execute a specified number of times, based on the value of the CX register.

TYPE, LENGHTOF, SIZEOF operators

In MASM, the TYPE, LENGTHOF, and SIZEOF operators are used to obtain information about variables and data types.

Little Endian Order

Little Endian is a method of arranging binary data in a computer's memory. In Little Endian order, the least significant byte (i.e., the byte with the lowest memory address) of a multi-byte value is stored first, followed by the next-least significant byte, and so on, with the most significant byte (i.e., the byte with the highest memory address) being stored last.

In MASM (Microsoft Macro Assembler), the MOV instruction can be declared with the following syntax:

MOV destination, source

Sign extension

Sign extension is a technique used to extend the size of a binary value while preserving its sign. Sign extension involves copying the left-most bit of the original value into the new bits being added. For example, to extend an 8-bit signed value to a 16-bit signed value, the left-most bit (which represents the sign) is copied into the left-most 8 bits of the new value. In MASM, sign extension can be achieved using the MOVSX (Move with Sign-Extend) instruction.

PUSH and POP operations

The PUSH instruction is used to push a value onto the top of the stack, and the POP instruction is used to pop a value from the top of the stack.

PUSH

The PUSH instruction takes a value or memory location as an operand, and pushes that value onto the top of the stack. The SP register is decremented by the size of the operand (in bytes) to make room for the new value on the stack. For example, the following instruction pushes the value 42 onto the top of the stack: PUSH 42

SIZEOF

The SIZEOF operator is used to obtain the size (i.e., number of bytes) of a variable or data type. The syntax of the SIZEOF operator is: SIZEOF variable_name

SUB

The SUB instruction is used to subtract one operand from another and store the result in a destination operand. The syntax of the SUB instruction is SUB destination, source

DEC

The DEC instruction is used to decrement (i.e., subtract one from) the value of a register or memory location. The syntax of the DEC instruction is DEC destination

INC

The INC instruction is used to increment (i.e., add one to) the value of a register or memory location. The syntax of the INC instruction is INC destination

JMP

The JMP instruction is used to jump to a specific memory location in the code. The syntax of the JMP instruction is: JMP destination

LENGTHOF

The LENGTHOF operator is used to obtain the length (i.e., number of elements) of an array or string. The syntax of the LENGTHOF operator is: LENGTHOF variable_name

LOOP

The LOOP instruction is used to implement loops in assembly language. The syntax of the LOOP instruction is: LOOP label

NEG

The NEG instruction is used to negate (i.e., make negative) a register or memory location. The syntax of the NEG instruction is NEG destination

OFFSET

The OFFSET operator is used to obtain the offset (i.e., memory address) of a variable or label in the code segment. The syntax of the OFFSET operator is: OFFSET variable_name

POP

The POP instruction pops the value on the top of the stack and stores it in a register or memory location. The SP register is incremented by the size of the operand (in bytes) to remove the value from the stack. For example, the following instruction pops the value on the top of the stack and stores it in the EAX register: POP EAX

Carry flag

The carry flag is set when an arithmetic operation generates a carry or a borrow. For example, after an ADD instruction that results in a carry, the carry flag will be set. In some processors, the carry flag can also be set by other operations like shifts and rotates.

Destination Operand

The destination operand is the location where the data is being moved to. It can be a register, memory location, or a combination of these. The destination operand is specified after the source operand using a comma-separated syntax.


Ensembles d'études connexes

Intro to Finance Chapters 9-10 Exam

View Set

State government executive and judiciary branches

View Set

Chapter 36 Global Interdependence

View Set

Evidence Based Research- Final Tes Practice questions

View Set

Slovenian expressions (Andreja Jernejčič)

View Set