Perihelion tutorial 1: Difference between revisions

From AtariForumWiki
Jump to navigation Jump to search
>Admin
No edit summary
>Admin
No edit summary
Line 1: Line 1:
[[Category:Category Perihelions Atari ST M68000 tutorial]]
[[Category:Category Perihelions Atari ST M68000 tutorial]]
<center>'''The Atari ST M68000 tutorial part 1 – on the theory behind programming'''</center>
The Atari ST M68000 tutorial part 1 – on the theory behind programming
<div align="center">
    
   <center>
Hi everybody! This is Warrior Munk of poSTmortem (aka Andreas Wahlin) writing. Me and Aldebaran (aka Lars Lindblad) have just started this little project of ours; the demo group poSTmortem. As a first step towards actually doing something with the ST, we thought that writing a tutorial might be good. In this way, we can teach ourselves and you (whoever is listening).  
  <table border="0" width="70%">
This tutorial is aimed at people who, like ourselves, want to learn to code assembler for the Atari ST. What? You say, this is the year 2002, why on earth would you want to learn how to code, for one thing, assembler, and assembler for the Atari? You must be crazy. Well, you might think the Atari is dead, but we say it survived itself, it has risen again, it is; poSTmortem (totally lame, right?). You don’t need any programming skills, although it might help since learning to code from assembly language is probably quite suicidal in a pedagogical view. I’ll try to cover the basics of general programming and setting you up in this tutorial, and in part two we will do some rather simple program to get things started. I will however, assume that you have some basic skills in Atari management, like file copying and so on. Also, I will assume you have a real Atari, emulating might work fine, but nothing beats the real thing.  
    <tr>
What is programming? Programming is the art and science of making the computer do what you want it to do. BTW, programming is also known as coding, I will use these two terms somewhat mixed probably. So, how do we do that? By telling the computer what to do, and then do it. Since you don’t have shit for brains, you will know that when you double click on a .prg file (known as .exe files on a PC), the computer will do stuff, like running a game. So, what if we could create our own .prg files… Yes, we can do that, this is where you’ll learn how!
      <td width="100%">
Every computer has a memory, this is where the number on your Atari is derived from, 520 have half a Meg (short for Mega Byte) of ram, and 1040’s have one Meg. Your usual PC these days have about 256 megs of ram, Bill Gates once said “nobody needs more than 640 K ram (about the memory amount of  an Atari 520). If these numbers confuse you, do not worry, they aren’t important right now. The memory is very temporary; it gets wiped out every time you turn off your Atari, unlike diskettes (thank God). When you run a program, the computer loads the program into memory, and then executes (follows the instructions given by the program).
        <p class="MsoNormal" style="text-align:justify;text-indent:65.2pt;mso-pagination:
¬Every area of the memory has an address, so you know where you are. You can think of these addresses as normal street addresses, but perhaps it would be better if you thought of them more as page indexes in a book. Every page is filled with information on how to act. So, let’s assume that we have a monitor capable of displaying one of two colours, either black or white. The memory address $20 holds this colour. 1 means black, 0 white. If memory looks like this, we get a black screen. 
none;mso-layout-grid-align:none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font size="1" face="Verdana">Hi
Address Value
        everybody! This is Warrior Munk of poSTmortem (aka Andreas Wahlin)
… 
        writing. Me and Aldebaran (aka Lars Lindblad) have just started this
$19 12 
        little project of ours; the demo group poSTmortem. As a first step
$20 1
        towards actually doing something with the ST, we thought that writing a
$21 67 
        tutorial might be good. In this way, we can teach ourselves and you (whoever
… 
        is listening).  
(each address can hold a number between 0 and 255)
        </font></span></p>
 
        <p class="MsoNormal" style="text-align:justify;text-indent:65.2pt;mso-pagination:
To understand a bit better about memory, because this is very important, we expand our little example. There is an area in the memory reserved for the user. This area is just for information storage, and does not affect the hardware. Let’s say that the monitor is capable of displaying text as well, the text is also either black or white as previously stated, and the information on the text colour is to be found at $21. Further, the address $22 holds a pointer to the text to be displayed. Pointer? Argh! Well, it’s really quite easy, a pointer is a reference to another part of the memory. Show first, talk later.
none;mso-layout-grid-align:none;text-autospace:none"><font size="1"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font  face="Verdana">This
   
        tutorial is aimed at people who, like ourselves, want to learn to code
Memorie Value
        assembler for the Atari ST. What? You say, this is the year 2002, why on
...
        earth would you want to learn how to code, for one thing, assembler, and
$19 12 
        assembler for the Atari? You must be crazy. Well, you might think the
$20 1
        Atari is dead, but we say it survived itself, it has risen again, it is;
$21 0
        poSTmortem (totally lame, right?). You don’t need any programming
$22 101
        skills, although it might help since learning to code from assembly
…
        language is probably quite suicidal in a pedagogical view. I’ll try to
$101 Hello World!
        cover the basics of general programming and setting you up in this
$200 DOH!
        tutorial, and in part two we will do some rather simple program to get
…
        things started. I will however, assume that you have some basic skills
 
        in Atari management, like file copying and so on. Also, I will assume
