Summary Review Flashcards
How would you send the error output from your program, a.out, to a file called error.txt?
./a.out 2> error.txt
Suppose you want to output an address in hex, what is the correct placeholder to use in your print statement?
%x
Which command allows you to write information to a specified output stream?
fprintf
Suppose you declare two variables:
int x;
int y;
Now you wish to read in two integers, separated by spaces, from stdin. What command would you use?
scanf(“%d%d”,&x,&y);
According to the text, a computer’s vocabulary is defined by its
instruction set
instruction set
if R3 = 0xffff_baad_c00f_0000, what value will be in R4 after this operation:
ASR R4, R3, #4
0xffff_fbaa_dc00_f000
0xffff_fbaa_dc00_f000
Mark all that are true of a RISC architecture
includes architectures, such as the x86 architecture.
tries to make common cases fast.
will use multiple instructions to carry out complex, less frequent operations.
.
In the ARM architecture, the MOV instruction sets a register to value. This value may come from (check all that apply):
a register
an immediate field
.
The ARM instruction SUB R3, R1, R2
performs R1 - R2 and puts the result in R3
.
The ARM instruction CMP
sets bits in the CPSR
sets bits in the CPSR
Given CMP R4, R2 which condition code bits would need to be set to indicate that R4== R2
Z
Given the following C code and its corresponding Assembler, select the appropriate instruction to put in the blank spot:
i = 10; j = 1; while (i > 0){ j = j + i; i--; }
mov R2, #10 ; i/R2 = 10 mov R3, #1 ; j/R3 = 1 lp: cmp R2, #0 ; while (i > 0){ \_\_\_\_\_ ; . add R3, R3, R2 ; j/R3 = j/R3 + i/R2; sub R2, R2, #1 ; i/R2 = i/R2 - 1; b lp ; } done:
Consider the following code fragments where target has the address 0x1018 and from has the address 0x1000. What is the immediate offset that will be encoded into the branch instruction at 0x1000?
0x1000 from: b target 0x1004 sub r10, r10, r2 0x1008 lsl r10, r10, #4 0x100c and r10, r2 0x1010 lsr r10, r10, #4 0x1014 or r0, r0, r0 0x1018 target: add r0, r0, #1 0x101c str r0, [r5, #0x100]
0x00_0004
Right. The immediate is the number of instructions between the target 0x1018 and the PC of the branch +8. 0x1008.
There are 4 instruction in between.
If the OP field (bits 27:26) of an instruction is 00, then the instruction type is:
a data processing instruction
a data processing instruction
A load or store instruction can specify a base address (from a register) and
a 12-bit unsigned immediate
What does push {r0} do to the stack pointer?
Decrements sp before storing r0 onto the stack.
Decrements sp before storing r0 onto the stack.
What does pop {r0} do to the stack pointer?Increments sp after loading from the stack into r0.
Increments sp after loading from the stack into r0.