COURS 2.TXT: Difference between revisions

From Atari Wiki
Jump to navigation Jump to search
(Olivier.jan moved page COURS 2.TXT to COURS 2.TXT/fr)
Tag: New redirect
 
m (Removed redirect to COURS 2.TXT/fr)
Tag: Removed redirect
Line 1: Line 1:
  +
{{Languages|COURS2.TXT}}
#REDIRECT [[COURS 2.TXT/fr]]
 
  +
<pre>
  +
******************************************************************
  +
* *
  +
* 68000 ASSEMBLY COURSE ON ATARI ST *
  +
* *
  +
* by The Ferocious Rabbit (from 44E) *
  +
* *
  +
* Lesson Number 2 *
  +
* *
  +
******************************************************************
  +
  +
THE 'MAGIC' NUMBERS
  +
  +
Let's first understand, in a simple way, how a computer works by
  +
placing ourselves in the following situation: we have to provide
  +
messages to a person we are separated from (for example, nightly
  +
messages between distant people).
  +
  +
We have a flashlight that we can turn on or off, that's all. So,
  +
we can give 2 messages: 1) the flashlight is off (for example,
  +
everything is fine) 2) the flashlight is on (for example, here
  +
come the cops!)
  +
  +
Let's delve into the 2 states of the flashlight:
  +
On Off
  +
  +
which translates to: current no current
  +
or: Current? YES NO
  +
  +
Current value? 1 0
  +
  +
The tests will be noted as 0 or 1 depending on the on or off state
  +
of the flashlight.
  +
  +
As we are rich, we buy a second flashlight.
  +
We now have 4 message possibilities:
  +
  +
FLASHLIGHT 1 FLASHLIGHT 2
  +
  +
Off Off
  +
On Off
  +
Off On
  +
On On
  +
  +
By counting with 3, 4, 5, 6 ... flashlights, we realize that it is
  +
possible to find a simple relationship between the number of
  +
flashlights and the number of possibilities.
  +
  +
Number of possibilities = 2 to the power of the number of flashlights.
  +
  +
So, we get the following table. The remarks are just there to give
  +
a hint!
  +
  +
Flashlights Possibilities Remarks
  +
1 2
  +
2 4
  +
3 8 There are 8-bit computers...
  +
4 16 and 16-bit ones...
  +
5 32 The ST is a 16/32 bits
  +
6 64 Amstrad CPC... 64!!
  +
7 128 or Commodore 128?
  +
8 256 In computing, the character encoding
  +
(letters, numbers, etc., using ASCII
  +
code) allows for 256 characters!
  +
9 512 A 520 has 512 KB of memory and
  +
Amstrad sells a PC1 512.
  +
10 1024 The memory size of my 1040!
  +
11 2048 That of my brother's Mega 2.
  +
12 4096 That of a Mega 4. Also the number of
  +
displayable colors with an Amiga.
  +
etc...
  +
16 65536 In GFA, a table cannot have more than
  +
65536 elements.
  +
  +
If my 4 flashlights are off (0000), I am at possibility 0. If they
  +
are all on (1111), I am at possibility 15 (because from 0 to 15
  +
adds up to 16), so 0000 --> 0 and 1111 --> 15.
  +
  +
So, I have a book of 16 pages giving the possibilities of the 16
  +
possible lightings, and my correspondent has the same. How do I
  +
send him the message from page 13?
  +
  +
Since the smallest digit is on the right (digits are read in
  +
hundreds, tens, units order), let's set up the flashlights.
  +
  +
Flashlight number: 4 3 2 1
  +
a) I have only one flashlight (the 1), and it's on, so I get the
  +
value 1. (I can only get 0 or 1)
  +
  +
b) I have 2 flashlights (1 and 2), both on, so I get the 4th
  +
possibility. So, I get the value 3 (since I count values 0, 1, 2,
  +
and 3, which adds up to 4). Since flashlight 1 has a maximum value
  +
of 1, I deduce that flashlight 2 alone has a maximum value of 2.
  +
  +
In fact:
  +
Flashlight 1 on --> value 1
  +
Flashlight 2 on --> value 2
  +
  +
Therefore, both on together --> value 3 = 4 possibilities.
  +
  +
Flashlight number 4 3 2 1
  +
'increase' 8 4 2 1
  +
  +
To send the message 13, I need to turn on flashlight 4 (value 8),
  +
flashlight 3 (value 4), and flashlight 1 (value 1).
  +
Flashlight 4 3 2 1
  +
State 1 1 0 1
  +
Value 8 + 4 + 0 + 1 = 13
  +
  +
We are therefore counting in binary.
  +
  +
In decimal: "dec" means 10, as a digit can take 10 values (from 0
  +
to 9).
  +
  +
In binary: "bi" means two, as each digit can only take 2 values
  +
(0 or 1).
  +
  +
Computing is an Anglo-Saxon domain. A 'binary digit' in English is
  +
