Docsity

Assembly Language Final Exam, Exams of Nursing

Toggle sidebar
bg1
Assembly Language Final Exam
- answers✔✔What is the largest positive value that may be stored in 20 bits?
Precise control timing
Optimize memory - answers✔✔Why learn assembly language?
0A5h - answers✔✔myBytes BYTE 80h,66h,0A5h
mov al,myBytes
add al,[myBytes+2]
Evaluation of al?
6600 - answers✔✔array WORD 8000h,6600h,4400h
mov ax,array
add ax,[array+2]
Evaluation of ax?
0 to 255
0 to (2^8 - 1) - answers✔✔Unsigned Byte Range
0 to (2^16 - 1) - answers✔✔Unsigned word range
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Assembly Language Final Exam and more Exams Nursing in PDF only on Docsity!

Assembly Language Final Exam

  • answers✔✔What is the largest positive value that may be stored in 20 bits? Precise control timing Optimize memory - answers✔✔Why learn assembly language? 0A5h - answers✔✔myBytes BYTE 80h,66h,0A5h mov al,myBytes add al,[myBytes+2] Evaluation of al? 6600 - answers✔✔array WORD 8000h,6600h,4400h mov ax,array add ax,[array+2] Evaluation of ax? 0 to 255 0 to (2^8 - 1) - answers✔✔Unsigned Byte Range 0 to (2^16 - 1) - answers✔✔Unsigned word range

0 to (2^32 - 1) - answers✔✔Unsigned doubleword range

  • 128 to + 127
  • 2^7 to (2^7 - 1) - answers✔✔Signed byte range
  • 2^15 to (2^15 - 1) - answers✔✔Signed word range
  • 2^31 to (2^31 - 1) - answers✔✔Signed doubleword range Repeatedly divide the decimal value by 16. Each remainder is a hexadecimal digit. (Last remainder obtained is the first hexadecimal digit) - answers✔✔Converting from unsigned Decimal to Hexadecimal Repeatedly divide the decimal value by 2. Each remainder is a binary digit. (Last remainder obtained is the first binary digit)" - answers✔✔Convert Unsigned Decimal to Binary Invert bits. Add 1 - answers✔✔Obtaining 2's complement notation MSB ≤ 7 - answers✔✔Hexadecimal number is positive if: MSB ≥ 8 - answers✔✔Hexadecimal number is negative if:
  1. Convert absolute value of the decimal to binary.
  1. Place address of the value to read onto the address bus
  2. Assert the processer's RD pin
  3. Wait one clock cycle for the memory chips to respond
  4. Copy the data from the data bus into the destination operand - answers✔✔Memory read cycle: hold most recently used instructions and data - answers✔✔Cache memory is used to... Directly inside the CPU - answers✔✔Where are registers located? 4 GB - answers✔✔Protected modeSpace assigned to each program? 32-bit address - answers✔✔Protected mode:Address size? Protected mode - answers✔✔Which operating mode supports multiasking? All memory is divided into segments. Programs share segments (no protection) - answers✔✔Real-Addressing mode memory? Programs given separate memory segments. Processor prevents programs from referencing memory outside their assigned segments. - answers✔✔Protected mode memory? NO. Can only run one program at a time.

Can interrupt program to process requests called "interrupts" - answers✔✔Real-Address mode multiple programs? Yes. Each process gets 4 GB of memory. - answers✔✔Protected mode run multiple programs? Permits segments to be divided into 4,096-byte blocks of memory (pages). Allows total memory used by all programs running at the same time to be larger than computers physical memory Adds page needed from disk to memory. If need more, and memory is full, return old page. Paging (disk access) is slower than main memory access - answers✔✔Paging: Code (executable instructions) Data (variables) Stack (procedure parameters, local variables, return addresses) - answers✔✔Assembly programs contain: Command embedded in source code. Recognized and acted upon by the assembler. Do not execute at runtime. - answers✔✔Directive definition .data, .code, .stack, ALIGN, LABEL - answers✔✔Example directives A statement that becomes executable when a program is assembled. Assembled into machine code by assembler - answers✔✔Instruction: definition