In this example, the “user memory” begins after position $100. All address positions $0 - $100 does something with the hardware in some way, but after that, it’s just storage space. With the above values, and given our premise, the text “Hello World!”, will be displayed in white text on black background. Let’s say we were to change the values to this instead.
        you have a real Atari, emulating might work fine, but nothing beats the
   
        real thing.
Memory Value
…
$19 12
$20 1
$21 1 
$22 200
…
$101 Hello World! 
$200 DOH!
… 
(changed values at $21 and $22)
 
We would get the text “DOH!” written in black text on black background, not to clever. Therefore, a pointer is a reference to another place. Because $22 only can hold a number of 0 - 255, the text “Hello World!” would never fit, so instead we point to an area in the user memory, which can hold much more than just a number between 0 - 255. Are you beginning to grasp how computers work?
If you have an enquiring mind, and I hope you do, you’ll probably wonder why the addresses $0 - $100 only hold numbers, while it seems that addresses $101 - … can hold letters. The answer is, they actually can’t hold any letters. In addition, it doesn’t quite look like I’ve shown you either. This might get somewhat complicated, hold your hat and don’t cry if you don’t get it. Just read it, let it go, meditate a bit and you’ll reach enlightenment.
            The addresses $101 and $200 actually only hold numbers, but the computer have a decode key so that each number can be decoded to a letter. Let’s say that
! = 0
A = 1
B = 2
C = 3
D = 4
…
and so on, then it really looks like this
Memory Value Meaning 
$200 3 D 
$201 14 O
$202  7 H
$203 0 ! 
…
             
            So you see, there are just numbers, also, as I said, each address can only hold a number between 0 - 255, meaning that each letter is held in one address. But but but but, why doesn’t more stuff get displayed as text? Why does it stop at $203? The memory must continue after that surely. Let’s look at this memory setup.
   
Memory  Value Meaning 
$200 4 D
$201 15 O 
$202 8 H
$203 0 ! 
$204 15 O
$205 4 D 
… 
            The text on the screen would display as “DOH!OD” and probably much more (the rest of the memory in fact). Well, here we use a control number, let’s say that the computer knows that when in reaches the number 255 the text ends there. If memory looks like this
             
Memory Value Meaning 
...
$19 12  something 
$20 1 background colour 
$21 0 text colour
$22 200 pointer to text on screen
… 
$200 4 D
$201 15 O 
$202 8 H 
$203 0 ! 
$204 255 end of text 
$205 4 D
           
            the text “DOH!” would be displayed in white on black background. When the computer reaches $204, it sees the number 255, which means stop displaying text, so the letter (or rather, value) at $205 and following addresses will not be displayed. Like I said, this may be a bit advanced, don’t panic. We will get much more concrete in tutorial 2. I just want you to have a theoretical basis so you know what’s what and so you can refer back to this. Just let this sink into your unconscious, when the time is right and you have correct understanding, it will surface and you will get it.
            Now, for last theory lesson; how do you actually make something happen? As we know, there are .prg files that make stuff happen. With our above knowledge, we know that they affect memory. We can write down simple commands in a text file, and then have that text file translated into the .prg format, so that the computer will understand what we say. A program that can pull this off is known as a compiler, a compiler usually comes with a text editor, suited for programming needs. The text file you use to create a .prg file, is knows as the source code.  Let’s take another example, this time let’s assume we wrote this source code. 
Put #1 at $20
Put #0 at $21
Put #200 at $22
Put #4 at $200
Put #15 at $201
Put #8 at $202
Put #0 at $203
Put #255 at $204
Initialize monitor 
            Now, as you can guess, # stands for value, a numerical value in our case, and $ stands for address. Now, if we compile this source code, that is, translate it to a format the computer understands, we will get a .prg file. When we double click on that file, the computer will do what it says above; the different values will be loaded into the different addresses, creating the memory profile given above. The last line “Initialize monitor” is for engaging the monitor. When the monitor is engaged, the Atari knows that it should look at $20, $21 and $22 to gather the data needed. So instead of “Initialize monitor”, perhaps we could’ve written
   
Activate $20
Activate $21
Activate $22 
            Because what we really want to do is to make the information on these addresses happen; we want the computer to process the information given. This is long and clumsy however, and the line “Initialize monitor”, or whatever you might call it, is far simpler.
The computer, internally, understands nothing but 1’s and 0’s, all text and numbers I have given above is for human understanding (more on binary understanding later). Also, none of the commands or memory addresses have any significance for the Atari, they are examples only.
OK, theory lesson over. Hope I haven’t scared you away. In the next tutorial we will get into how to actually make a .prg file. It won’t do much, but at least you will get to see your code in action.
Warrior Munk of poSTmortem, 2002-03-31
“Conan, what is best in life?”
“To crush your enemies, see them driven before you, and to hear the lamentations of their women.”
Conan the Barbarian


        </font></span></font></p>
        <p class="MsoNormal" style="text-align:justify;text-indent:65.2pt;mso-pagination:
none;mso-layout-grid-align:none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font size="1" face="Verdana">What
        is programming? Programming is the art and science of making the
        computer do what you want it to do. BTW, programming is also known as
        coding, I will use these two terms somewhat mixed probably. So, how do
        we do that? By telling the computer what to do, and then do it. Since
        you don’t have shit for brains, you will know that when you double
        click on a .prg file (known as .exe files on a PC), the computer will do
        stuff, like running a game. So, what if we could create our own .prg
        files… Yes, we can do that, this is where you’ll learn how!
        </font></span></p>
        <p class="MsoNormal" style="text-align:justify;text-indent:65.2pt;mso-pagination:
