Midterm1 Flashcards
What is a signed number
A negative number
When do u use imul, idiv
In negative numbers
Div edx,eax stores quotient and remainder where?
Quotient in eax
Remainder in edx
How to detect overflow in unsigned equations
Carry flag is set (Jc,jnc)
How to detect overflow in signed equations
Overflow flag is set (jo,Jno)
How to tell if CF is set?
1: hex addition, if last addition in equation has a carry
How to tell if OF is set?
Think of the two numbers as signed:
If they are a different sign then OF=0 no matter what
If they are the same sign, OF=1 only if the result of adding the two together makes no sense (sign+sign=unsign)
Ex. AF+84 = 33
Adding Two negative should not make it a positive
When moving a greater quantity to a smaller quantity the bits on what side are dropped?
Left
When increasing with movsx what happens?
Adds replicas of signed bit to the left
When increasing with movzx what happens?
Adds zeros to the left
What are jump instructions for unsigned numbers?
JE,JNE,JB,JNAE,JBE,JNA,JA,JNBE,JAE,JNB
B=below
A=above
Jump instructions for signed numbers
JE,JNE,JL,JNGE,JLE,JNG,JG,JNLE,JGE,JNL
G=greater
L=less
What is the memory layout in little endian?
If any memory that is not db, hex representation is stored backwards
Ex.
dd AABBCCAA
In register: AACCBBAA
Mov eax,L2
Will make the “pointer” point to the first byte of L2
Add eax,2
Will make the “pointer” move 2 bytes within the register
Mov word[eax], 23
Will save the hex value of 23 where ever the pointer is pointing too as 4bytes (because of word)
Adc al,0
Will make al+=0+carry
Basically will save 1 or 0 to determine with carry but was flipped on or off
What can xor be used for?
To flip a bit
Ex.
XOR eax,ebx
Will flip the bit in eax when ebx where ebx is pointing to
Octal/binary/hex -> decimal
base^n+……+#base^0=base decimal number
This goes for any bases
Binary (2), octal (8), hex(16)
Binary -> decimal
Only is there is a one, you add the the decimal representation together:
Ex: 1010
8+2=10
256 128 64 32 16 8 4 2 1
Binary arithmetic
1+1= 0 and a carry
0+0=0
1+0=1
Hex addition?
If overflows, start back from 10, result will be whatever u counted when I start back from 10 and a carry
A
10
B
11
C
12