Chapter 3 Machine Level Representation of Programs Flashcards

1
Q

Assembly code suffix b represents…

A

C declaration: Char
Intel data type : Byte
Size: 1 byte

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Assembly code suffix w represents…

A

C declaration: short
Intel data type : Word
Size: 2 bytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Assembly code suffix l represents

A

C declaration: int or double
Intel data type : Double word(int), Double precision (double)
Size: 4 bytes (int), 8 bytes(double)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Assembly code suffix q represents:

A

C declaration: long or char*
Intel data type : Quad word
Size: 8 bytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Assembly code suffix s

A

C declaration: float
Intel data type : Single precision
Size: 4 bytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

in x86-64, what is the size of pointers

A

8 bytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Return register for 64 bit machine

A

%rax (r for 64)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Return register for 32 bit machine

A

%eax (e for 32)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Return register for 16 bit machine

A

%ax

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Data movement instruction

A

mov

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

$

A

immediate value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

movzb

A

Move zero extending byte. These instructions have a register or memory location as the source and a register as the destination

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

movsbw

A

move sign-extended byte to word (bw can change to bl, wl… meaning from one type to another)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

PC

A

Program Counter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Importance of PC

A

Holds address of next instruction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What do Condition codes do

A

Store status information about most recent arithmetic or logical operation
Used for conditional branching

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is Memory

A
  • Byte addressable array
  • Code and user data
  • Stack to support procedures
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Translate to C
movq $0x4,%rax

A

Immediate value to register
temp = 0x4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Translate to C
movq $-147,(%rax)

A

Immediate value to memory
*p = -147

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Translate to C
movq %rax,%rdx

A

register to register
temp2 = temp1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Translate to C
movq %rax,(%rdx)

A

Register to memory
*p = temp

22
Q

Translate to C
movq (%rax),%rdx

A

Memory to register
temp = *p

23
Q

Meaning of the following unary operation
neg

A

Arithmetic negation

24
Q

Meaning of the following unary operation
not

A

Bitwise complement

25
addq
Dest = Dest + Src
26
subq
Dest = Dest - Src
27
imulq
Dest = Dest * Src
28
salq or shlq
Dest = Dest << Src
29
sarq
Dest = Dest >> Src ARITHMETIC
30
shrq
Dest = Dest >> Src LOGICAL
31
xorq
Dest = Dest ^ Src
32
andq
Dest = Dest & Src
33
orq
Dest = Dest | Src
34
incq
Dest = Dest + 1
35
decq
Dest = Dest -1
36
negq
Dest = -Dest
37
notq
Dest = ~Dest
38
Difference between neg and not
NEG changes -1 to 1 because it reverses all the bits and adds 1 NOT changes -1 to 0 because it reverses all the bits only
39
What is a stack
Data structure where values can be added or deleted according to "last-in, first out" rule
40
Register to hold location of runtime stack
%rsp
41
Register to hold location of current code control (instruction) point
%rip
42
CF
Carry Flag (for unsigned) Set if carry out from most significant bit(unsigned overflow)
43
ZF
Zero flag Set if t == 0
44
SF
Sign flag (for signed) Set if t < 0 (as signed)
45
OF
Overflow flag(for signed) Set if two's complement overflow
46
cmpq b,a
Is like computing a - b without setting destination
47
ZF in compare
Set if a == b
48
SF in compare
Set if (a-b) < 0 (as signed)
49
testq b,a
Is like computing a&b without setting destination
50
ZF in test
Set when a&b == 0
51
SF in test
Set when a&b <0
52
Translate to C movl (%rdi, %rsi, 4), %eax
%rdi + 4*%rsi