none;mso-layout-grid-align:none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font size="1" face="Verdana">Every
        computer has a memory, this is where the number on your Atari is derived
        from, 520 have half a Meg (short for Mega Byte) of ram, and 1040’s
        have one Meg. Your usual PC these days have about 256 megs of ram, Bill
        Gates once said “nobody needs more than 640 K ram (about the memory
        amount of<span style="mso-spacerun: yes">&nbsp; </span>an Atari 520). If
        these numbers confuse you, do not worry, they aren’t important right
        now. The memory is very temporary; it gets wiped out every time you turn
        off your Atari, unlike diskettes (thank God). When you run a program,
        the computer loads the program into memory, and then executes (follows
        the instructions given by the program).
        </font></span></p>


        <p class="MsoNormal" style="text-align:justify;text-indent:65.2pt;mso-pagination:
Last edited 2002-04-07
none;mso-layout-grid-align:none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font size="1" face="Verdana">­Every
        area of the memory has an address, so you know where you are. You can
        think of these addresses as normal street addresses, but perhaps it
        would be better if you thought of them more as page indexes in a book.
        Every page is filled with information on how to act. So, let’s assume
        that we have a monitor capable of displaying one of two colours, either
        black or white. The memory address $20 holds this colour. 1 means black,
        0 white. If memory looks like this, we get a black screen.
        &nbsp;
        </font></span></p>
       
      <table border="0" width="100%" cellspacing="7">
 
        <tr>
          <td width="25%" align="left">
            <font color="#CCFFFF" size="1" face="Verdana">Address</font></td>
          <td width="75%" align="left">
            <p align="left"><font color="#FFFFCC" size="1" face="Verdana">Value</font></td>
        </tr>
        <tr>
          <td width="25%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">…
 
            &nbsp;</font></span></td>
          <td width="75%" align="left"></td>
        </tr>
        <tr>
          <td width="25%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$19</font></span></td>
          <td width="75%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">12
            &nbsp;</font></span></td>
        </tr>
 
        <tr>
          <td width="25%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$20</font></span></td>
          <td width="75%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">1</font></span></td>
        </tr>
        <tr>
          <td width="25%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$21</font></span></td>
          <td width="75%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">67
 
            &nbsp;</font></span></td>
        </tr>
        <tr>
          <td width="25%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">…
            &nbsp;</font></span></td>
          <td width="75%" align="left"></td>
        </tr>
      </table>
 
  <center>
        <p class="MsoNormal" style="text-align:justify;text-indent:65.2pt;mso-pagination:
none;mso-layout-grid-align:none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFFF" size="1" face="Verdana">(each
        address can hold a number between 0 and 255)
        </font></span></p>
        <p class="MsoNormal" style="text-align:justify;text-indent:65.2pt;mso-pagination:
none;mso-layout-grid-align:none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFFF" size="1" face="Verdana">&nbsp;
        </font></span></p>
        <p class="MsoNormal" style="text-align:justify;text-indent:65.2pt;mso-pagination:
none;mso-layout-grid-align:none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font size="1" face="Verdana">To
        understand a bit better about memory, because this is very important, we
        expand our little example. There is an area in the memory reserved for
        the user. This area is just for information storage, and does not affect
        the hardware. Let’s say that the monitor is capable of displaying text
        as well, the text is also either black or white as previously stated,
        and the information on the text colour is to be found at $21. Further,
        the address $22 holds a pointer to the text to be displayed. Pointer?
        Argh! Well, it’s really quite easy, a pointer is a reference to
        another part of the memory. Show first, talk later.
 
  </center>
      <table border="0" width="100%" cellspacing="5">
        <tr>
          <td width="21%" align="left">
 
            <font color="#CCFFFF" size="1" face="Verdana">Memorie</font></td>
  <center>
  <td width="79%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">Value<o:p>
    </font></span></td>
          </tr>
          <tr>
            <td width="21%" align="left"><span style="mso-ansi-language: EN-GB" lang="EN-GB"><font color="#CCFFFF" size="1" face="Verdana">...</font></span></td>
 
            <td width="79%" align="left"></td>
          </tr>
          <tr>
            <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$19</font></span></td>
            <td width="79%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">12<o:p>
              &nbsp;</font></span></td>
          </tr>
          <tr>
 
            <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$20</font></span></td>
            <td width="79%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">1</font></span></td>
          </tr>
          <tr>
            <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$21</font></span></td>
            <td width="79%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">0</font></span></td>
          </tr>
 
          <tr>
            <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$22</font></span></td>
            <td width="79%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">101</font></span></td>
          </tr>
          <tr>
            <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">…</font></span></td>
            <td width="79%" align="left"></td>
 
          </tr>
          <tr>
            <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$101</font></span></td>
            <td width="79%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">Hello World!</font></span></td>
          </tr>
          <tr>
            <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$200</font></span></td>
 
            <td width="79%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">DOH!
              </font></span></td>
          </tr>
          <tr>
            <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">…
              </font></span></td>
            <td width="79%"></td>
          </tr>
 
        </table>
        <p class="MsoNormal" style="text-align:justify;text-indent:65.2pt;mso-pagination:
