Lec21 - ECE 212 Digital Circuits II Wednesday 16 April 2008 HW Set 21 Problem 1 Problem 2 Problem 3 Problem 4 Problem 5 Problem 6 Problem 7 Aaron L

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 212 Digital Circuits II Wednesday, 16 April 2008 HW Set 21: Problem 1 Aaron L. Problem 2 Connor McG. Problem 3 Chris N. Problem 4 Peter P. Problem 5 Laura P. Problem 6 Rob S. Problem 7 Sheena S.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Today's Goals To introduce C functions. To understand parameter passing on the stack. To understand the creation of local variables on the stack. To understand how to call DBug12 functions.
Background image of page 2
C Functions Function definition. Function declarations (prototypes). Function call. A function is assembled into a subroutine. main is a function (called by startup code).
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
A Function int main( ) { new_line( ); new_line( ); } void new_line( void ) { putch('\r'); // Return character, putch('\n'); // next line character. } void putch(char b); void new_line(void); Function definition. Function prototypes. A function can call other functions. No parameters. No return value.
Background image of page 4
A Function is a Subroutine putch('\r'); putch('\n'); int main( ) { } void new_line(void) { } void putch(char b); void new_line(void); new_line(); new_line(); Compiled assembly language:
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Return Value int main( ) { } char getch_echo(void); { } void putch(char a); char getch(void); char getch_echo(void); char z; z = getch(); putch(z); return(z); char z; z = getch_echo(); getch_echo(); Assign to z the character returned. Don't use the character returned. (Wait until a key is hit, echo the key.) Function getch_echo() is type char . getch_echo() returns a character. What to return.
Background image of page 6
Return Value int main( ) { } char getch_echo(void); { } void putch(char a); char getch(void); char getch_echo(void); char z; z = getch(); putch(z); return(z); char z; z = getch_echo(); getch_echo(); The returned character is in B (with A = 00)
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Local Variable char z; int main( ) { } char getch_echo(void); { } void putch(char a); char getch(void); char getch_echo(void); z = getch(); putch(z);
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/17/2008 for the course ECE 212 taught by Professor Greco during the Spring '08 term at Lafayette.

Page1 / 24

Lec21 - ECE 212 Digital Circuits II Wednesday 16 April 2008 HW Set 21 Problem 1 Problem 2 Problem 3 Problem 4 Problem 5 Problem 6 Problem 7 Aaron L

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online