called a 'bit'! A bit can be either 0 or 1. It is the smallest
  +
computing unit because the correspondent we are sending messages
  +
to is actually a computer. Instead of turning on flashlights, we
  +
apply current to a wire or not. So, an 8-bit computer has 8 wires
  +
where we can apply or not apply current!
  +
  +
To send messages, we will prepare flashlights with small switches,
  +
and when our flashlights are ready, we will flip the main switch
  +
to send the current and light up the planned flashlights.
  +
  +
Through

Revision as of 09:54, 16 December 2023

     ******************************************************************
   *                                                                *
   *             68000 ASSEMBLY COURSE ON ATARI ST                  *
   *                                                                *
   *                 by The Ferocious Rabbit (from 44E)             *
   *                                                                *
   *                          Lesson Number 2                       *
   *                                                                *
   ******************************************************************

   THE 'MAGIC' NUMBERS

   Let's first understand, in a simple way, how a computer works by
   placing ourselves in the following situation: we have to provide
   messages to a person we are separated from (for example, nightly
   messages between distant people).

   We have a flashlight that we can turn on or off, that's all. So,
   we can give 2 messages: 1) the flashlight is off (for example,
   everything is fine) 2) the flashlight is on (for example, here
   come the cops!)

   Let's delve into the 2 states of the flashlight:
                         On                       Off

   which translates to:  current                  no current
   or: Current?            YES                       NO

   Current value?           1                         0

   The tests will be noted as 0 or 1 depending on the on or off state
   of the flashlight.

   As we are rich, we buy a second flashlight.
   We now have 4 message possibilities:

               FLASHLIGHT 1       FLASHLIGHT 2

              Off                 Off
              On                  Off
              Off                 On
              On                  On

   By counting with 3, 4, 5, 6 ... flashlights, we realize that it is
   possible to find a simple relationship between the number of
   flashlights and the number of possibilities.

   Number of possibilities = 2 to the power of the number of flashlights.

   So, we get the following table. The remarks are just there to give
   a hint!

   Flashlights  Possibilities                Remarks
   1            2
   2            4
   3            8              There are 8-bit computers...
   4            16             and 16-bit ones...
   5            32             The ST is a 16/32 bits
   6            64             Amstrad CPC... 64!!
   7            128            or Commodore 128?
   8            256            In computing, the character encoding
                               (letters, numbers, etc., using ASCII
                               code) allows for 256 characters!
   9            512            A 520 has 512 KB of memory and
                               Amstrad sells a PC1 512.
   10           1024           The memory size of my 1040!
   11           2048           That of my brother's Mega 2.
   12           4096           That of a Mega 4. Also the number of
                               displayable colors with an Amiga.
   etc...
   16           65536          In GFA, a table cannot have more than
                               65536 elements.

   If my 4 flashlights are off (0000), I am at possibility 0. If they
   are all on (1111), I am at possibility 15 (because from 0 to 15
   adds up to 16), so 0000 --> 0 and 1111 --> 15.

   So, I have a book of 16 pages giving the possibilities of the 16
   possible lightings, and my correspondent has the same. How do I
   send him the message from page 13?

   Since the smallest digit is on the right (digits are read in
   hundreds, tens, units order), let's set up the flashlights.

   Flashlight number:  4       3       2        1
   a) I have only one flashlight (the 1), and it's on, so I get the
   value 1. (I can only get 0 or 1)

   b) I have 2 flashlights (1 and 2), both on, so I get the 4th
   possibility. So, I get the value 3 (since I count values 0, 1, 2,
   and 3, which adds up to 4). Since flashlight 1 has a maximum value
   of 1, I deduce that flashlight 2 alone has a maximum value of 2.

   In fact:
                   Flashlight 1 on --> value 1
                   Flashlight 2 on --> value 2

   Therefore, both on together --> value 3 = 4 possibilities.

   Flashlight number     4             3            2            1
   'increase'            8             4            2            1

   To send the message 13, I need to turn on flashlight 4 (value 8),
   flashlight 3 (value 4), and flashlight 1 (value 1).
   Flashlight          4      3         2       1
   State               1      1         0       1
   Value              8  +   4    +    0   +   1 = 13

   We are therefore counting in binary.

   In decimal: "dec" means 10, as a digit can take 10 values (from 0
   to 9).

   In binary: "bi" means two, as each digit can only take 2 values
   (0 or 1).

   Computing is an Anglo-Saxon domain. A 'binary digit' in English is
   called a 'bit'! A bit can be either 0 or 1. It is the smallest
   computing unit because the correspondent we are sending messages
   to is actually a computer. Instead of turning on flashlights, we
   apply current to a wire or not. So, an 8-bit computer has 8 wires
   where we can apply or not apply current!

   To send messages, we will prepare flashlights with small switches,
   and when our flashlights are ready, we will flip the main switch
   to send the current and light up the planned flashlights.

   Through