none;mso-layout-grid-align:none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font size="1" face="Verdana">In
        this example, the “user memory” begins after position $100. All
        address positions $0 - $100 does something with the hardware in some way,
        but after that, it’s just storage space. With the above values, and
        given our premise, the text “Hello World!”, will be displayed in
        white text on black background. Let’s say we were to change the values
        to this instead.
        </font></span></p>
 
        <table border="0" width="100%" cellspacing="5">
          <tr>
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">Memory</font></span></td>
            <td width="78%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">Value</font></span></td>
          </tr>
          <tr>
 
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">…</font></span></td>
            <td width="78%" align="left"></td>
          </tr>
          <tr>
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$19</font></span></td>
            <td width="78%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">12</font></span></td>
          </tr>
 
          <tr>
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$20</font></span></td>
            <td width="78%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">1</font></span></td>
          </tr>
          <tr>
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$21</font></span></td>
            <td width="78%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">1<o:p>
 
              &nbsp;</font></span></td>
          </tr>
          <tr>
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$22</font></span></td>
            <td width="78%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">200</font></span></td>
          </tr>
          <tr>
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">…</font></span></td>
 
            <td width="78%" align="left"></td>
          </tr>
          <tr>
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$101</font></span></td>
            <td width="78%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">Hello World!<o:p>
              &nbsp;</font></span></td>
          </tr>
          <tr>
 
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$200</font></span></td>
            <td width="78%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">DOH!</font></span></td>
          </tr>
          <tr>
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">…<o:p>
              &nbsp;</font></span></td>
            <td width="78%" align="left"></td>
 
          </tr>
          <tr>
            <td width="100%" align="right" colspan="2">
        <p class="MsoNormal" style="text-indent: 65.2pt; mso-pagination: none; mso-layout-grid-align: none; text-autospace: none" align="center">&nbsp;</p>
        <p class="MsoNormal" style="text-indent: 65.2pt; mso-pagination: none; mso-layout-grid-align: none; text-autospace: none" align="center"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFFF" size="1" face="Verdana">(changed
        values at $21 and $22)<o:p>
        </o:p>
        </font></span></p>
            </td>
 
          </tr>
        </table>
        <p class="MsoNormal" style="text-align:justify;text-indent:65.2pt;mso-pagination:
none;mso-layout-grid-align:none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFFF" size="1" face="Verdana">&nbsp;<o:p>
        </o:p>
        </font></span></p>
        <p class="MsoNormal" style="text-align:justify;text-indent:65.2pt;mso-pagination:
none;mso-layout-grid-align:none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font size="1" face="Verdana">We
        would get the text “DOH!” written in black text on black background,
        not to clever. Therefore, a pointer is a reference to another place.
        Because $22 only can hold a number of 0 - 255, the text “Hello World!”
        would never fit, so instead we point to an area in the user memory,
        which can hold much more than just a number between 0 - 255. Are you
        beginning to grasp how computers work? <o:p>
        </o:p>
        </font></span></p>
 
        <p class="MsoNormal" style="text-align:justify;text-indent:65.2pt;mso-pagination:
none;mso-layout-grid-align:none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font size="1" face="Verdana">If
        you have an enquiring mind, and I hope you do, you’ll probably wonder
        why the addresses $0 - $100 only hold numbers, while it seems that
        addresses $101 - … can hold letters. The answer is, they actually can’t
        hold any letters. In addition, it doesn’t quite look like I’ve shown
        you either. This might get somewhat complicated, hold your hat and
        don’t cry if you don’t get it. Just read it, let it go, meditate a
        bit and you’ll reach enlightenment. <o:p>
        </o:p>
        </font></span></p>
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><span style="mso-tab-count:1"><font size="1" face="Verdana">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </font></span><font size="1" face="Verdana">The addresses $101 and $200 actually
        only hold numbers, but the computer have a decode key so that each
        number can be decoded to a letter. Let’s say that
        </font></span></p>
 
  </center>
        <p class="MsoNormal" style="text-indent: 65.2pt; mso-pagination: none; mso-layout-grid-align: none; text-autospace: none" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">!
        = 0<o:p>
        </o:p>
        </font></span></p>
        <p class="MsoNormal" style="text-indent: 65.2pt; mso-pagination: none; mso-layout-grid-align: none; text-autospace: none" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">A
        = 1<o:p>
        </o:p>
        </font></span></p>
        <p class="MsoNormal" style="text-indent: 65.2pt; mso-pagination: none; mso-layout-grid-align: none; text-autospace: none" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">B
        = 2<o:p>
 
        </o:p>
        </font></span></p>
        <p class="MsoNormal" style="text-indent: 65.2pt; mso-pagination: none; mso-layout-grid-align: none; text-autospace: none" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">C
        = 3<o:p>
        </o:p>
        </font></span></p>
        <p class="MsoNormal" style="text-indent: 65.2pt; mso-pagination: none; mso-layout-grid-align: none; text-autospace: none" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">D
        = 4<o:p>
        </o:p>
        </font></span></p>
 
        <p class="MsoNormal" style="text-indent: 65.2pt; mso-pagination: none; mso-layout-grid-align: none; text-autospace: none" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font size="1" face="Verdana"><font color="#FFFFCC">…<o:p>
        </font><font color="#FFFFFF">
        </o:p>
        </font></font></span></p>
  <center>
        <p class="MsoNormal" style="text-align:justify;text-indent:65.2pt;mso-pagination:
none;mso-layout-grid-align:none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFFF" size="1" face="Verdana">and
        so on, then it really looks like this
        </font></span></p>
        <p class="MsoNormal" style="text-align:justify;text-indent:65.2pt;mso-pagination:
none;mso-layout-grid-align:none;text-autospace:none"><font size="1" face="Verdana">&nbsp;</font></p>
  <table border="0" width="100%" cellspacing="5">
 
    <tr>
      <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">Memory</font></span></td>
      <td width="17%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">Value</font></span></td>
      <td width="62%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">Meaning<o:p>
        &nbsp;</font></span></td>
    </tr>
    <tr>
 
      <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$200</font></span></td>
      <td width="17%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">3</font></span></td>
      <td width="62%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">D<o:p>
        &nbsp;</font></span></td>
    </tr>
    <tr>
      <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$201</font></span></td>
 
      <td width="17%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">14</font></span></td>
      <td width="62%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">O</font></span></td>
    </tr>
    <tr>
      <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$202<span style="mso-tab-count:1">&nbsp;
        </span></font></span></td>
      <td width="17%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">7</font></span></td>
 
      <td width="62%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">H</font></span></td>
    </tr>
    <tr>
      <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$203</font></span></td>
      <td width="17%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">0</font></span></td>
      <td width="62%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">!<o:p>
        &nbsp;</font></span></td>
 
    </tr>
    <tr>
      <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">…</font></span></td>
      <td width="17%" align="center"></td>
      <td width="62%" align="left"></td>
    </tr>
  </table>
        <p class="MsoNormal" style="text-align:justify;text-indent:65.2pt;mso-pagination:
none;mso-layout-grid-align:none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFFF" size="1" face="Verdana"><span style="mso-tab-count:1">&nbsp;
 
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
        </o:p>
        </font></span></p>
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font size="1" face="Verdana"><span style="mso-tab-count:1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </span>So you see, there are just numbers, also, as I said, each address
        can only hold a number between 0 - 255, meaning that each letter is held
        in one address. But but but but, why doesn’t more stuff get displayed
        as text? Why does it stop at $203? The memory must continue after that
        surely. Let’s look at this memory setup.<o:p>
        </o:p>
        </font></span></p>
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFFF" size="1" face="Verdana">&nbsp;<o:p>
 
        &nbsp;
        </font></span></p>
  <table border="0" width="100%" cellspacing="5">
    <tr>
      <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">Memory<span style="mso-tab-count:
1">&nbsp; </span></font></span></td>
      <td width="18%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">Value</font></span></td>
      <td width="61%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">Meaning<o:p>
 
        &nbsp;</font></span></td>
    </tr>
    <tr>
      <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$200</font></span></td>
      <td width="18%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">4</font></span></td>
      <td width="61%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">D</font></span></td>
    </tr>
 
    <tr>
      <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$201</font></span></td>
      <td width="18%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">15</font></span></td>
      <td width="61%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">O<o:p>
        &nbsp;</font></span></td>
    </tr>
    <tr>
 
      <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$202</font></span></td>
      <td width="18%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">8</font></span></td>
      <td width="61%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">H</font></span></td>
    </tr>
    <tr>
      <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$203</font></span></td>
      <td width="18%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">0</font></span></td>
 
      <td width="61%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">!<o:p>
        &nbsp;</font></span></td>
    </tr>
    <tr>
      <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$204</font></span></td>
      <td width="18%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">15</font></span></td>
      <td width="61%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">O</font></span></td>
 
    </tr>
    <tr>
      <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$205</font></span></td>
      <td width="18%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">4</font></span></td>
      <td width="61%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">D<o:p>
        &nbsp;</font></span></td>
    </tr>
 
    <tr>
      <td width="21%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">…<o:p>
        &nbsp;</font></span></td>
      <td width="18%" align="left"></td>
      <td width="61%"></td>
    </tr>
  </table>
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font size="1" face="Verdana">
 
        </o:p>
        </font></span></p>
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font size="1" face="Verdana"><span style="mso-tab-count:1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </span>The text on the screen would display as “DOH!OD” and probably
        much more (the rest of the memory in fact). Well, here we use a control
        number, let’s say that the computer knows that when in reaches the
        number 255 the text ends there. If memory looks like this<o:p>
        </o:p>
        </font></span></p>
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><span style="mso-tab-count:1"><font color="#FFFFFF"><font size="1" face="Verdana">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </font>
 
        </font></span><font color="#FFFFFF"><o:p>
        &nbsp;
        </font></span></p>
        <table border="0" width="100%" cellspacing="5">
          <tr>
            <td width="24%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">Memory</font></span></td>
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">Value</font></span></td>
            <td width="54%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">Meaning<o:p>
 
              &nbsp;</font></span></td>
          </tr>
          <tr>
            <td width="24%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">...</font></span></td>
            <td width="22%" align="left"></td>
            <td width="54%" align="left"></td>
          </tr>
          <tr>
 
            <td width="24%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$19</font></span></td>
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">12<span style="mso-tab-count:1">&nbsp;
        </span></font></span></td>
            <td width="54%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">something<o:p>
              &nbsp;</font></span></td>
          </tr>
          <tr>
 
            <td width="24%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$20</font></span></td>
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">1</font></span></td>
            <td width="54%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">background colour<o:p>
              &nbsp;</font></span></td>
          </tr>
          <tr>
            <td width="24%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$21</font></span></td>
 
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">0</font></span></td>
            <td width="54%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">text colour</font></span></td>
          </tr>
          <tr>
            <td width="24%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$22<span style="mso-tab-count:1">&nbsp;</span></font></span></td>
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">200</font></span></td>
            <td width="54%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">pointer to text on screen</font></span></td>
 
          </tr>
          <tr>
            <td width="24%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">…<o:p>
              &nbsp;</font></span></td>
            <td width="22%" align="left"></td>
            <td width="54%" align="left"></td>
          </tr>
          <tr>
 
            <td width="24%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$200</font></span></td>
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">4</font></span></td>
            <td width="54%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">D</font></span></td>
          </tr>
          <tr>
            <td width="24%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$201</font></span></td>
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">15</font></span></td>
 
            <td width="54%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">O<o:p>
              &nbsp;</font></span></td>
          </tr>
          <tr>
            <td width="24%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$202</font></span></td>
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">8</font></span></td>
            <td width="54%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">H<o:p>
 
              &nbsp;</font></span></td>
          </tr>
          <tr>
            <td width="24%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$203</font></span></td>
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">0</font></span></td>
            <td width="54%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">!<o:p>
              &nbsp;</font></span></td>
 
          </tr>
          <tr>
            <td width="24%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$204</font></span></td>
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">255</font></span></td>
            <td width="54%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">end of text<o:p>
              &nbsp;</font></span></td>
          </tr>
 
          <tr>
            <td width="24%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFFF" size="1" face="Verdana">$205</font></span></td>
            <td width="22%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">4</font></span></td>
            <td width="54%" align="left"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#CCFFCC" size="1" face="Verdana">D</font></span></td>
          </tr>
        </table>
        <p class="MsoNormal" style="text-align:justify;text-indent:65.2pt;mso-pagination:
