Fichas
CSI2334 computer systems fall 2023

Fichas del conjunto (70)
- 1how many different characters can be represented with ASCII128 (is the answer she's looking for even though the "correct" answer is 256)
- 2DeMorgan's laws in ordernot(xy) = not(x) + not(y)
not(x+y) = not(xy) - 3describe pipelining-ability to execute instructions while prev instructions are still executing
-stall can occur if shared hardware component is currently in use
-the use of pipelining increases effective processor speed - 4esi and edi are...?-index registers
- 5little endianleast significant byte in the lowest memory address
- 6big endianmost significant byte in the lowest memory address
- 7eax,ebx,ecx,edx-data/general registers
-32 bit/doubleword - 8espstack pointer
- 9EBPBASE POINTER
- 10cs, ds, es, fs, gs, ss16-bit segment registers
- 11eipinstruction pointer, address of next instruction to be fetched
- 12EFLAGS32-bit flags register

- 13three types of assembly instructionsdirectives
macros
instructions - 14directivestells the assembler to take some action. Such an
action generally does not result in machine instructions and
may or may not cause object code to be generated
ex: .DATA, .STACK - 15macros“shorthand” for a sequence of other statements—
instructions, directives, or even other macros. The assembler
expands a macro to the statements it represents, and then
assembles the resulting statements
ex: input, output, atod, dtoa - 16instructionis translated by the assembler into 1 or more
bytes of object code (machine code) that is executed at run
time
ex: mov, add, mul - 17what happens in the _declspec c++ calling convention-parameters are widened to 32 bits and passed in reverse order
-eip's contents are pushed onto stack (return address)
-after function termination, c++ cleans up stack and restores esp to location before fxn prologue - 18how do you determine the sign of the remainder when doing idiv operations?sign of remainder is always the same as the dividend (edx:eax)
- 19what sizes need prefix bytesquadword, word
- 20how is 80x86 memory arrangedcollection of slots, each holds 1 byte of instruction/data
- 21what is the last address of 32-bit, 512 MB RAM processor--->(number of MB * size of MB) - 1
--->(512 * 2^20 ) - 1 = 2^29 - 1
= 1FFF FFFFh - 22list amount of memory a kilobyte, megabyte, gigabyte, and terabyte all holdkilo: 2^10 = thousand
mega: 2^20 = million
giga: 2^30 = billion
tera: 2^40 = 1000 GB - 23which way(s) can data travel using the address bus and data busdata bus: from cpu to main memory and from main memory to cpu
address bus: ONLY from cpu to main memory (not back) - 24using this line of code: 00000005 03 05 00000004 R add eax, num2 label the opcode, object code, and addressaddress: 00000005
opcode: 03
object code: 03 05 00000008 - 25what is "enter key" stored as in memory0D 0A (CR LF)
- 26turn this standard hex number into little endian format: FFFF 05F1hF105FFFF
- 27label the addressing modes of the following: [ebx] ebx 05h intVar[ebx]: memory mode-register indirect
ebx: register mode
05h: immediate mode
intVar: memory mode- direct - 28what are the restrictions on label/variable names-cant use a reserved word (like loop, add, for, etc)
-cant start with a number - 29how long is the ascii string that the "wtoa" and "dtoa" macros convert6 bytes and 11 bytes
- 30why does "add [eax], 5" produce a syntax error but "add [eax], ebx" does not?in "add [eax], 5," the size of the value [eax] is point to is unclear because "5" can be any size (byte,word,etc)
but in "add [eax],ebx," the size of [eax] is implied to be DWORD bc thats what ebx's size is - 31what does "atod string" doscans memory starting at the location of "string" and looks for the ASCII representation of a number. once found, it converts
the ASCII representation to the corresponding 2’s complement
doubleword integer. This doubleword is always stored in EAX
—no destination operand is allowed. - 32what does "input prompt, dest, 30" dogenerates a dialogue box with label specified by "prompt", where prompt references a string in the data segment. when OK is pressed, up to "30" characters are copied from the dialogue box to memory at "dest"
- 33what does "wtoa result, bx" doconverts the word at "bx" to a 6-byte long ascii string in "result"
- 34in a .lst file, when you look at the encoding of certain instructions, the encoding may have an 'R' after it. what does the R meanrelocatable
- 35why do we include null bytes in our data segmentso that the computer knows when to stop scanning memory (like when using the wtoa macro)
- 36why does instruction mov ebx, 42 not need a modR/M bytemodR/M is not needed for immediate to register because the immediate value is just assembled directly into the object code instead, and this + the opcode gives the assembler enough information
- 37in general, what does "2+" mean for register indirect mode2+0
- 38keeping in mind that the chart says this type of instruction requires "6+" bytes of object code, which instruction requires more: mov memVar, 10 mov DWORD PTR[edx], 10mov memVar, 10 requires 6+4
mov DWORD PTR[edx], 10 requires only 6
Because:
1ST INSTRUCTIONS OBJECT CODE: opcode + ModR/M + address of data in memory + immediate value
2ND INSTRUCTIONS: same, but without the address of data in memory required - 39location of different flag bits on EFLAG register

- 40which instructions do not affect eflagsmov
push
xchg
pop
lea
inc and dec
cbw, cwd, cdq
not
(maybe also: loop) - 41how does div/idiv affect eflagsit changes them, but not in an understandable/predictable way
- 42how does mul affect flagsCF and OF are 0 if high-order half of the product is zero, and set to 1
if the high-order half is not zero. (i.e, tells you whether the product was the same size as the source) - 43how does imul affect flagsCF and OF are 1 if any bit in the high-order half is different from the sign bit in the low-order half
- 44difference btwn backward and forward reference (relative short jmp)backward: 128 bytes
forward: 127 bytes - 45why do we want to minimize jumps-obstructs flow of code/isnt good design
-negatively affects pipelining--> can't execute next instruction at same time as current instruction bc you have to wait to see whether the condition to jump will be fulfilled or not - 46what does "cmp num2, 20" dosame as sub num2, 20, but without modifying num2-->modifies flags as if we did num2 - 20
- 47which flags do unsigned jumps look atZF and CF only because ZF tells you if the two values were equal, and CF tells you which was bigger (you need a carry in if the second value was bigger)
- 48what does "loop statement label" do• ecx -= 1.
• If the new value in ECX is 0, then execution continues
with the statement following the loop instruction.
• If the new value in ECX is nonzero, then a jump to the
instruction at statementLabel takes place
--can only jump 128 back/127 bytes forward - 49what does "pop ebx" do-goes to address on stack that ESP contains and copies the DWORD value into ebx
-increments esp by 4 - 50what does "push ebx" doESP is decremented by 4. ebx is then stored at address in ESP
- 51relative short/relative near displacementshort: 8 bit displacement
near: 32 bit displacement - 52what does call dosaves the address of the next
instruction (the one immediately following the call), then
transfers control to the procedure code. It does this by pushing
EIP onto the stack and then changing EIP to contain the
address of the first instruction of the procedure. - 53what does ret doreverse of what call does (pops eip, transfers control)
- 54what do these instructions do: and source, dest or source, dest xor source, dest not sourceeach of them "ands/ors/xors/nots" each individual bit of source with each individual bit of dest and stores the result in source. modifies flags too EXCEPT not
- 55what is a maskA value used with a logical instruction (shl, shr, sar, sal) only to alter bit values
- 56how do logical operations (and, or, xor) affect EFLAGSCF and OF: always 0
SF and ZF: based on whatever result is
PF: corresponds to parity of JUST the low-order byte of the
result. - 57what does "test num1, 20" do"ands" num1 and 20 w/out changing value in num1
- 58arithmetic vs logical shiftsarithmetic and logical LEFT shifts: exactly the same
arithmetic RIGHT shift: the new bits are filled with the sign bit
logical RIGHT shift: the new bits are filled with 0s - 59how are status bits affected by shift instructions-For both logical and arithmetic:
---last bit that shifts off is saved in CF.
---SF, ZF, PF are as expected.
----OF is undefined for a
multiple-bit shift; for a single-bit shift it is 0 if the sign bit of the result is the same as the sign bit of the
original operand value - 605 stages of the instruction execution cycle-instruction fetch
-instruction decode (w/data bus)
-data fetch (w/address bus)
-execution
-return result - 61where and why do bottlenecks happen and how do we prevent themhappens when multiple processes need the same hardware/computer
components--specifically, SYSTEM BUS. This means that the computer cannot execute multiple things at
once and the runtime is slowed down. To prevent bottlenecks, diversify variables/instructions
and make sure to avoid points in a program where everything is being run on one
component/register--also, LIMIT TRIPS TO MEMORY - 62why does single precision floating point format provide us with 7 decimal digits of precisionThe single format has 24 significant fraction bits, the implied
leading 1 bit plus the 23 bits that are stored, for 2^23 distinct
patterns. Since 2^23 = 8,388,608, which has seven digits, the single format has about
seven decimal digits of precision - 63differences between single, double, and extended-double precision floating point formats

- 64how is 0 stored as a floating point valuesince 0 cannot be normalized (stored as a mantissa with an implied "1." at the front), it is represented with all 0 bits (+0) or a 1 followed by all 0 bits (-0)
- 65how is +/- infinity and NaN represented as a floating point valueinfinity: sign = 0 for positive infinity, 1 for negative infinity. exponent = all 1 bits. fraction = all 0 bits.
NaN: all 1 bits for the exponent and some non-zero value in the fraction - 66how many floating-point registers are there, how long are they, and how are they organized8 registers, all 80 bits long, and they are organized like a stack
- 67good info to know about labels for jump statements lol--multiple labels can reference the same instruction in memory.
-Labels are not part of object code, so extra labels do not add to
the length of object code or to execution time.
-might want to use multiple labels to make code clearer - 68why are there duplicate mnemonics for the various jump instructions? (i.e. jb and jc generate the same machine code and do the same thing-- so why don't we just use jc?)because sometimes one mnemonic is more natural than the other for
implementation of a given design-- lends itself to clean and straightforward code - 69why is a decrementing count-controlled loop better than incrementing?because a decrementing loop can just use the "loop instruction"--> causes cleaner and more comprehensible code, as well as usually more efficient than using many cmp, jmp, or inc statements
- 70how do you establish a pointer to memory and why would you do this over using memory directly--> "lea dest, source" loads the address of source into dest
-->would do this in the case of using an array, where you need the address of the first element and then can just add to this value to get any other element in the array
Información
- Descripción
- flashcards using the provided discussion questions and questions from past tests/homeworks----after you finish going thru flashcards, if you click "Restart deck," itll give you the option to hide known cards
- Creado por
- Cate Arlinghaus
- Visitas
- 75
- Etiquetas
- Valoración