Chapter 3 - Assembly Flashcards Preview

Advanced Topics in Programming Languages > Chapter 3 - Assembly > Flashcards

Flashcards in Chapter 3 - Assembly Deck (41):
1

Special Purpose Registers

IP
SP
Flags
CS
DS
ES
FS
GS

2

IP

instruction pointer; points to next sequential instruction

3

SP

stack pointer; addresses stack area

4

flags

collection of control properties
12 bits

5

C flag

carry flag; holds the carry after addition or borrow after subtraction

6

Z flag

zero flag; reports the result of an arithmetic operation as zero

7

S flag

sign flag; holds the sign of the result after an arithmetic or logic instruction

8

O flag

overflow flag; indicates overflow as a result from signed arithmetic operations

9

CS

code segment; holds the programs used by the system

10

DS

data segment; contains most of the data used by program

data accessed by offset address

11

ES

extra segment; an additional data segment

12

SS

stack segment; defines the are of memory used for the stack.

Stack pointer register determines entry point in stack segment

13

FS & GS

additional segment registers

14

Real mode

allows the microprocessor to only address the 1st MB of memory. any program can access any area of memory

15

offset address

used to select a location within a 64kb segment to address a given program

16

Assembler start of program

.Model small
.stack 100h
Main PROC

mov ax, @data
mov ds, ax

17

Register Addressing

transfers a copy of a byte or word from one register to another

ex: mov ax, bx

18

Immediate addressing

transfers the source immediate byte (actual value) into a register or memory location

ex: mov ah, 0

19

Direct addressing

moves a byte or word between memory and AL, AX, or EAX registers ONLY

most operands must be the same size

ex: count DW 100H
temp DB 20

mov ax, count (or mov count, ax)
mov al, temp (or vice versa)

20

Displacement addressing

almost identical to direct addressing except instruction is 4 bytes wide instead of 3 bytes wide

21

How to move 8 bits into 16 bit register

2 moves

mov al, temp
mov ah, 00h

22

MOV operations allowed

all moves require the source and destination to be of the same size

memory to register; yes (and vice versa)
x bit register to x bit register; yes
x bit register to y bit register; no if x != y
literal to memory; yes
memory to memory; no

23

_GetCh

grabs char from input. result in BL register

24

_GetDate

grabs date.

DL = day
DH = month
CX = year
AL = day of week

25

Binary subtraction for A - B

= A + twos_complement(B)

26

Twos Complement

flip the bits and add 1

27

Size of number as a result of multiplication

8 bit * 8 bit = 16 bit
16 bit * 16 bit = 32 bit

28

Multiplication operations

MUL; unsigned number multiplication
IMUL; signed number multiplication

29

Multiplication operation structure

register/memory location * al/ax

ex: C = A * B

A DW 10
B DW 5
C DW ?

mov ax, B
mul A (or IMUL A)

if C <= 16 bits answer in AX
else
AX = lower 16 bits
DX = remaining upper bits

30

CBW

convert byte to word
sign extend a bye into a word

31

CWD

convert word to double
sign extend word to double word

32

Size of number as a result of division

16 bits / 8 bits = 8 bits
32 bits / 16 bits = 16 bits

33

Division Operations

DIV; unsigned number division
IDIV; signed number division

34

Division Operation Structure

register or eax or ax / reg or mem location

ex: Q = B/C

Q DW ?
R DW ?
B DW 12
C DW 4

mov Ax, B
CWD (make AX into EAX)
DIV C (or IDIV)

AX = quotient
DX = remainder

35

Jump types

JE --> jump equals
JNE --> jump not equals
JL --> jump less than
JG --> jump greater than
JGE --> jump greater than or equal
JNGE --> jump not greater than or equal
JLE --> jump less than or equal
JNLE --> jump not less than or equal
JMP --> unconditional jump

36

What happens when jump instruction is called?

if the criteria is true, then the program jumps to the specified label

37

What does CALL do?

pushes IP on to stack
replaces current address of IP with address of subprogram

38

What does RET do?

pops the return address from the stack into IP plus the number of bytes specified

39

What happens to begin each subprogram?

save the current bp, set sp equal to bp

40

How to add subprogram parameters?

Parameters pushed on stack from left to right. First parameter located at word ptr [bp + 4], the second at word ptr [bp + 6] etc. (the IP at [bp+2]

41

Where are local variables in the stack frame?

at word ptr [bp-2], word ptr [bp -4] etc.