The homeworks
The decoding assignment
This will not be on the upcoming exams.
.file "testit.c" .text .globl un_c .type un_c, @function un_c: .LFB0: .cfi_startproc movl $0, %eax jmp .L2 .L3: movslq %eax, %rdx addl %eax, (%rdi,%rdx,4) addl $1, %eax .L2: cmpl %esi, %eax jl .L3 rep ret .cfi_endproc .LFE0: .size un_c, .-un_c .ident "GCC: (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4" .section .note.GNU-stack,"",@progbits
- It’s a function which ends at the
rep ret
. - A good picture of register usage for calls is
CMU notes p 25.
%rdi
— argument 1%rsi
(aka%esi
) — argument 2%rdx
must be a temporary%eax
is a temporary
addl %eax, (%rdi,%rdx,4)
- The ultimate CISC instruction: See CMU notes p 36
- Adding
%eax
to element%rdx
of an integer array located at%rdi
(unsigned long)(void *)&X[i]
is(unsigned long)(void *)X + (sizeof X[0])*i
. See Subtask Five of the pre-assembly lab.- Before C, it was
X(5)
notX[5]
for array index
The C program — version 2
Start with homework version 1 solution.
Add something like this.
// This section is for Part 2 of the assignment (HW7) char name[51] ; int hour ; int minute ; while(fscanf(fileIn, "%50s %d:%d", name, &hour, &minute) == 3) { fprintf(fileOut, "%-50s %02d:%02d \n", name, hour, minute) ; } fclose(fileIn); fclose(fileOut); return 0 ;
Expected access time
Be sure to complete the expected time homework before the exams. ECON 120 students call it “expected return”.
Some things you just have to know
- C logical expressions — differences with Java
false
is zerotrue
is an non-zero integer
- C bitwise expressions — just like the Java bitwise expressions
- Pointers
- The
*
and&
operators. &V[i]
versusV+i
- The
- Standard C I/O
- C/C++
printf
and C/C++scanf
- relation to Java
format
- C/C++
int main(int argc, char *argv[])
- binary arithmetic
- know the powers of 2 up to 1024
- know what computer geeks mean by 64k, 128M and 16G
- Understand the mechanical aspects of combinational digital logic
- Boolean expressions, truth tables, combinational circuits
Getting ready for the prefinal and final
Review the exams!