none;mso-layout-grid-align:none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFFF" size="1" face="Verdana"><span style="mso-tab-count:1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
        </o:p>
        </font></span></p>
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font size="1" face="Verdana"><span style="mso-tab-count:1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </span>the text “DOH!” would be displayed in white on black
        background. When the computer reaches $204, it sees the number 255,
        which means stop displaying text, so the letter (or rather, value) at
        $205 and following addresses will not be displayed. Like I said, this
        may be a bit advanced, don’t panic. We will get much more concrete in
        tutorial 2. I just want you to have a theoretical basis so you know what’s
        what and so you can refer back to this. Just let this sink into your
        unconscious, when the time is right and you have correct understanding,
        it will surface and you will get it. <o:p>
        </o:p>
        </font></span></p>
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><span style="mso-tab-count:1"><font color="#FFFFFF"><font size="1" face="Verdana">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 
        </font>
        </font></span><font size="1" face="Verdana">Now, for last theory lesson; how do
        you actually make something happen? As we know, there are .prg files
        that make stuff happen. With our above knowledge, we know that they
        affect memory. We can write down simple commands in a text file, and
        then have that text file translated into the .prg format, so that the
        computer will understand what we say. A program that can pull this off
        is known as a compiler, a compiler usually comes with a text editor,
        suited for programming needs. The text file you use to create a .prg
        file, is knows as the source code. <span style="mso-tab-count:1">&nbsp; </span>Let’s
        take another example, this time let’s assume we wrote this source
        code.<o:p>
        </o:p><o:p>
        &nbsp;</font></span></p>
        <div align="center">
          <table border="0" width="75%">
            <tr>
 
              <td width="100%">
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">Put #1 at $20<o:p>
        </o:p></font></span></p>
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">Put
        #0 at $21<o:p>
        </o:p></font></span></p>
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">Put
        #200 at $22<o:p>
        </o:p></font></span></p>
 
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">Put
        #4 at $200<o:p>
        </o:p></font></span></p>
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">Put
        #15 at $201<o:p>
        </o:p></font></span></p>
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">Put
        #8 at $202<o:p>
        </o:p></font></span></p>
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">Put
        #0 at $203<o:p>
 
        </o:p></font></span></p>
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">Put
        #255 at $204<o:p>
        </o:p></font></span></p>
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">Initialize
        monitor<o:p>
        &nbsp;</font></span></p>
              </td>
            </tr>
          </table>
 
        </div>
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font size="1" face="Verdana"><span style="mso-tab-count:1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </span>Now, as you can guess, # stands for value, a numerical value in
        our case, and $ stands for address. Now, if we compile this source code,
        that is, translate it to a format the computer understands, we will get
        a .prg file. When we double click on that file, the computer will do
        what it says above; the different values will be loaded into the
        different addresses, creating the memory profile given above. The last
        line “Initialize monitor” is for engaging the monitor. When the
        monitor is engaged, the Atari knows that it should look at $20, $21 and
        $22 to gather the data needed. So instead of “Initialize monitor”,
        perhaps we could’ve written<o:p>
        </o:p>
        </font></span></p>
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFFF" size="1" face="Verdana">&nbsp;<o:p>
        &nbsp;
        </font></span></p>
 
        <div align="center">
          <table border="0" width="75%">
            <tr>
              <td width="100%">
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">Activate $20<o:p>
        </o:p>
        </font></span></p>
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">Activate $21<o:p>
 
        </o:p>
        </font></span></p>
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font color="#FFFFCC" size="1" face="Verdana">Activate $22<o:p>
        &nbsp;</font></span></p>
              </td>
            </tr>
          </table>
        </div>
 
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none">&nbsp;</p>
        <p class="MsoNormal" style="text-align:justify;mso-pagination:none;mso-layout-grid-align:
