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
Q

addq

A

Dest = Dest + Src

26
Q

subq

A

Dest = Dest - Src

27
Q

imulq

A

Dest = Dest * Src

28
Q

salq or shlq

A

Dest = Dest &laquo_space;Src

29
Q

sarq

A

Dest = Dest&raquo_space; Src ARITHMETIC

30
Q

shrq

A

Dest = Dest&raquo_space; Src LOGICAL

31
Q

xorq

A

Dest = Dest ^ Src

32
Q

andq

A

Dest = Dest & Src

33
Q

orq

A

Dest = Dest | Src

34
Q

incq

A

Dest = Dest + 1

35
Q

decq

A

Dest = Dest -1

36
Q

negq

A

Dest = -Dest

37
Q

notq

A

Dest = ~Dest

38
Q

Difference between neg and not

A

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
Q

What is a stack

A

Data structure where values can be added or deleted according to “last-in, first out” rule

40
Q

Register to hold location of runtime stack

A

%rsp

41
Q

Register to hold location of current code
control (instruction) point

A

%rip

42
Q

CF

A

Carry Flag (for unsigned)
Set if carry out from most significant bit(unsigned overflow)

43
Q

ZF

A

Zero flag
Set if t == 0

44
Q

SF

A

Sign flag (for signed)
Set if t < 0 (as signed)

45
Q

OF

A

Overflow flag(for signed)
Set if two’s complement overflow

46
Q

cmpq b,a

A

Is like computing a - b without setting destination

47
Q

ZF in compare

A

Set if a == b

48
Q

SF in compare

A

Set if (a-b) < 0 (as signed)

49
Q

testq b,a

A

Is like computing a&b without setting destination

50
Q

ZF in test

A

Set when a&b == 0

51
Q

SF in test

A

Set when a&b <0

52
Q

Translate to C
movl (%rdi, %rsi, 4), %eax

A

%rdi + 4*%rsi