3. Programming (1) Flashcards

1
Q

What is a computer program?

A

A program is a sequence of instructions (‘code’) to be executed by a computer. It may be organised in different ways (procedures, objects) and written in different languages. The processor executes instructions one after the other unless there is an explicit ‘branch’, ‘jump’ or ‘goto’ instruction.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How are pushbuttons (with internal pullup resistors and LEDs connected to the mC?

A

Pushbuttons with internal pullup resistors on pin 12, active low. LEDs on pin 13, active high. DRAW DIAGRAM.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is machine code?

A

By the time a program is stored (‘burned’) in the program memory of a mC, it is just binary data (1’s and 0’s). It has a particular meaning to the mC and is called machine called.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is assembly language?

A

This is just words that can be translated directly into machine code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Does a programmer ever use assembly language?

A

Sometimes for critical parts of a program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How is assembly language translated into machine code?

A

using an assembler.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is better than an assembler?

A

A compiler , which does a more thorough job and translates for a higher level language, such as C.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What can the processor do?

A
  1. Arithmetic
  2. Logical
  3. Bit operations
  4. Functions (subroutines)
  5. move data
  6. Control Flow
  7. Misc.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What arithmetic can the processor do?

A

Add, subtract, increment, decrement, divide, multiply; all of these can be floating point or integer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What logical operations can the processor do?

A

and, inclusive-or, exclusive-or, complement, rotate (shift)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What bit operations can the processor do?

A

set or clear individual bits in any memory location

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What can the processor do with functions (subroutines)?

A

call and return

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What can the processor do to move data?

A

move data from any memory location to another

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What can the processor do to control flow?

A

If, then, else construction, loops, call functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the misc things a processor can do?

A

sleep, set and service interrupts, clear WDT - these are usually accomplished by setting/ clearing data in specific registers, and C can be used for this.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is source code (in C)?

A

When we write a C program we create a text file which contains the C statements and is known as the source code. This is a human readable file, which the mC cannot interpret.

17
Q

How is the source code made readable to the mC?

A

The compiler turns it into binary code (machine code). This is generally stored in another file and then transferred to the mC.

18
Q

What are variables?

A

In programming, a variable is a value that can change, depending on conditions or on information passed to the program

19
Q

How many bytes to store a day of the week?

A

This only needs to go fro 1-7 and so a byte is sufficient.

20
Q

How many bytes to store a reading from an ADC?

A

these have 12 bit precision and are always positive. One byte is not enough, so two bytes are required.

21
Q

How many bytes for a floating point number?

A

4 bytes.

22
Q

What does the variable TYPE tell the compiler?

A

How much memory it takes up and how that memory should be interpreted (e.g unsigned integer or a float)

23
Q

what is int?

A

int - a 4 byte integer from -2147483648 to 2147483647

24
Q

what is unsigned int?

A

this goes from 0 to 4294967295

25
Q

what is char?

A

a single character e.g ‘a’ or ‘T’

26
Q

what is float?

A

a real number with 6-7 decimal digits of precision. The max value is 3.4E+38 and the smallest positive number is 1.2E-38

27
Q

What are constants?

A

values which do not change, like variables because has a type and refers to a particular memory location. The compiler checks that you dont accidently change its value once it has been set