none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font size="1" face="Verdana"><span style="mso-tab-count:1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </span>Because what we really want to do is to make the information on
        these addresses happen; we want the computer to process the information
        given. This is long and clumsy however, and the line “Initialize
        monitor”, or whatever you might call it, is far simpler. <o:p>
        </o:p>
        </font></span></p>
        <p class="MsoNormal" style="text-align:justify;text-indent:65.2pt;mso-pagination:
none;mso-layout-grid-align:none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font size="1" face="Verdana">The
        computer, internally, understands nothing but 1’s and 0’s, all text
        and numbers I have given above is for human understanding (more on
        binary understanding later). Also, none of the commands or memory
        addresses have any significance for the Atari, they are examples only. <o:p>
        </o:p>
        </font></span></p>
 
        <p class="MsoNormal" style="text-align:justify;text-indent:65.2pt;mso-pagination:
none;mso-layout-grid-align:none;text-autospace:none"><span lang="EN-GB" style="mso-ansi-language:EN-GB"><font size="1" face="Verdana">OK,
        theory lesson over. Hope I haven’t scared you away. In the next
        tutorial we will get into how to actually make a .prg file. It won’t
        do much, but at least you will get to see your code in action.
        </font></span></p>
        <p class="MsoNormal" style="text-align:justify;text-indent:65.2pt;mso-pagination:
none;mso-layout-grid-align:none;text-autospace:none">&nbsp;</p>
      </center></td>
    </tr>
    <tr>
      <td width="100%">
        <p><font size="1" face="Verdana" color="#FFFFFF">Warrior Munk of poSTmortem, 2002-03-31</font></p>
      </td>
 
    </tr>
    <tr>
      <td width="100%">
      <table width="100%" align=center bgcolor="#CC0000" cellspacing="1" cellpadding="0">
<tr>
<td>
<table  cellspacing="0" cellpadding="0" width="100%">
<tr>
<td>
 
        <p align="justify">
 
        <font size="1" face="Verdana"> <i> “Conan, what is best in life?”&nbsp;<br>
 
“To crush your enemies, see them driven before you, and to  hear the lamentations of their women.”&nbsp;</i></font></p>
        <p><font size="1" face="Verdana" color="#FFFFFF"><i>
        Conan the Barbarian</i></font>&nbsp;</p>

Revision as of 19:04, 30 January 2006

The Atari ST M68000 tutorial part 1 – on the theory behind programming

Hi everybody! This is Warrior Munk of poSTmortem (aka Andreas Wahlin) writing. Me and Aldebaran (aka Lars Lindblad) have just started this little project of ours; the demo group poSTmortem. As a first step towards actually doing something with the ST, we thought that writing a tutorial might be good. In this way, we can teach ourselves and you (whoever is listening). This tutorial is aimed at people who, like ourselves, want to learn to code assembler for the Atari ST. What? You say, this is the year 2002, why on earth would you want to learn how to code, for one thing, assembler, and assembler for the Atari? You must be crazy. Well, you might think the Atari is dead, but we say it survived itself, it has risen again, it is; poSTmortem (totally lame, right?). You don’t need any programming skills, although it might help since learning to code from assembly language is probably quite suicidal in a pedagogical view. I’ll try to cover the basics of general programming and setting you up in this tutorial, and in part two we will do some rather simple program to get things started. I will however, assume that you have some basic skills in Atari management, like file copying and so on. Also, I will assume you have a real Atari, emulating might work fine, but nothing beats the real thing. What is programming? Programming is the art and science of making the computer do what you want it to do. BTW, programming is also known as coding, I will use these two terms somewhat mixed probably. So, how do we do that? By telling the computer what to do, and then do it. Since you don’t have shit for brains, you will know that when you double click on a .prg file (known as .exe files on a PC), the computer will do stuff, like running a game. So, what if we could create our own .prg files… Yes, we can do that, this is where you’ll learn how! Every computer has a memory, this is where the number on your Atari is derived from, 520 have half a Meg (short for Mega Byte) of ram, and 1040’s have one Meg. Your usual PC these days have about 256 megs of ram, Bill Gates once said “nobody needs more than 640 K ram (about the memory amount of an Atari 520). If these numbers confuse you, do not worry, they aren’t important right now. The memory is very temporary; it gets wiped out every time you turn off your Atari, unlike diskettes (thank God). When you run a program, the computer loads the program into memory, and then executes (follows the instructions given by the program). ¬Every area of the memory has an address, so you know where you are. You can think of these addresses as normal street addresses, but perhaps it would be better if you thought of them more as page indexes in a book. Every page is filled with information on how to act. So, let’s assume that we have a monitor capable of displaying one of two colours, either black or white. The memory address $20 holds this colour. 1 means black, 0 white. If memory looks like this, we get a black screen. Address Value … $19 12 $20 1 $21 67 … (each address can hold a number between 0 and 255)

