aLec16_localVariables - Introduction to Embedded...

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

View Full Document Right Arrow Icon
Lecture 16.1 Jonathan W. Valvano Student: “Programming in assembly is a lot like digging a post hole with a teaspoon. Of course, you do have complete control over every piece of dirt” Valvano: “Programming in a high level language is a lot like painting a masterpiece with a paint roller. Of course, you do get the job done quickly.” Recap Finite State Machines Pointer implementation Overview Fixed-point: why, when, how Local variables: scope and allocation How these concepts apply to C Binding, allocation, access, deallocation 10.1. Fixed-point numbers Fixed point numbers Why? (wish to represent non-integer values) Next lab measures distance from 0 to 3 cm E.g., 1.234 cm When? (range is known, range is small) Range is 0 to 3cm Resolution is 0.003 cm How? (value = Integer* Δ ) 16-bit unsigned integer Δ = 10 -3 decimal fixed-point Range becomes 0.000 to 65.535 Output an integer. Assume integer, n, is between 0 and 9999. not very pretty OutChar($30+n/1000) ;thousand’s digit n = n%1000 OutChar($30+n/100) ;hundred’s digit n = n%100 OutChar($30+n/10) ;ten’s digit OutChar ($30+n%10) ;one’s digit Output a fixed-point number. Assume the integer part of the fixed point number, n, is between 0 and 9999. very pretty OutChar($30+n/1000) ;thousand’s digit n = n%1000 OutChar($2E) ;decimal point OutChar($30+n/100) ;hundred’s digit n = n%100 OutChar($30+n/10) ;ten’s digit OutChar ($30+n%10) ;one’s digit 7.3. Local Variables Introduction
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

aLec16_localVariables - Introduction to Embedded...

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

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