Calculate the size of the array: ListSize = ($ - list) / 2 - answers✔✔List WORD 1000h,2000h,3000h,4000h Calculate the size of the array: Both operands must be the same size. Both operands cannot be memory operands. Immediate value cannot be moved to a segment register - answers✔✔MOV Instruction rules Move with zero-extend used with unsigned integers - answers✔✔MOVZX Instruction Move with sign-extend Takes the smaller operand's highest bit & extends it in the destination operand - answers✔✔MOVSX Instruction Copies the low byte of the EFLAGS register into AH Flags that are copied: Sign, Zero, Auxiliary Carry, Parity, and Carry - answers✔✔LAFH Instruction Stores AH into status flags Copies AH into the low byte of the EFLAGS register i.e. can retrieve values of flags that were earlier saved in a variable - answers✔✔SAHF Instruction Exchange data (contents of two operands)

Rules: Both operands must be the same size. Both operands cannot be memory operands. CS, EIP, and IP cannot be destination operands. Does not accept immediate operands - answers✔✔XCHG Instruction Does not affect the carry flag. - answers✔✔Affect of INC on CF? Does not affect the CF - answers✔✔Affect of DEC on CF? When the sum exceeds the storage size of its destination operand. (CF is a copy of the carry out of the MSB of the destination.) - answers✔✔Unsigned Addition: When does CF = 1? (Larger unsigned int is subtracted from a smaller one.) - answers✔✔Unsigned Subtraction When does CF = 1? Source operand is negated and added to the destination. Carry out of MSB is inverted and copied to the CF. - answers✔✔Unsigned subtraction: Method: Result of a signed arithmetic operation is negative (Is copy of the destination's highest bit) - answers✔✔When does SF = 1? When the result of a signed arithmetic operation overflows or underflows the destination operand.

LENGTHOF array1 = LENGTHOF array2 = 5 * 3 = 15 - answers✔✔array2 WORD 5 DUP( DUP(?))LENGTHOF array2 = LENGTHOF array = 4 - answers✔✔array DWORD 1,2,3,4LENGTHOF array = LENGTHOF array5 = 9 - answers✔✔array5 BYTE ""12345678"", LENGTHOF array5 = Returns a value equivalent to multiplying LENGTHOF by TYPE - answers✔✔SIZEOF Operator returns? Aligns a variable on a byte, word, doubleword, or paragraph boundary ALIGN bound (bound can be 1, 2, 4, or 16) The next address is a multiple of bound - answers✔✔ALIGN Directive does...? Overrides the default type of a label Used to access part of a variable - answers✔✔PTR Operator Variable containing the address of another variable - answers✔✔Pointer ptrB DWORD arrayB or ptrB DWORD OFFSET arrayB - answers✔✔Pointer syntax Causes an unconditional transfer of control to a destination.

Offset/address of destination is moved into the instruction pointer. Execution continues at the new location. - answers✔✔JMP Instruction Effect on Instruction pointer? mov al, var or mov al, [var1] - answers✔✔Direct operand mov al, [arrayB+1] mov al, arrayB+1 - answers✔✔Direct-Offset Operand syntax Used to access memory locations without explicit labels Useful for accessing array elements - answers✔✔Direct-Offset operands use...? No, assembler will retrieve memory outside the array - answers✔✔Direct- Offset Operands Assembler perform range checking? Any 32-bit general purpose register surrounded by brackets mov [esi], bl mov bl, [esi] - answers✔✔Indirect Operands syntax? In protected mode, if the effective address points to an area outside your program's data segment, the CPU executes a general protection (GP) fault. - answers✔✔General protection fault

set when a 1 bit carries out of position 3 in the least significant byte of the destination operand. - answers✔✔Auxiliary Carry Flag