To understand a bit better about memory, because this is very important, we expand our little example. There is an area in the memory reserved for the user. This area is just for information storage, and does not affect the hardware. Let’s say that the monitor is capable of displaying text as well, the text is also either black or white as previously stated, and the information on the text colour is to be found at $21. Further, the address $22 holds a pointer to the text to be displayed. Pointer? Argh! Well, it’s really quite easy, a pointer is a reference to another part of the memory. Show first, talk later.

Memorie Value ... $19 12 $20 1 $21 0 $22 101 … $101 Hello World! $200 DOH! …

In this example, the “user memory” begins after position $100. All address positions $0 - $100 does something with the hardware in some way, but after that, it’s just storage space. With the above values, and given our premise, the text “Hello World!”, will be displayed in white text on black background. Let’s say we were to change the values to this instead.

Memory Value … $19 12 $20 1 $21 1 $22 200 … $101 Hello World! $200 DOH! …

(changed values at $21 and $22)

We would get the text “DOH!” written in black text on black background, not to clever. Therefore, a pointer is a reference to another place. Because $22 only can hold a number of 0 - 255, the text “Hello World!” would never fit, so instead we point to an area in the user memory, which can hold much more than just a number between 0 - 255. Are you beginning to grasp how computers work? If you have an enquiring mind, and I hope you do, you’ll probably wonder why the addresses $0 - $100 only hold numbers, while it seems that addresses $101 - … can hold letters. The answer is, they actually can’t hold any letters. In addition, it doesn’t quite look like I’ve shown you either. This might get somewhat complicated, hold your hat and don’t cry if you don’t get it. Just read it, let it go, meditate a bit and you’ll reach enlightenment.

           The addresses $101 and $200 actually only hold numbers, but the computer have a decode key so that each number can be decoded to a letter. Let’s say that 

! = 0 A = 1 B = 2 C = 3 D = 4 … and so on, then it really looks like this

Memory Value Meaning $200 3 D $201 14 O $202 7 H $203 0 ! …

           So you see, there are just numbers, also, as I said, each address can only hold a number between 0 - 255, meaning that each letter is held in one address. But but but but, why doesn’t more stuff get displayed as text? Why does it stop at $203? The memory must continue after that surely. Let’s look at this memory setup. 
   

Memory Value Meaning $200 4 D $201 15 O $202 8 H $203 0 ! $204 15 O $205 4 D …

           The text on the screen would display as “DOH!OD” and probably much more (the rest of the memory in fact). Well, here we use a control number, let’s say that the computer knows that when in reaches the number 255 the text ends there. If memory looks like this 
             

Memory Value Meaning ... $19 12 something $20 1 background colour $21 0 text colour $22 200 pointer to text on screen … $200 4 D $201 15 O $202 8 H $203 0 ! $204 255 end of text $205 4 D

           the text “DOH!” would be displayed in white on black background. When the computer reaches $204, it sees the number 255, which means stop displaying text, so the letter (or rather, value) at $205 and following addresses will not be displayed. Like I said, this may be a bit advanced, don’t panic. We will get much more concrete in tutorial 2. I just want you to have a theoretical basis so you know what’s what and so you can refer back to this. Just let this sink into your unconscious, when the time is right and you have correct understanding, it will surface and you will get it. 
           Now, for last theory lesson; how do you actually make something happen? As we know, there are .prg files that make stuff happen. With our above knowledge, we know that they affect memory. We can write down simple commands in a text file, and then have that text file translated into the .prg format, so that the computer will understand what we say. A program that can pull this off is known as a compiler, a compiler usually comes with a text editor, suited for programming needs. The text file you use to create a .prg file, is knows as the source code.   Let’s take another example, this time let’s assume we wrote this source code.  

Put #1 at $20 Put #0 at $21 Put #200 at $22 Put #4 at $200 Put #15 at $201 Put #8 at $202 Put #0 at $203 Put #255 at $204 Initialize monitor

           Now, as you can guess, # stands for value, a numerical value in our case, and $ stands for address. Now, if we compile this source code, that is, translate it to a format the computer understands, we will get a .prg file. When we double click on that file, the computer will do what it says above; the different values will be loaded into the different addresses, creating the memory profile given above. The last line “Initialize monitor” is for engaging the monitor. When the monitor is engaged, the Atari knows that it should look at $20, $21 and $22 to gather the data needed. So instead of “Initialize monitor”, perhaps we could’ve written 
   

Activate $20 Activate $21 Activate $22

           Because what we really want to do is to make the information on these addresses happen; we want the computer to process the information given. This is long and clumsy however, and the line “Initialize monitor”, or whatever you might call it, is far simpler. 

The computer, internally, understands nothing but 1’s and 0’s, all text and numbers I have given above is for human understanding (more on binary understanding later). Also, none of the commands or memory addresses have any significance for the Atari, they are examples only. OK, theory lesson over. Hope I haven’t scared you away. In the next tutorial we will get into how to actually make a .prg file. It won’t do much, but at least you will get to see your code in action.

Warrior Munk of poSTmortem, 2002-03-31 “Conan, what is best in life?” “To crush your enemies, see them driven before you, and to hear the lamentations of their women.” Conan the Barbarian


Last edited 2002-04-07