description:"Software development and QA (testing) for an international race timing company based in Canmore, AB. Testing using unittest and Selenium. Development done in Javascript and Tornado. Zone4 was founded in 2001 by Canadian Olympian Dan Roycroft.."
description:"Software development and QA (testing) for an international race timing company based in Canmore, AB. Testing using unittest and Selenium. Development done in Javascript and Tornado. Zone4 was founded in 2001 by Canadian Olympian Dan Roycroft."
description:"Written for a local roofing business to securely distribute quotes."
- name:"Yggdrasil Screen Reader"
- name:"Odilia Screen Reader"
link:"https://yggdrasil-sr.github.io/"
description:"Some small pieces of code I've written have made it into a new screen reader for Linux, written in Rust."
description:"Significant contributor to a new screen reader for Linux, written in the Rust programming language."
- name:"Programming Tutorials For The Visually Impaired"
link:"/emacspeak-tutorials/"
description:"Amateur-level production quality videos with all file buffers, written text, and shell commands read out by <a href=\"http://emacspeak.sourceforge.net/\">Emacspeak</a>, an Emacs extention for the blind."
- name:"Simple Markdown Editor"
link:"https://tait.tech/md/"
description:"A simple online (and offline) browser-based markdown editor that supports the automatic creation of accessible math (MathML)."
- name:"Lichess"
link:"https://github.com/ornicar/lila/pull/7772"
description:"A patch for Lichess.org which vastly extends support for screen reader users. The website has millions of active players."
- name:"Quote Retrieval System"
link:"https://github.com/TTWNO/quote_pdf"
description:"Written for a local roofing business to securely distribute quotes."
- name:"epub-with-pinyin"
link:"https://github.com/TTWNO/epub-with-pinyin"
description:"A program to add Pinyin above Chinese characters in .epub files to assist those learning Mandarin Chinese."
- name:"Programming Tutorials For The Visually Impaired"
link:"/emacspeak-tutorials/"
description:"Amateur-level production quality videos with all file buffers, written text, and shell commands read out by <a href=\"http://emacspeak.sourceforge.net/\">Emacspeak</a>, an Emacs extention for the blind."
- name:"lamegames"
link:"https://github.com/TTWNO/lamegames.io"
description:"A little games website I made for some demonstrations of Django and websocket functionality. Very, very lame. Would not recommend."
- name:"chess"
link:"https://github.com/TTWNO/chess"
description:"A command-line chess game in C++. It is compileable on nearly any system."
- name:"Emacspeak C Tutorials"
link:"https://tait.tech/emacspeak-tutorials/"
description:"C Tutorials for the Visually Impaired"
- name:"Simple Markdown Editor"
link:"https://tait.tech/md/"
description:"A simple online (and offline) browser-based markdown editor that supports the automatic creation of MathML."
#- name: "Emacspeak C Tutorials"
# link: "https://tait.tech/emacspeak-tutorials/"
# description: "C Tutorials for the Visually Impaired"
<?xml version="1.0" encoding="utf-8"?><feedxmlns="http://www.w3.org/2005/Atom"><generatoruri="https://jekyllrb.com/"version="4.2.1">Jekyll</generator><linkhref="http://localhost:4000/feed.xml"rel="self"type="application/atom+xml"/><linkhref="http://localhost:4000/"rel="alternate"type="text/html"/><updated>2021-11-28T18:08:20-07:00</updated><id>http://localhost:4000/feed.xml</id><entry><titletype="html">How To Produce Semantically Correct MathML From XaTeX/LaTeX (and other accessibility ideas)</title><linkhref="http://localhost:4000/2021/09/18/how-to-generate-proper-content-mathml-from-katex-or-latex/"rel="alternate"type="text/html"title="How To Produce Semantically Correct MathML From XaTeX/LaTeX (and other accessibility ideas)"/><published>2021-09-18T00:00:00-06:00</published><updated>2021-09-18T00:00:00-06:00</updated><id>http://localhost:4000/2021/09/18/how-to-generate-proper-content-mathml-from-katex-or-latex</id><contenttype="html"xml:base="http://localhost:4000/2021/09/18/how-to-generate-proper-content-mathml-from-katex-or-latex/">During a recent run-in with the Simon Fraser Fraser University accessibility department,
I learned that they're writers are so well-trained as to write "image" where a simple diagram is shown,
and "print out picture of output" where a piece of code lies.
=======
<?xml version="1.0" encoding="utf-8"?><feedxmlns="http://www.w3.org/2005/Atom"><generatoruri="https://jekyllrb.com/"version="4.2.0">Jekyll</generator><linkhref="/feed.xml"rel="self"type="application/atom+xml"/><linkhref="/"rel="alternate"type="text/html"/><updated>2021-11-25T21:47:55-07:00</updated><id>/feed.xml</id><entry><titletype="html">How To Produce Semantically Correct MathML From XaTeX/LaTeX (and other accessibility ideas)</title><linkhref="/2021/09/18/how-to-generate-proper-content-mathml-from-katex-or-latex/"rel="alternate"type="text/html"title="How To Produce Semantically Correct MathML From XaTeX/LaTeX (and other accessibility ideas)"/><published>2021-09-18T00:00:00-06:00</published><updated>2021-09-18T00:00:00-06:00</updated><id>/2021/09/18/how-to-generate-proper-content-mathml-from-katex-or-latex</id><contenttype="html"xml:base="/2021/09/18/how-to-generate-proper-content-mathml-from-katex-or-latex/"><p>During a recent run-in with the Simon Fraser Fraser University accessibility department,
I learned that they’re writers are so well-trained as to write “image” where a simple diagram is shown,
and “print out picture of output” where a piece of code lies.
>>>>>>> ca770be68ffdcb836bbddb3a47786c64f4f717a7
I figure the geniuses over there could use some help creating files for the visually impaired.
@ -99,6 +99,10 @@ This should be quite simple given how easy the lichess API is, and the <a href="
<li>The list of servers will be updated manually with <codeclass="language-plaintext highlighter-rouge">bt update</code>.</li>
</ul>
<p>I love this idea, but unfortunately, Canada has data retention laws that would stop me from protecting the privacy of anyone using a system delivered by me.
Unless I incorporate in Switzerland or the Seychelles, this is not a viable option.
Doing the above costs a fair amount in up-front investment that I am not willing to make at this point in time.</p>
<h2id="5-3d-printing-of-google-mapsopenstreetmaps-data-for-the-visually-impaired">5. 3d printing of Google Maps/OpenStreetMaps data for the visually impaired.</h2>
<p>A larger project, to be sure, but one I think could be of interest.
@ -125,6 +129,57 @@ Then, add 4 more roads and figure out how to intersect them.</p>
<p>This is being worked on through the <ahref="https://github.com/skarkkai/touch-mapper">touch-mapper</a> project.
They do not, however, have labels yet.</p>
<h2id="6-3d-printed-binary-trees">6. 3D Printed Binary Trees</h2>
<p>A simple hub/connection system to connect nodes of a binary tree together to have a physical object for visually impaired computer science students to use for initial introduction into the subject of (binary) trees.</p>
<p>Have a simple module for loading in an SVG of a tree, along with Javascript to make the diagram accessible by jumping left/right with the arrow keys and up to a parent with the up arrow.</p>
<p>Lego or 3d printed logic gates with physical switches for in and out.
Again, sore of as an introductory tool for blind students learning computer science.</p>
<h2id="8-more-tutorialsmaterials">8. More Tutorials/Materials</h2>
<p>Perhaps a broader selection of materials for computer science students with proper transcriptions for everything in this list:</p>
<ul>
<li>UML diagrams</li>
<li>UML sequence diagrams</li>
<li>Gantt charts</li>
<li>Advanced math equations</li>
<li>Stacks, Queues and Linked Lists</li>
<li>Memory layout tables</li>
<li>Logic gate diagrams</li>
<li>Decision charts; I think I could add some macros on top of</li>
<li>Timing diagrams (i.e., watching the state of various inputs and outputs over time [usually in relation to a clock cycle]); my current idea for this is a dynamic audiogram where you can listen to the clock + any other tracks at the same time to “see” the diagram</li>
<li>Circuit diagrams (not 100% relevant, but I have seen it in CS courses)</li>
<li>Database tables as HTML tables</li>
<li>Properly transcribed security content like buffer-overflows, underflows and similar things</li>
</ul>
<p>Although developing these is good, I think it is worthwhile to also create tools that make creation of these easier for both sighted and blind individuals.
This will make it easier for course transcribers who are not tech-savy and will enable the blind student to create the diagrams and send them back to their teachers.
Preferably have a “plain text” version which can be rendered as an SVG for use by visual learners, then make sure the SVG can be accessible with a Javascript hook.
This would (in theory) make it possible for a teacher to create the graphic in the specialized tool for that kind of chart, put it in their slides/course info/textbook/whatever and have the student able to extract the SVG and paste it somewhere where a script could make it readable.
Yes, the best case is the teacher cooperates 100%, but considering that is never the case, I figure making it easier to convert between the two is the best I can hope for.</p>
<p>Some other things I would like to do, if I could find the time:</p>
<ul>
<li>How to get started with Linux.</li>
<li>Text-based tutorials from start-to-finish with various frameworks: SpringBoot (Java), Django/Flask (Python), JavaEE.</li>
<li>Specific programming language instruction in all the basics: C/C++, Bash, Python, Javascript, HTML, Java. Perhaps in the future branch into Rust, Golang, Zig or Haskell.</li>
<li>Custom-made braille manuals for a set of affordable computer parts which can be purchased to assemble a computer from scratch, without sighted assistance (see <ahref="/2021/06/21/uefi-audio/">current status of accessible BIOSes</a>).</li>
</ul>
<p>This would all be licensed as CC-BY-NC-SA.
I may drop the NC. As long as I have specified SA, then anyone (even for-profit companies) can use it as long as any changes are shared to the public as well.</p>
@ -50,55 +50,49 @@ I have all of my code projects hosted on <a href="https://github.com/TTWNO">my G
<li>
<p>
<aclass="namelink"href="https://github.com/TTWNO/quote_pdf">Quote Retrieval System</a>— Written for a local roofing business to securely distribute quotes.
<aclass="namelink"href="https://yggdrasil-sr.github.io/">Odilia Screen Reader</a>— Significant contributor to a new screen reader for Linux, written in the Rust programming language.
</p>
</li>
<li>
<p>
<aclass="namelink"href="https://yggdrasil-sr.github.io/">Yggdrasil Screen Reader</a>— Some small pieces of code I've written have made it into a new screen reader for Linux, written in Rust.
</p>
</li>
<li>
<p>
<aclass="namelink"href="https://github.com/ornicar/lila/pull/7772">Lichess</a>— A patch for Lichess.org which vastly extends support for screen reader users. The website has millions of active players.
<aclass="namelink"href="/emacspeak-tutorials/">Programming Tutorials For The Visually Impaired</a>— Amateur-level production quality videos with all file buffers, written text, and shell commands read out by <ahref="http://emacspeak.sourceforge.net/">Emacspeak</a>, an Emacs extention for the blind.
</p>
</li>
<li>
<p>
<aclass="namelink"href="https://github.com/TTWNO/epub-with-pinyin">epub-with-pinyin</a>— A program to add Pinyin above Chinese characters in .epub files to assist those learning Mandarin Chinese.
<aclass="namelink"href="https://tait.tech/md/">Simple Markdown Editor</a>— A simple online (and offline) browser-based markdown editor that supports the automatic creation of accessible math (MathML).
</p>
</li>
<li>
<p>
<aclass="namelink"href="/emacspeak-tutorials/">Programming Tutorials For The Visually Impaired</a>— Amateur-level production quality videos with all file buffers, written text, and shell commands read out by <ahref="http://emacspeak.sourceforge.net/">Emacspeak</a>, an Emacs extention for the blind.
<aclass="namelink"href="https://github.com/ornicar/lila/pull/7772">Lichess</a>— A patch for Lichess.org which vastly extends support for screen reader users. The website has millions of active players.
</p>
</li>
<li>
<p>
<aclass="namelink"href="https://github.com/TTWNO/lamegames.io">lamegames</a>— A little games website I made for some demonstrations of Django and websocket functionality. Very, very lame. Would not recommend.
<aclass="namelink"href="https://github.com/TTWNO/quote_pdf">Quote Retrieval System</a>— Written for a local roofing business to securely distribute quotes.
</p>
</li>
<li>
<p>
<aclass="namelink"href="https://github.com/TTWNO/chess">chess</a>— A command-line chess game in C++. It is compileable on nearly any system.
<aclass="namelink"href="https://github.com/TTWNO/epub-with-pinyin">epub-with-pinyin</a>— A program to add Pinyin above Chinese characters in .epub files to assist those learning Mandarin Chinese.
</p>
</li>
<li>
<p>
<aclass="namelink"href="https://tait.tech/emacspeak-tutorials/">Emacspeak C Tutorials</a>— C Tutorials for the Visually Impaired
<aclass="namelink"href="https://github.com/TTWNO/lamegames.io">lamegames</a>— A little games website I made for some demonstrations of Django and websocket functionality. Very, very lame. Would not recommend.
</p>
</li>
<li>
<p>
<aclass="namelink"href="https://tait.tech/md/">Simple Markdown Editor</a>— A simple online (and offline) browser-based markdown editor that supports the automatic creation of MathML.
<aclass="namelink"href="https://github.com/TTWNO/chess">chess</a>— A command-line chess game in C++. It is compileable on nearly any system.
<strong>Zone4 Systems Inc.</strong>—<em>Software Developer</em> (June 2021-present)
<p>Software development and QA (testing) for an international race timing company based in Canmore, AB. Testing using unittest and Selenium. Development done in Javascript and Tornado. Zone4 was founded in 2001 by Canadian Olympian Dan Roycroft..</p>
<p>Software development and QA (testing) for an international race timing company based in Canmore, AB. Testing using unittest and Selenium. Development done in Javascript and Tornado. Zone4 was founded in 2001 by Canadian Olympian Dan Roycroft.</p>
<strong><ahref="/emacspeak-tutorials/">Programming Tutorials For The Visually Impaired</a></strong>
<p>Some small pieces of code I've written have made it into a new screen reader for Linux, written in Rust.</p>
<p>Amateur-level production quality videos with all file buffers, written text, and shell commands read out by <ahref="http://emacspeak.sourceforge.net/">Emacspeak</a>, an Emacs extention for the blind.</p>
<p>Amateur-level production quality videos with all file buffers, written text, and shell commands read out by <ahref="http://emacspeak.sourceforge.net/">Emacspeak</a>, an Emacs extention for the blind.</p>
<p>A program to add Pinyin above Chinese characters in .epub files to assist those learning Mandarin Chinese.</p>
</li>
<li>
@ -126,18 +132,6 @@
<p>A command-line chess game in C++. It is compileable on nearly any system.</p>
</li>
<li>
<strong><ahref="https://tait.tech/emacspeak-tutorials/">Emacspeak C Tutorials</a></strong>
<p>A container that stores a collection of items with insertion and removal in “first-in-first-out” order.</p>
<p>Stack: a digram showing circled being placed on top of eachother, pushing circles into the tube, then popping them out from the same size (the top). Like a pringles can of elements.</p>
<p>Queue: a diagram showing circles being unqueued in on the left and dequeued on the right. Like waiting in line for food.</p>
<p>Basic operations:</p>
<ul>
<li>enqueue: add an item to the back of a list</li>
<li>dequeue: remove & return the item at the front of the list</li>
<p>Sequence <codeclass="language-plaintext highlighter-rouge">aba</code> should succeed.
Sequence <codeclass="language-plaintext highlighter-rouge">aab</code> should not.</p>
<p>In an array: a diagram showing the following pattern with the variable <codeclass="language-plaintext highlighter-rouge">i</code> set to the leftmost element and <codeclass="language-plaintext highlighter-rouge">j</code> set to the rightmost element.</p>
<table>
<tbody>
<tr>
<td>Values</td>
<td>a</td>
<td>b</td>
<td>c</td>
<td>…</td>
<td>s</td>
<td>b</td>
<td>a</td>
</tr>
</tbody>
</table>
<p>With a stack and queue:</p>
<ol>
<li>read symbols, starting each in a stack and a queue</li>
<li>while the stack, queue are not empty:
<ul>
<li>pop and element from the stack + delete an element from the queue</li>
<p>A container that stores a collection of items with insertion and removal in “first-in-first-out” order.</p>
<p>Stack: a digram showing circled being placed on top of eachother, pushing circles into the tube, then popping them out from the same size (the top). Like a pringles can of elements.</p>
<p>Queue: a diagram showing circles being unqueued in on the left and dequeued on the right. Like waiting in line for food.</p>
<p>Basic operations:</p>
<ul>
<li>enqueue: add an item to the back of a list</li>
<li>dequeue: remove & return the item at the front of the list</li>
<p>Sequence <codeclass="language-plaintext highlighter-rouge">aba</code> should succeed.
Sequence <codeclass="language-plaintext highlighter-rouge">aab</code> should not.</p>
<p>In an array: a diagram showing the following pattern with the variable <codeclass="language-plaintext highlighter-rouge">i</code> set to the leftmost element and <codeclass="language-plaintext highlighter-rouge">j</code> set to the rightmost element.</p>
<table>
<tbody>
<tr>
<td>Values</td>
<td>a</td>
<td>b</td>
<td>c</td>
<td>…</td>
<td>s</td>
<td>b</td>
<td>a</td>
</tr>
</tbody>
</table>
<p>With a stack and queue:</p>
<ol>
<li>read symbols, starting each in a stack and a queue</li>
<li>while the stack, queue are not empty:
<ul>
<li>pop and element from the stack + delete an element from the queue</li>
<p>A container that stores a collection of items with insertion and removal in “first-in-first-out” order.</p>
<p>Stack: a digram showing circled being placed on top of eachother, pushing circles into the tube, then popping them out from the same size (the top). Like a pringles can of elements.</p>
<p>Queue: a diagram showing circles being unqueued in on the left and dequeued on the right. Like waiting in line for food.</p>
<p>Basic operations:</p>
<ul>
<li>enqueue: add an item to the back of a list</li>
<li>dequeue: remove & return the item at the front of the list</li>
<p>Sequence <codeclass="language-plaintext highlighter-rouge">aba</code> should succeed.
Sequence <codeclass="language-plaintext highlighter-rouge">aab</code> should not.</p>
<p>In an array: a diagram showing the following pattern with the variable <codeclass="language-plaintext highlighter-rouge">i</code> set to the leftmost element and <codeclass="language-plaintext highlighter-rouge">j</code> set to the rightmost element.</p>
<table>
<tbody>
<tr>
<td>Values</td>
<td>a</td>
<td>b</td>
<td>c</td>
<td>…</td>
<td>s</td>
<td>b</td>
<td>a</td>
</tr>
</tbody>
</table>
<p>With a stack and queue:</p>
<ol>
<li>read symbols, starting each in a stack and a queue</li>
<li>while the stack, queue are not empty:
<ul>
<li>pop and element from the stack + delete an element from the queue</li>
<h1id="memory--pointers-1">Memory & Pointers 1</h1>
<p>CMPT-225, Fall 2021</p>
<h2id="computer-memory">Computer Memory</h2>
<ul>
<li>A sequence of locations</li>
<li>Indexed by address: 0,1,2,…</li>
<li>Each location stores a data <em>byte</em></li>
<li>Processor can <em>read</em> or <em>write</em> the byte at each address.</li>
<li>Regions of memory are allocated to processes <em>as needed</em>, according to some scheme.</li>
</ul>
<p>Diagram displaying “Code + Data for running part of OS” at the start of memory, “Free memory” in the middle, and “Code + Data for running user processes” and the end.</p>
<h2id="variables--memory">Variables & Memory</h2>
<p>A variable is (roughly) and names & tagged collection of bytes:</p>
<p>Diagram showing:</p>
<ul>
<li>“int x; x = 6” taking 4 bytes of memory,</li>
<li>“char c; c = ‘x’;” taking 1 byte of memory</li>
<li>
<p>“bool b; b = ‘true’;” taking 1 byte of memory</p>
</li>
<li>So, <em>at run time</em>, each variable has an <em>address</em> in memory.</li>
<li>In C, C++ we can:
<ul>
<li>access the address of a variable</li>
<li>access a variable or memory location by its address</li>
<li>declare variables by storing addresses (pointers).</li>
</ul>
</li>
</ul>
<h2id="addresses--pointers---by-example">Addresses & Pointers - By Example</h2>
<ul>
<li>“int i = 5;”
<ul>
<li>allocate space for an <em>int</em>,</li>
<li>name the space “i”,</li>
<li>store 5 there</li>
</ul>
</li>
<li>“int *p;”
<ul>
<li>allocate space for an address,</li>
<li>name it p,</li>
<li>record its type as “pointer to int”</li>
</ul>
</li>
<li>“p = ∧i;”
<ul>
<li>“&i” is the address of “i”</li>
<li>store ∧i in p</li>
<li>so, p becomes a <em>pointer to i</em></li>
</ul>
</li>
<li>“cout «i;”
<ul>
<li>outputs the value stored in i, <em>5</em></li>
</ul>
</li>
<li>“cout «p;”
<ul>
<li>outputs the address of i: 0xbffffbbc</li>
</ul>
</li>
<li>“cout « *p;”
<ul>
<li>”*” <em>dereferences</em> p. That is, *p is the value <em>pointed to by p</em>. In this case <em>5</em></li>
</ul>
</li>
</ul>
<p>Diagram of memory:</p>
<table>
<tbody>
<tr>
<td>Address</td>
<td>Name</td>
<td>Value</td>
</tr>
<tr>
<td>…</td>
<td>…</td>
<td>…</td>
</tr>
<tr>
<td><spanid="point">254</span></td>
<td>i</td>
<td>5</td>
</tr>
<tr>
<td>…</td>
<td>…</td>
<td>…</td>
</tr>
<tr>
<td>923</td>
<td>p</td>
<td><ahref="index.html#point">254</a></td>
</tr>
</tbody>
</table>
<p>Second diagram of memory:</p>
<table>
<tbody>
<tr>
<td>Address</td>
<td>Name</td>
<td>Value</td>
<td>Size</td>
</tr>
<tr>
<td>0x6fffbe</td>
<td>i</td>
<td>5</td>
<td>4 bytes</td>
</tr>
<tr>
<td>…</td>
<td>…</td>
<td>…</td>
<td>…</td>
</tr>
<tr>
<td>???</td>
<td>p</td>
<td>0x6fffbe</td>
<td>4 bytesa</td>
</tr>
</tbody>
</table>
<p>Slide showing program code: see pointers.c</p>
<p>Slide showing output: see output.txt</p>
<p>Slide showing same program with different highlights.</p>
<p>Slide showing same output with different highlights.</p>
<h1id="memory--pointers-1">Memory & Pointers 1</h1>
<p>CMPT-225, Fall 2021</p>
<h2id="computer-memory">Computer Memory</h2>
<ul>
<li>A sequence of locations</li>
<li>Indexed by address: 0,1,2,…</li>
<li>Each location stores a data <em>byte</em></li>
<li>Processor can <em>read</em> or <em>write</em> the byte at each address.</li>
<li>Regions of memory are allocated to processes <em>as needed</em>, according to some scheme.</li>
</ul>
<p>Diagram displaying “Code + Data for running part of OS” at the start of memory, “Free memory” in the middle, and “Code + Data for running user processes” and the end.</p>
<h2id="variables--memory">Variables & Memory</h2>
<p>A variable is (roughly) and names & tagged collection of bytes:</p>
<p>Diagram showing:</p>
<ul>
<li>“int x; x = 6” taking 4 bytes of memory,</li>
<li>“char c; c = ‘x’;” taking 1 byte of memory</li>
<li>
<p>“bool b; b = ‘true’;” taking 1 byte of memory</p>
</li>
<li>So, <em>at run time</em>, each variable has an <em>address</em> in memory.</li>
<li>In C, C++ we can:
<ul>
<li>access the address of a variable</li>
<li>access a variable or memory location by its address</li>
<li>declare variables by storing addresses (pointers).</li>
</ul>
</li>
</ul>
<h2id="addresses--pointers---by-example">Addresses & Pointers - By Example</h2>
<ul>
<li>“int i = 5;”
<ul>
<li>allocate space for an <em>int</em>,</li>
<li>name the space “i”,</li>
<li>store 5 there</li>
</ul>
</li>
<li>“int *p;”
<ul>
<li>allocate space for an address,</li>
<li>name it p,</li>
<li>record its type as “pointer to int”</li>
</ul>
</li>
<li>“p = ∧i;”
<ul>
<li>“&i” is the address of “i”</li>
<li>store ∧i in p</li>
<li>so, p becomes a <em>pointer to i</em></li>
</ul>
</li>
<li>“cout «i;”
<ul>
<li>outputs the value stored in i, <em>5</em></li>
</ul>
</li>
<li>“cout «p;”
<ul>
<li>outputs the address of i: 0xbffffbbc</li>
</ul>
</li>
<li>“cout « *p;”
<ul>
<li>”*” <em>dereferences</em> p. That is, *p is the value <em>pointed to by p</em>. In this case <em>5</em></li>
</ul>
</li>
</ul>
<p>Diagram of memory:</p>
<table>
<tbody>
<tr>
<td>Address</td>
<td>Name</td>
<td>Value</td>
</tr>
<tr>
<td>…</td>
<td>…</td>
<td>…</td>
</tr>
<tr>
<td><spanid="point">254</span></td>
<td>i</td>
<td>5</td>
</tr>
<tr>
<td>…</td>
<td>…</td>
<td>…</td>
</tr>
<tr>
<td>923</td>
<td>p</td>
<td><ahref="#point">254</a></td>
</tr>
</tbody>
</table>
<p>Second diagram of memory:</p>
<table>
<tbody>
<tr>
<td>Address</td>
<td>Name</td>
<td>Value</td>
<td>Size</td>
</tr>
<tr>
<td>0x6fffbe</td>
<td>i</td>
<td>5</td>
<td>4 bytes</td>
</tr>
<tr>
<td>…</td>
<td>…</td>
<td>…</td>
<td>…</td>
</tr>
<tr>
<td>???</td>
<td>p</td>
<td>0x6fffbe</td>
<td>4 bytesa</td>
</tr>
</tbody>
</table>
<p>Slide showing program code: see pointers.c</p>
<p>Slide showing output: see output.txt</p>
<p>Slide showing same program with different highlights.</p>
<p>Slide showing same output with different highlights.</p>
<h1id="memory--pointers-1">Memory & Pointers 1</h1>
<p>CMPT-225, Fall 2021</p>
<h2id="computer-memory">Computer Memory</h2>
<ul>
<li>A sequence of locations</li>
<li>Indexed by address: 0,1,2,…</li>
<li>Each location stores a data <em>byte</em></li>
<li>Processor can <em>read</em> or <em>write</em> the byte at each address.</li>
<li>Regions of memory are allocated to processes <em>as needed</em>, according to some scheme.</li>
</ul>
<p>Diagram displaying “Code + Data for running part of OS” at the start of memory, “Free memory” in the middle, and “Code + Data for running user processes” and the end.</p>
<h2id="variables--memory">Variables & Memory</h2>
<p>A variable is (roughly) and names & tagged collection of bytes:</p>
<p>Diagram showing:</p>
<ul>
<li>“int x; x = 6” taking 4 bytes of memory,</li>
<li>“char c; c = ‘x’;” taking 1 byte of memory</li>
<li>
<p>“bool b; b = ‘true’;” taking 1 byte of memory</p>
</li>
<li>So, <em>at run time</em>, each variable has an <em>address</em> in memory.</li>
<li>In C, C++ we can:
<ul>
<li>access the address of a variable</li>
<li>access a variable or memory location by its address</li>
<li>declare variables by storing addresses (pointers).</li>
</ul>
</li>
</ul>
<h2id="addresses--pointers---by-example">Addresses & Pointers - By Example</h2>
<ul>
<li>“int i = 5;”
<ul>
<li>allocate space for an <em>int</em>,</li>
<li>name the space “i”,</li>
<li>store 5 there</li>
</ul>
</li>
<li>“int *p;”
<ul>
<li>allocate space for an address,</li>
<li>name it p,</li>
<li>record its type as “pointer to int”</li>
</ul>
</li>
<li>“p = ∧i;”
<ul>
<li>“&i” is the address of “i”</li>
<li>store ∧i in p</li>
<li>so, p becomes a <em>pointer to i</em></li>
</ul>
</li>
<li>“cout «i;”
<ul>
<li>outputs the value stored in i, <em>5</em></li>
</ul>
</li>
<li>“cout «p;”
<ul>
<li>outputs the address of i: 0xbffffbbc</li>
</ul>
</li>
<li>“cout « *p;”
<ul>
<li>”*” <em>dereferences</em> p. That is, *p is the value <em>pointed to by p</em>. In this case <em>5</em></li>
</ul>
</li>
</ul>
<p>Diagram of memory:</p>
<table>
<tbody>
<tr>
<td>Address</td>
<td>Name</td>
<td>Value</td>
</tr>
<tr>
<td>…</td>
<td>…</td>
<td>…</td>
</tr>
<tr>
<td><spanid="point">254</span></td>
<td>i</td>
<td>5</td>
</tr>
<tr>
<td>…</td>
<td>…</td>
<td>…</td>
</tr>
<tr>
<td>923</td>
<td>p</td>
<td><ahref="index.html#point">254</a></td>
</tr>
</tbody>
</table>
<p>Second diagram of memory:</p>
<table>
<tbody>
<tr>
<td>Address</td>
<td>Name</td>
<td>Value</td>
<td>Size</td>
</tr>
<tr>
<td>0x6fffbe</td>
<td>i</td>
<td>5</td>
<td>4 bytes</td>
</tr>
<tr>
<td>…</td>
<td>…</td>
<td>…</td>
<td>…</td>
</tr>
<tr>
<td>???</td>
<td>p</td>
<td>0x6fffbe</td>
<td>4 bytesa</td>
</tr>
</tbody>
</table>
<p>Slide showing program code: see pointers.c</p>
<p>Slide showing output: see output.txt</p>
<p>Slide showing same program with different highlights.</p>
<p>Slide showing same output with different highlights.</p>