Pl NR: Difference between revisions

From Atari Wiki
Jump to navigation Jump to search
No edit summary
 
mNo edit summary
 
(13 intermediate revisions by 3 users not shown)
Line 1: Line 1:
  +
{{Languages|Pl NR}}
 
<pre>
 
<pre>
   
   
 
------------------------------
 
------------------------------
CHAPITRE nr° 2:
+
CHAPTER number 2:
 
 
* PREMIERS PAS EN ASSEMBLEUR *
+
* FIRST STEPS IN ASSEMBLY *
 
 
 
------------------------------
 
------------------------------
Line 11: Line 12:
   
   
*** UTILISATION LOGICIELLE DE L'ASSEMBLEUR ***
+
*** SOFTWARE USE OF THE ASSEMBLER ***
 
----------------------------------------------
 
----------------------------------------------
   
  +
- As we saw in the previous chapter, programming in assembly language is only possible with: an EDITOR, an ASSEMBLER, and a LINKER.
- Comme nous l'avons vu dans le chapitre pr‚c‚dent, programmer en
 
assembleur n'est possible qu'avec : un EDITEUR, un ASSEMBLEUR et
 
un LINKER.
 
   
1) l'EDITEUR: .C'est l'EDITEUR qui permet la saisie de votre listing:
+
1) The EDITOR: .It is the EDITOR that allows you to enter your listing:
 
----------
 
----------
Vous ‚crirez votre programme grƒce aux fonctions de
+
You will write your program using the functions of the editor. The editor will save and load your listings.
l'‚diteur. L'‚diteur sauvera et chargera vos listings.
 
   
Les fichiers sauv‚s sont des fichiers ASCII (tout com-
+
The saved files are ASCII files (like the files in this digital book) and can be modified at will with the editor.
me les fichiers de ce livre digital) et peuvent ètre
 
modifi‚s à volont‚ avec l'‚diteur.
 
   
Un tel fichier est nomm‚ CODE SOURCE.
+
Such a file is called SOURCE CODE.
   
  +
The functions of the editor vary with the utility (DEVPAC, METACOMCO, PROFIMAT...) and simplify the input of the text (listing).
Les fonctions de l'‚diteur varient avec l'utilitaire
 
(DEVPAC,METACOMCO,PROFIMAT...) et simplifient l'entr‚e
 
du texte (listing).
 
   
.Un fichier issu d'un ‚diteur ne peut pas être execut‚!
+
.A file from an editor cannot be executed!
   
Il faudra d'abord l'ASSEMBLER puis le LINKER.
+
It will first have to be ASSEMBLED and then LINKED.
   
   
  +
2) The ASSEMBLER .ASSEMBLY constitutes the second step:
2) l'ASSEMBLEUR .l'ASSEMBLAGE constitue la deuxième ‚tape:
 
 
------------
 
------------
  +
The ASCII codes (text) of the listing are translated by the Assembler and are converted (encoded) into BINARY (binary is recognized directly by the computer, unlike ASCII text)
Les codes ASCII (texte) du listing sonts traduits par
 
l'Assembleur et sont convertis (cod‚s) en BINAIRE (le
 
binaire est reconnu directement par l'ordinateur,con-
 
trairement au texte ASCII)
 
   
  +
Once processed (Assembled), the file (listing) is saved on the diskette in the format of a BINARY file called OBJECT CODE.
Le fichier (listing) une fois trait‚ (Assembl‚) est
 
sauv‚ sur la disquette sous le format d'un fichier
 
en BINAIRE appel‚ CODE OBJET.
 
   
3) le LINKER .l'EDITION DE LIENS est la dernière ‚tape:
+
3) The LINKER .LINK EDITION is the last step:
 
---------
 
---------
Le CODE OBJET est charg‚ et le LINKER intègrera les
+
The OBJECT CODE is loaded and the LINKER will integrate the MACRO INSTRUCTIONS that make up the library if the source file requires it. -->
MACROS INSTRUCTIONS qui constituent la bibliothèque
 
si le fichier SOURCE le demandait. -->
 
   
 
-------------
 
-------------
  +
Let me explain:
Je m'explique:
 
 
--------------
 
--------------
.En assembleur vous pouvez cre‚r des MACRO-INSTRUCTIONS
+
.In assembly language, you can create MACRO-INSTRUCTIONS
(voir chapitre pr‚c‚dent).
+
(see previous chapter).
   
.Une MACRO n'est rien d'autre qu'une nouvelle instruction (param‚trable)
+
.A MACRO is nothing more than a new instruction (parametrizable)
qui sera incluse par le LINKER chaque fois qu'il rencontrera son nom
+
which will be included by the LINKER every time it encounters its name
dans le CODE OBJET.
+
in the OBJECT CODE.
   
  +
An example:
Un exp:
 
 
-------
 
-------
.Vous cr‚ez une MACRO qui affiche 'SALUT' sur l'‚cran:
+
.You create a MACRO that displays 'HELLO' on the screen:
   
  +
This MACRO actually delimits a PROGRAM whose function
Cette MACRO d‚limite en r‚alit‚ un PROGRAMME dont la fonction
 
est d'afficher 'SALUT' sur l'‚cran et vous la nommez 'ECRIS':
+
is to display 'HELLO' on the screen and you name it 'WRITE':
   
d‚but de la Macro
+
Beginning of the Macro
   
ECRIS .
+
WRITE .
 
.
 
.
. le listing qui permet d'afficher
+
. the listing that allows to display
. 'SALUT' sur l'‚cran
+
. 'HELLO' on the screen
 
.
 
.
   
Fin de la Macro
+
End of the Macro
 
 
Chaque fois que le LINKER rencontrera 'ECRIS' (le nom de la MACRO) ,
+
Each time the LINKER encounters 'WRITE' (the name of the MACRO),
  +
in the OBJECT CODE, it will rewrite the 'WRITE' program segment in place of the MACRO.
dans le CODE OBJET, il re‚crira la portion de programme 'ECRIS' à la
 
place de la MACRO.
 
   
.Une MACRO n'est donc pas un sous-programme, elle permet juste une
+
.A MACRO is therefore not a subroutine, it only allows for better
une meilleur lisibilit‚ dans le listing.
+
readability in the listing.
   
.Une macro sera re‚crite entièrement à chaque appel: On perd donc
+
.A macro will be completely rewritten each time: so we lose
un peu plus de MEMOIRE , mais c'est bien plus rapide qu'un sous-
+
a little bit more memory, but it is much faster than a subroutine.
programme.
 
   
.Les Macros permettent une meilleur lisibilit‚ du listing puisque
+
.Macros allow for better readability of the listing as
Vous n'avez plus à taper la ROUTINE correspondant au nom de la
+
You no longer have to type the ROUTINE corresponding to the name of the
Macro, le Linker s'en charge.
+
Macro, the Linker takes care of that.
   
.Vous pouvez donc vous cr‚er une BIBLIOTHEQUE de MACROS ( c.à.d. des
+
.You can therefore create a LIBRARY of MACROS (i.e. files
  +
defining MACROS) to call when you need them in your listing...
fichiers d‚finissant des MACROS ) pour les appeler quand vous en
 
aurrez besoin dans votre listing...
 
   
Le LINKER s'occupe de charger les MACROS utilis‚es dans le listing
+
The LINKER takes care of loading the MACROS used in the listing
(si le listing en contient...) et de les re‚crires entièrement.
+
(if the listing contains them...) and rewriting them completely.
   
Il suffira d'indiquer (au d‚but du listing) le nom du fichier qui
+
It will be sufficient to indicate (at the beginning of the listing) the name of the file which
contient les MACROS utilis‚es, ou de d‚finir les MACROS utilis‚es
+
contains the MACROS used, or to define the MACROS used
au d‚but du listing.
+
at the beginning of the listing.
(NOUS VERRONS COMMENT EN DETAIL ...)
+
(WE WILL SEE IN DETAIL...)
   
.Nous,nous cr‚erons des MACROS pour les fonctions du GEM,de l'XBIOS,
+
.We, we will create MACROS for the functions of GEM, XBIOS,
  +
BIOS and VDI (MACROS that handle calling the desired functions by passing the necessary parameters for speed and user-friendliness)
du BIOS et du VDI ( Des MACROS qui se chargent d'appeler les fonc-
 
tions d‚sir‚es en passant les paramètres n‚cessaires pour plus de
 
rapidit‚ et de convivialit‚ )
 
   
 
--------------
 
--------------
   
.le LINKER cr‚era aussi la PAGE DE BASE, qui contient
+
.The LINKER will also create the BASE PAGE, which contains
  +
information about the program essential for the operating system to be able to load and execute
des renseignements sur le prg indispensables au sys-
 
tème d'exploitation pour pouvoir charger et executer
+
the LINKED program.
le prg LINKE.
+
This is why LINKAGE is essential even if
Voilà pourquoi le LINKAGE est indispenssable mème si
+
the listing does not contain Macros.
le listing ne contient pas de Macros.
 
 
(Je d‚taillerais quand je parlerais du GEMDOS)
 
   
  +
(I will detail when I talk about GEMDOS)
   
.Le fichier ainsi obtenu sera sauv‚ et pourra ètre
 
execut‚.
 
   
  +
.The resulting file will be saved and can be
  +
executed.
   
   
  +
RESUME:
 
  +
SUMMARY:
 
------
 
------
* EDITEUR * * ASSEMBLEUR * * LINKER *
+
* EDITOR * * ASSEMBLER * * LINKER *
   
|listing| -------> |code objet| -------> |prg executable|
+
|listing| -------> |object code| -------> |executable prg|
   
   
Line 141: Line 122:
   
   
*** QUELQUES NOTIONS ELEMENTAIRES ***
+
*** SOME BASIC NOTIONS ***
 
-------------------------------------
 
-------------------------------------
   
  +
Here are some VERY IMPORTANT notions:
Voilà quelques notions TRES IMPORTANTES:
 
   
1) le BINAIRE:
+
1) BINARY:
 
-----------
 
-----------
. Habituellement, pour calculer, on utilise un système d‚cimal,
+
. Usually, for calculations, we use a decimal system,
c.à.d. que ce système est compos‚ de 10 chiffres: 0,1,2,3,4,5,6,7,8,9
+
i.e. this system is composed of 10 digits: 0,1,2,3,4,5,6,7,8,9
:C'est une BASE de 10.
+
:This is a BASE of 10.
   
  +
If we want to express a set whose quantity exceeds 9: we increase
Si on d‚sire exprimmer un ensemble dont la quantit‚ d‚passe 9: on aug-
 
mente le chiffre d'une unit‚ et on obtient un nombre:10,11,12,13,14...
+
the digit by one unit and we obtain a number:10,11,12,13,14...
   
.Le système BINAIRE (ou de BASE 2),est compos‚ de 2 chiffres: 0 et 1
+
.The BINARY system (or BASE 2), consists of 2 digits: 0 and 1
   
  +
Thus, if we want to express a set whose quantity exceeds 1
Ainsi, si on veut exprimmer un ensemble dont la quantit‚ d‚passe 1
 
( c.à.d. >1 en système d‚cimal !! ) on augmente d'une unit‚.
+
(i.e. >1 in decimal system!!) we increase by one unit.
   
  +
Therefore:
Donc:
 
Voilà comment on compte en BINAIRE:0,1,10,11,100,101,111,1000,1001,1011...
+
This is how we count in BINARY:0,1,10,11,100,101,111,1000,1001,1011...
   
  +
.We will assume that each component of the computer's memory is represented
.On SUPPOSERA que toute composante de la m‚moire de l'ordi est repr‚sent‚e
 
(ou cod‚e) en BINaire.
+
(or coded) in BINARY.
   
  +
.The 0 and 1 of the BINARY system present in the components of
.On nomme le 0 et le 1 du système BINaire pr‚sent dans les composantes de
 
  +
the computer's structure are called BITS.
la structure de l'ordi par BIT.
 
   
.Un BIT peut ètre nul (ou ‚teint):0 OU activ‚ (ou encore allum‚):1
+
.A BIT can be zero (or off):0 OR activated (or on):1
 
--
 
--
.Le BIT est donc la plus petite structure modifiable et reconnaissable
+
A BIT is the smallest modifiable and recognizable structure
  +
by the computer.
par l'ordi.
 
   
.On d‚finit par OCTET un groupe de 8 BITS. (L'OCTET est aussi appel‚ BYTE
+
.We define a group of 8 BITS as an BYTE (The BYTE is also called BYTE
en Anglais, ne le confondez pas avec 'bit' !)
+
in English, do not confuse it with 'bit'!)
   
.On d‚finit par MOT un groupe de 2 OCTETS (donc de 16 BITS)
+
We define a group of 2 BYTES as a WORD (so 16 BITS)
   
.On d‚finit par LONG MOT un groupe de 2 MOTS (donc de 4 OCTETS ou 32 BITS)
+
We define a group of 2 WORDS as a LONG WORD (so 4 BYTES or 32 BITS)
   
  +
These groupings are arbitrary and deal with consecutive BITS
.Ces regroupements sont arbitraires et conscernent des BITS cons‚cutifs
 
(qui se suivent) en m‚moire.
+
(that follow each other) in memory.
   
CONSEQUENCES: Les composantes internes de l'ordi. peuvent être exprim‚es
+
CONSEQUENCES: The internal components of the computer can be expressed
------------ en BITS,OCTETS,MOTS ou LONGS MOTS.
+
------------ in BITS, BYTES, WORDS or LONG WORDS.
   
  +
SUMMARY:
RESUME:
 
 
-------
 
-------
- Un BIT prend soit la valeur 1 (activ‚) soit la valeur 0 (‚teind)
+
- A BIT takes on the value of either 1 (activated) or 0 (turned off)
 
---
 
---
- Un OCTET est un groupe de 8 BITS cons‚cutifs en m‚moire
+
- An BYTE is a group of 8 consecutive BITS in memory
 
-----
 
-----
- Un MOT est un groupe de 2 OCTETS cons‚cutifs en m‚moire
+
- A WORD is a group of 2 consecutive BYTES in memory
 
---
 
---
- Un LONG MOT est un groupe de 2 MOTS cons‚cutifs en m‚moire
+
- A LONG WORD is a group of 2 WORDS consecutive in memory
 
--------
 
--------
  +
To simplify, we could say that the computer's memory is composed
Pour sch‚matiser, on pourrait dire que la m‚moire de l'ordi. est compos‚e
 
  +
of a multitude of small boxes (BITS) that can take either 1 or 0 as values depending on the actions of the Microprocessor and can be grouped (arbitrarily) in the form of BYTES, WORDS or LONG WORDS.
d'une multitude de petites cases (BITS) pouvant prendre soit 1 soit 0 com-
 
me valeurs suivant les actions du Microprocesseur et pouvant ètres regrou-
 
p‚es (arbitrairement) sous la forme d'OCTETS, de MOTS ou de LONGS MOTS.
 
   
  +
EXAMPLE:
EXP:
 
--- { 0 est un BIT
+
--- { 0 is a BIT
extraits de { 01011101 est un OCTET, ou 8 BITS
+
excerpts from { 01011101 is a BYTE or 8 BITS
m‚moire { 0101110111010110 est un MOT, ou 16 BITS
+
memory { 0101110111010110 is a WORD or 16 BITS
{ 01011101110101101000100100101101 est un LONG MOT,ou 32 B
+
{ 01011101110101101000100100101101 is a LONG WORD or 32 B
   
   
2) L'HEXADECIMAL:
+
2) HEXADECIMAL:
 
-------------
 
-------------
.l'HEXADECIMAL est un système de BASE 16,les 16 composantes de ce système
+
.HEXADECIMAL is a BASE 16 system, the 16 components of this system
sont:0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
+
are:0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
   
Ainsi, pour exprimer un ensemble dont la quantit‚ d‚passe F (soit 16 en
+
Thus, to express a set whose quantity exceeds F (i.e. 16 in
BASE de 10), on change d'unit‚: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,10,11,12,
+
BASE 10), we change units: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,10,11,12,
 
,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22...
 
,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22...
   
  +
As you can see, the real utility of this system is that a large number is represented by a minimum of digits.
Comme vous pouvez le constater, la v‚ritable utilit‚ de ce système est
 
qu'un grand nombre est repr‚sent‚ par un minimum de chiffres.
 
   
  +
.An BYTE is represented in HEXA. by 2 digits
   
.Un OCTET est repr‚sent‚ en HEXA. par 2 chiffres
+
.A WORD is represented in HEXA. by 4 digits
   
.Un MOT est repr‚sent‚ en HEXA. par 4 chiffres
+
.A LONG WORD is represented in HEXA. by 8 digits
 
.Un LONG MOT est repr‚sent‚ en HEXA. par 8 chiffres
 
   
   
 
3) NOTATIONS:
 
3) NOTATIONS:
 
----------
 
----------
- Dans un listing en ASS. ,les chiffres cod‚s en BINaire sont
+
- In an ASM listing, digits coded in BINARY are
  +
represented with the prefix ' % ', those coded in
repr‚sent‚s avec le pr‚fixe ' % ', ceux cod‚s en HEXAd‚cimal avec
 
le pr‚fixe ' $ '.
+
HEXADECIMAL with the prefix ' $ '.
   
( L'utilisation de la BASE de 10 n'a pas besoin d'ètre indiqu‚e )
+
(The use of the BASE 10 does not need to be indicated)
   
  +
After Linking, all digits will automatically be coded in
Après le Linkage, tous les chiffres seront automatiquement cod‚s en
 
  +
Hexadecimal.
Hexad‚cimal.
 
   
EXP: %01001011 est un chiffre cod‚ en BINAIRE (et un OCTET)
+
EXAMPLE: %01001011 is a digit coded in BINARY (and an BYTE)
---- $1F0A est un chiffre cod‚ en HEXA. (et un MOT)
+
---- $1F0A is a digit coded in HEXA. (and a WORD)
101001 est un chiffre cod‚ en DECIMAL !
+
101001 is a digit coded in DECIMAL !
   
   
4) REMARQUES:
+
4) REMARKS:
 
----------
 
----------
- Le BIT le plus à gauche d'un OCTET,d'un MOT,d'un LONG MOT est appell‚
+
- The leftmost BIT of an BYTE, a WORD, a LONG WORD is called
M.S.B ( Most Significant Bit ) ou Bit de plus fort poids.
+
M.S.B (Most Significant Bit) or Most significant bit.
   
- C'est ce bit qui permet de signer ( positif / n‚gatif ) un nombre.
+
- This bit allows for signing (positive/negative) a number.
Il est activ‚ pour un nombre n‚gatif.
+
It is activated for a negative number.
   
- Il n'est utilis‚ que pour signer un nombre !
+
- It is only used to sign a number!
   
EXP: $FFFFFFFF est un L-M qui vaut -1 en d‚cimal
+
EXAMPLE: $FFFFFFFF is a L-W that is -1 in decimal
---- %1111111111111111 est un MOT qui vaut -1 en d‚cimal
+
---- %1111111111111111 is a WORD that is -1 in decimal
%11111110 est un OCTET qui vaut -2 en d‚cimal et
+
%11111110 is an BYTE that is -2 in decimal and
%00000010 en est un qui vaut 2:Pour inverser le signe de l'OCTET,
+
%00000010 is an BYTE that is 2: To invert the sign of the BYTE,
on a donc 'prolong‚' le 1 le plus à gauche jusqu'au MSB.
+
we have 'extended' the leftmost 1 to the MSB.
   
  +
:Very theoretical examples, don't panic, it's not really useful
:Exemples très th‚oriques, pas de panique,ce n'est pas vraiment utile
 
en pratique (et même franchement inutile, je vous rassure...) car il
+
in practice (and frankly useless, I assure you...) because there
existe des instructions qui font toutes sortes d'op‚rations sur les
+
are instructions that perform all sorts of operations on the
BITS,OCTETS,MOTS et L-M... (et personne ne vous oblige à travailler en
+
BITS, BYTES, WORDS and L-W... (and no one forces you to work in
système Binaire!)
+
Binary system!)
   
- D'après nos d‚finitions: (le MSB n'est utilis‚ que pour signer le bit,
+
- According to our definitions: (the MSB is only used to sign the bit,
l'octet,le mot ou le long-mot)
+
the BYTE, the word or the long word)
   
donc: * -2^7 ó OCTET < 2^7
+
therefore: * -2^7 ó BYTE < 2^7
-128 ó OCTET < 128
+
-128 ó BYTE < 128
   
* -2^15 ó MOT < 2^15
+
* -2^15 ó WORD < 2^15
-32768 ó MOT < 32768
+
-32768 ó WORD < 32768
   
* -2^31 ó L-M < 2^31
+
* -2^31 ó L-W < 2^31
-2147483648 ó L-M < 2147483648
+
-2147483648 ó L-W < 2147483648
   
  +
This, on the other hand, is something to remember: Overflows (BYTE too large...)
ça par contre, c'est à retenir: Les d‚bordements (OCTET trop grand...)
 
  +
cause errors.
provoquent des erreurs.
 
   
 
5) RECAPITULATION:
 
5) RECAPITULATION:
 
---------------
 
---------------
.Une composante de la structure de l'ordi. : REGISTRE,VARIABLE... (termes
+
.A component of the computer's structure: REGISTER,VARIABLE... (terms
expliqu‚s bientot) peut prendre la forme de BIT,OCTET,MOT ou LONG MOT.
+
to be explained soon) can take the form of a BIT, BYTE, WORD or LONG WORD.
   
En th‚orie... Nous ‚tudierons les exceptions:Le choix est plus limit‚ en
+
In theory... We will study the exceptions: The choice is more limited in
r‚alit‚.
+
reality.
   
   
CONSEQUENCES: .Une VARIABLE d‚finie en tant que MOT ne pourra donc
+
CONSEQUENCES: .A VARIABLE defined as a WORD cannot therefore
------------- pas avoir une valeur sup‚rieure à 32768. (par exp.)
+
------------- have a value greater than 32768. (for example)
   
NB: Cette variable ne pourra qu'ètre un Long Mot (Si sa
+
NB: This variable can only be a Long WORD (If its
--- valeur peut être contenue dans un L-M , sinon cela
+
--- value can be contained in a L-W , otherwise that
provoquerait une erreur puisque l'ordi ne reconnait
+
would cause an error since the computer does not recognize
pas de composante dont la quantit‚ depasse le L-M.)
+
any component whose quantity exceeds the L-W.)
(en th‚orie...)
+
(in theory...)
   
REMARQUES: .Une Variable pouvant ètre contenue dans un OCTET,
+
REMARKS: .A Variable that can be contained in an BYTE,
---------- donc dont la valeur est <128 peut aussi ètre con-
+
---------- so whose value is <128 can also be contained in a
tenue dans un MOT ou un L-M.
+
WORD or a L-W.
   
Mais il faut faire attention à ce que la composante
+
But it is necessary to pay attention to what the component
(ici la variable) puisse ètre d‚finie sur un MOT ou
+
(here the variable) can be defined as (BIT, BYTE,
un L-M (Dans cet exemple pr‚cis, c'est possible)
+
WORD, L-W...).
   
.Il faudra donc pour chaque composante de la structure
+
.Therefore, for each component of the computer's internal structure
interne de l'ordi. indiquer les diff‚rentes formes
+
indicate the different forms it can take (BIT, BYTE, WORD, L-W...).
qu'elle peut prendre (BIT,OCTET,MOT,L-M...).
 
   
Nous le feront avec pr‚cision.
+
We will do this with precision.
   
  +
This is why it is necessary to know the different forms that can
C'est pour cela qu'il faudra savoir les diff‚rentes formes que peut
 
prendre ce que nous utilisons pour programmer (Registres,variables...)
+
be used for programming (Registers, variables...)
et aussi par quoi sont d‚finit ces formes (BIT,OCTET...).
+
and also by what these forms are defined (BIT, BYTE...).
  +
This is why Assembler is very strict in its programming.
Voilà pourquoi l'Assembleur est très stricte dans sa programmation.
 
   
   
Line 323: Line 299:
 
----------
 
----------
   
Les ensembles tels que les OCTETS,MOTS,L-M sont compos‚s de BITS,ces BITS
+
Sets such as BYTES, WORDS, L-W are composed of BITS, these BITS
sont num‚rot‚s ainsi (dans les OCTETS,MOT,L-M,REGISTRES,VARIABLES...):
+
are numbered like this (in BYTES, WORD, L-W, REGISTERS, VARIABLES...):
   
De la DROITE vers la GAUCHE.
+
From RIGHT to LEFT.
   
 
31 30 . . . . . . 15 . . . 9 8 7 6 5 4 3 2 1 0
 
31 30 . . . . . . 15 . . . 9 8 7 6 5 4 3 2 1 0
 
[*][ ][.][.][.][ ][ ][ ][ ][*][.][.][.][ ][ ][*][ ][ ][ ][ ][ ][ ][*]
 
[*][ ][.][.][.][ ][ ][ ][ ][*][.][.][.][ ][ ][*][ ][ ][ ][ ][ ][ ][*]
   
- Un OCTET est donc num‚rot‚ de la droite vers la gauche de 0 à 7
+
- An BYTE is therefore numbered from right to left from 0 to 7
   
- Un MOT , de 0 à 15
+
- A WORD, from 0 to 15
   
- Un L-M , de 0 à 31
+
- A L-W, from 0 to 31
   
- Le BIT 0 est le bit de PLUS FAIBLE POIDS (ou LSB:Least significant Bit)
+
- Bit 0 is the MOST SIGNIFICANT BIT (or LSB: Least significant Bit)
   
- Le BIT 7 (15 pour un MOT,31 pour un L-M) est le bit de POIDS le plus
+
- Bit 7 (15 for a WORD, 31 for a L-W) is the MOST
FORT (ou MSB)
+
SIGNIFICANT BIT (or MSB)
   
AINSI:
+
THUS:
------ <----------- poids FORT
+
------ <----------- MOST SIGNIFICANT BITS
   
 
31<-- ...[][][][][][][][][][][][][]... -->0
 
31<-- ...[][][][][][][][][][][][][]... -->0
   
poids FAIBLE ---------->
+
LEAST SIGNIFICANT BITS ---------->
   
DONC: Un MOT est compos‚ de 2 OCTETS, un de poids FAIBLE (bits 0 à 7) et
+
THEREFORE: A WORD is composed of 2 BYTES, one of lower WEIGHT (bits 0 to 7) and
----- un de poids FORT: (bits 8 à 15)
+
----- one of higher WEIGHT: (bits 8 to 15)
   
Un L-M est compos‚ de 2 MOTS, un de poids FAIBLE (bits 0 à 15) et
+
A L-W is composed of 2 WORDS, one of lower WEIGHT (bits 0 to 15) and
un de poids FORT (bits 16 à 31)
+
one of higher WEIGHT (bits 16 to 31)
   
CETTE NOTION EST FONDAMENTALE
+
THIS NOTION IS FUNDAMENTAL
 
-----------------------------
 
-----------------------------
   
   
*** LA MEMOIRE ***
+
*** THE MEMORY ***
 
------------------
 
------------------
   
  +
- It is assumed that memory is a sequence of numbers coded in BINARY.
- On admettra que la m‚moire est une suite de nombres cod‚s en BINaire.
 
   
  +
:We now know that these numbers can be grouped into
:Nous savons maintenant que ces nombres peuvent ètres regroupp‚s en
 
OCTETS,MOTS,L-M.
+
BYTES, WORD, L-W.
   
  +
- Programming in assembly language allows you to change the contents
- La programmation en assembleur permet de changer le contenu
 
de la m‚moire.
+
of the memory.
   
  +
Memory is changed when the computer performs a task (a calculation,
.La m‚moire est chang‚e quand l'ordinateur effectue une tàche (un calcul,
 
une recherche quelconque...).
+
any search...).
  +
In this case, the computer takes care of organizing its memory, it is according to this order that one or other action takes place, the user therefore does not intervene: This is what happens at every moment, a computer is therefore never at rest (it checks if the disk is changed, erases
Dans ce cas, l'ordi. s'occupe d'ordonner sa m‚moire , c'est en fonction
 
  +
the screen fifty times a second).
de cet ordre que telle ou telle action se produit,l'utilisateur n'inter-
 
vient donc pas: C'est ce qui se passe à chaque instant, un ordinateur
 
n'est donc jamais au repos (il verifie si on change de disquette,efface
 
l'ecran cinquante fois par seconde).
 
   
  +
Memory of the computer can also be changed by the user, this is the
. La m‚moire de l'ordi. peut aussi être chang‚e par l'utilisateur,c'est le
 
  +
purpose of programming. The consequence is a planned state (programmed)
but de la programmation.La cons‚quence en est un ‚tat pr‚vu (programm‚)
 
de la m‚moire,donc telle ou telle action est effectu‚e.
+
of the memory, so such and such action is performed.
  +
This is possible by using instructions specific to the language used or by modifying directly a portion of the memory. This last operation is carried out very easily in ASM and with a precision at the level of the BIT.
Ceci est possible en utilisant des instructions propres au langage uti-
 
  +
We can therefore Move an BYTE, a WORD, a L-W (which we have defined)
lis‚ ou en modifiant directement une portion de la m‚moire.Cette derni-
 
  +
in the memory.(where it is possible...)
ère op‚ration s'effectue très facilement en ASSembleur et avec une pr‚-
 
cision de l'ordre du BIT.
 
On peut donc D‚placer un OCTET,un MOT, un L-M (qu'on aura pu d‚finir)
 
dans la m‚moire.(là o— c'est possible...)
 
   
  +
In order to navigate in the vast memory of our computer, we have divided the
Pour se rep‚rer dans la vaste m‚moire de notre ordi. , on a d‚coup‚ la
 
  +
memory and named each portion of the memory by an ADDRESS (like addresses on a street...)
m‚moire et on a nomm‚ chaque portion de la m‚moire par une ADRESSE (com-
 
me pour des Adresses dans une rue...)
 
   
Th‚oriquement, il serait possible de mettre un BIT,OCTET,MOT ou L-M à
+
Theoretically, it would be possible to place a BIT, BYTE, WORD or L-W at
n'importe quelle ADRESSE, mais en r‚alit‚ ceci n'est pas possible.
+
any ADDRESS, but in reality this is not possible.
   
- L'utilisateur n'a accès qu'à une partie de la m‚moire.
+
- The user only has access to a part of the memory.
(nous verrons laquelle)
+
(we will see which part)
   
  +
- It is necessary to take into account the parity and oddness of ADDRESSES:
- Il faut tenir compte de la parit‚ et de l'imparit‚ des ADRESSES:
 
  +
One cannot put anything at any address.
On ne peut pas mettre n'importe quoi à n'importe quelle adresse.
 
   
EN EFFET: Si on SCHEMATISE la structure de la m‚moire, celle-ci ressemble
+
IN FACT: If we SCHEMATICIZE the structure of memory, it looks like
  +
a band of limited length (start and end) and a WIDTH of 16 BITS, the different parts of which are numbered and addressed every 8 BITS. (at each BYTE)
-------- à une bande de longueur limit‚e (d‚but et fin) et d'une LAR-
 
GEUR de 16 BITS, dont les diff‚rentes parties sont num‚rot‚es
 
ADRESSEES) tout les 8 BITS. (à chaque OCTET)
 
   
   
Line 414: Line 381:
 
----- .| | |
 
----- .| | |
 
x-2|--------|--------|
 
x-2|--------|--------|
| x|10001011|--------| OCTET :10001011 à l'adresse x
+
| x|10001011|--------| BYTE: 10001011 at address x
| x+2|--------|10001101| OCTET :10001101 en x+3 octets
+
| x+2|--------|10001101| BYTE: 10001101 at x+3 BYTEs
 
| x+4|--------|--------|
 
| x+4|--------|--------|
| x+6|00101100|10110011| MOT :0010110010110011
+
| x+6|00101100|10110011| WORD: 0010110010110011
| .|--------|--------| en x+6 octets
+
| .|--------|--------| at x+6 BYTEs
 
\|/ .|--------|--------|
 
\|/ .|--------|--------|
' x+12|11011111|01110100| L-M :110111110111010001011011-
+
' x+12|11011111|01110100| L-W: 110111110111010001011011-
 
SENS des .|01011011|01110100| 01110100
 
SENS des .|01011011|01110100| 01110100
adresses .|--------|--------| en x+12 octets
+
adresses .|--------|--------| at x+12 BYTEs
 
CROISSANTES .|--------|--------|
 
CROISSANTES .|--------|--------|
----------- x+20|--------|-------1| BIT :1 à l'adresse x+21 octets
+
----------- x+20|--------|-------1| BIT: 1 at address x+21 BYTEs
 
| .|--------|--------|
 
| .|--------|--------|
 
| .|OCT FORT| FAIBLE |
 
| .|OCT FORT| FAIBLE |
Line 433: Line 400:
   
 
+-------+
 
+-------+
|MEMOIRE| : ( Exemple d'organisation )
+
|MEMORY |: (Example of organization)
 
+-------+
 
+-------+
   
   
  +
- Take a good look at this example, it is very easy to understand and this scheme
- Observez bien cet exemple, il est très simple à comprendre et ce sch‚ma
 
  +
must be in your head every time you program in ASM.
devra être dans votre tète à chaque fois que vous programmerez en ASS.
 
   
- Vous pouvez constater que:
+
- You can see that:
   
* La m‚moire est adressable au niveau de l'octet *
+
* Memory is addressable at the BYTE level *
 
----------------------------------------------
 
----------------------------------------------
* :Entre 2 adresses diff‚rentes X et X+1 ou X-1, il y a *
+
* :Between 2 different addresses X and X+1 or X-1, there is *
* 8 BITS ou un OCTET. *
+
* 8 BITS or one BYTE. *
   
 
bits n° 7 6 5 4 3 2 1 0
 
bits n° 7 6 5 4 3 2 1 0
   
 
X-1 ---------->
 
X-1 ---------->
[ ][ ][ ][ ][ ][ ][ ][ ]
+
[ ][ ][ ][ ][ ][ ][ ][ ]
X ---------->
+
X ---------->
[ ][ ][ ][ ][ ][ ][ ][ ]
+
[ ][ ][ ][ ][ ][ ][ ][ ]
 
X+1 ---------->
 
X+1 ---------->
[ ][ ][ ][ ][ ][ ][ ][ ]
+
[ ][ ][ ][ ][ ][ ][ ][ ]
   
   
  +
* Memory can be represented as a WELL into which we
* La m‚moire peut ètre repr‚sent‚e comme un PUITS dans lequel on
 
JETTE des donn‚es:BITS,OCTET,MOTS,L-M:
+
DROP data: BITS, BYTE, WORDS, L-W:
   
La largeur de ce puit est d'un MOT (soit 16 Bits)
+
The width of this well is a WORD (so 16 BITS)
La profondeur d‚pend de la taille de la m‚moire.
+
The depth depends on the size of the memory.
   
Le but du jeu: Jetter nos donn‚es dans le puit sans d‚former
+
The purpose of the game: Drop our data into the well without deforming
les donn‚es.
+
the data.
   
c.à.d: Si vous y jettez un MOT: 1010101110110110 (=2 octets,1 de
+
i.e.: If you throw a WORD: 1010101110110110 (=2 bytes, 1 high-weight (on the right) and one low-weight (on the left)) at
  +
an even address x.
poids fort (à droite) et un de poids faible (à gauche) ) à
 
une adresse x paire.
 
   
   
Line 476: Line 442:
   
 
|--------|--------|
 
|--------|--------|
ADRESSES PAIRES |--------|--------| ADRESSES IMPAIRES
+
EVEN ADDRESSES |--------|--------| ODD ADDRESSES
 
--------------- |--------|--------| -----------------
 
--------------- |--------|--------| -----------------
 
bit nr° 15 7 0
 
bit nr° 15 7 0
   
 
 
vous obtenez:
+
you obtain:
   
ADRESSES PAIRES x|10101011|10110110| ADRESSES IMPAIRES
+
EVEN ADDRESSES x|10101011|10110110| ODD ADDRESSES
 
---------------x+2|--------|--------| -----------------
 
---------------x+2|--------|--------| -----------------
 
|--------|--------|
 
|--------|--------|
 
bit nr° 15 7 0
 
bit nr° 15 7 0
   
- Le MOT a été posé à l'adresse x (PAIRE)
+
- The WORD has been placed at address x (EVEN)
   
. L'Oct de poids FORT est à l'adresse x (PAIRE)
+
. The HIGH-WEIGHT Byte is at address x (EVEN)
. L'Oct de poids FAIBLE à l'adresse x+1 (IMPAIRE)
+
. The LOW-WEIGHT Byte is at address x+1 (ODD)
   
   
par contre, si vous jetez ce mot à une adresse impaire:
+
however, if you throw this word at an odd address:
   
   
Line 504: Line 470:
   
 
|--------|--------|
 
|--------|--------|
ADRESSES PAIRES |--------|--------| ADRESSES IMPAIRES
+
EVEN ADDRESSES |--------|--------| ODD ADDRESSES
 
--------------- |--------|--------| -----------------
 
--------------- |--------|--------| -----------------
 
bit nr° 15 7 0
 
bit nr° 15 7 0
Line 510: Line 476:
 
 
 
 
vous obtenez:
+
you obtain:
   
 
x-3|--------|--------|
 
x-3|--------|--------|
ADRESSES PAIRES x-1|--------|10101011|x ADRESSES IMPAIRES
+
EVEN ADDRESSES x-1|--------|10101011|x ODD ADDRESSES
 
--------------- |10110110|--------|x+2 -----------------
 
--------------- |10110110|--------|x+2 -----------------
 
|--------|--------|
 
|--------|--------|
Line 519: Line 485:
   
   
- Le MOT a ‚t‚ pos‚ à l'adresse x (IMPAIRE)
+
- The WORD has been placed at address x (ODD)
   
. L'Oct de poids FORT est à une adresse IMPAIRE :x
+
. The HIGH-WEIGHT Byte is at an ODD address: x
. L'Oct de poids FAIBLE à une adresse PAIRE :x+1
+
. The LOW-WEIGHT Byte is at an EVEN address: x+1
   
Dans ce cas, on ne respecte plus les règles de notre 'jeu'
+
In this case, the rules of our 'game' are no longer respected.
Si on devait jeter un autre MOT à l'adresse x-3 dans notre
+
If we had to throw another WORD at address x-3 in our
puits, son Oct FORT ne pourrait pas se maintenir et d‚grin-
+
well, its HIGH-WEIGHT Byte could not hold and would
golerait en x-1!
+
tumble down to x-1!
   
ATTENTION,en r‚alit‚ ceci ne se produirait pas, Je simplifie
+
CAUTION, in reality this would not happen, I am simply
seulement mon explication...
+
simplifying my explanation...
   
En fait, pour pouvoir d‚placer (poser) des MOTS dans la m‚moire, il
+
In fact, to be able to move (place) WORDS in memory, one
  +
must ensure that the destination address is EVEN!
faut veiller à ce que l'adresse de destination soit PAIRE!
 
   
Pour notre exemple, il faut donc poser le MOT sous cette
+
For our example, the WORD must therefore be placed in memory
forme dans la m‚moire (dans notre 'puits')
+
(in our 'well') in this form:
   
 
+----------------+
 
+----------------+
Line 545: Line 511:
   
 
|--------|--------|
 
|--------|--------|
ADRESSES PAIRES x|10101011|10110110|x+1 ADRESSES IMPAIRES
+
EVEN ADDRESSES x|10101011|10110110|x+1 ODD ADDRESSES
 
--------------- |--------|--------| -----------------
 
--------------- |--------|--------| -----------------
 
bit nr° 15 7 0
 
bit nr° 15 7 0
   
.L'Oct de poids FORT (10101011) est à l'adresse x
+
.The HIGH-WEIGHT Byte (10101011) is at address x
qui est PAIRE
+
which is EVEN
   
.L'Oct de poids FAIBLE (10110110) est à l'adresse x+1
+
.The LOW-WEIGHT Byte (10110110) is at address x+1
qui est IMPAIRE
+
which is ODD
   
   
* Il en est de mème lorsqu'il s'agit d'un L-M:
+
* The same applies when it's an L-M:
 
--------------------------------------------
 
--------------------------------------------
   
Voilà comment poser un L-M, aussi il faut que l'adresse de
+
Here's how to place an L-M, here too the destination address
destination soit PAIRE, pour ‚viter les m‚mes complications
+
must be EVEN, to avoid the same complications
que dans notre exemple pr‚c‚dent.
+
as in our previous example.
   
   
Line 573: Line 539:
   
 
|--------|--------|
 
|--------|--------|
ADRESSES PAIRES |--------|--------| ADRESSES IMPAIRES
+
EVEN ADDRESSES |--------|--------| ODD ADDRESSES
 
--------------- |--------|--------| -----------------
 
--------------- |--------|--------| -----------------
 
x|11100010|01100100|x+1
 
x|11100010|01100100|x+1
Line 580: Line 546:
 
bit nr° 15 7 0
 
bit nr° 15 7 0
   
.Le MOT de poids FORT (1110001001100100) est à
+
.The HIGH-WEIGHT Word (1110001001100100) is at
l'adresse x ,qui est PAIRE
+
address x, which is EVEN
   
.Le MOT de poids FAIBLE (1010110011010001) est à
+
.The LOW-WEIGHT Word (1010110011010001) is at
l'adresse x+2 ,qui est PAIRE
+
address x+2, which is EVEN
   
   
* Pour un OCTET ou un BIT
+
* For a BYTE or a BIT
 
-----------------------
 
-----------------------
   
- La parit‚ n'a plus d'importance!
+
- Parity no longer matters!
   
Ainsi, pour un Octet: on a:
+
Thus, for a Byte: we have:
 
--------------
 
--------------
   
Line 600: Line 566:
   
 
|--------|--------|
 
|--------|--------|
ADRESSES PAIRES x|01000110|--------|x+1 ADRESSES IMPAIRES
+
EVEN ADDRESSES x|01000110|--------|x+1 ODD ADDRESSES
 
--------------- |--------|--------| -----------------
 
--------------- |--------|--------| -----------------
 
bit nr° 15 7 0
 
bit nr° 15 7 0
   
   
.L'Oct (01000110) est à une adresse x ,PAIRE
+
.The Byte (01000110) is at an address x, EVEN
   
OU:
+
OR:
 
--
 
--
 
01000110
 
01000110
Line 614: Line 580:
   
 
|--------|--------|
 
|--------|--------|
ADRESSES PAIRES x-1|--------|01000110|x ADRESSES IMPAIRES
+
EVEN ADDRESSES x-1|--------|01000110|x ODD ADDRESSES
 
--------------- |--------|--------| -----------------
 
--------------- |--------|--------| -----------------
 
bit nr° 15 7 0
 
bit nr° 15 7 0
   
   
.L'Oct (01000110) est à une adresse x ,IMPAIRE
+
.The Byte (01000110) is at an address x, ODD
   
   
Pour un BIT: on a
+
For a BIT: we have
 
------------
 
------------
   
Line 631: Line 597:
   
 
|--------|--------|
 
|--------|--------|
ADRESSES PAIRES x|-------0|--------|x+1 ADRESSES IMPAIRES
+
EVEN ADDRESSES x|-------0|--------|x+1 ODD ADDRESSES
 
--------------- |--------|--------| -----------------
 
--------------- |--------|--------| -----------------
 
bit nr° 15 7 0
 
bit nr° 15 7 0
   
   
.Le BIT (0) est à une adresse x ,PAIRE
+
.The BIT (0) is at an address x, EVEN
   
OU:
+
OR:
 
---
 
---
   
Line 647: Line 613:
   
 
|--------|--------|
 
|--------|--------|
ADRESSES PAIRES x-1| -------|-------0|x ADRESSES IMPAIRES
+
EVEN ADDRESSES x-1| -------|-------0|x ODD ADDRESSES
 
--------------- |--------|--------| -----------------
 
--------------- |--------|--------| -----------------
 
bit nr° 15 7 0
 
bit nr° 15 7 0
   
   
.Le BIT (0) est à une adresse x ,IMPAIRE
+
.The BIT (0) is at an address x, ODD
   
   
  +
*** SUMMARY ***
  +
----------------------
   
  +
* A BIT can be either at an EVEN address or an ODD address
  +
--- ----- -------
  +
* A BYTE can be either at an EVEN address or an ODD address
  +
----- ----- -------
  +
* A WORD is always located at an EVEN address in memory
  +
--- -----
  +
* An L-M is always located at an EVEN address in memory
  +
--- -----
  +
(Not following this rule leads to a computer crash!)
   
  +
* STRUCTURE of MEMORY:
*** RECAPITULATION ***
 
----------------------
 
 
* Un BIT peut ètre, soit à une adresse PAIRE, soit à une adresse IMPAIRE
 
--- ----- -------
 
* Un OCTET peut ètre, soit à une adresse PAIRE, soit une adresse IMPAIRE
 
----- ----- -------
 
* Un MOT est toujours situ‚ à une adresse PAIRE en m‚moire
 
--- -----
 
* Un L-M est toujours situ‚ à une adresse PAIRE en m‚moire
 
--- -----
 
( Le non respect de cette règle entraine un 'plantage' de l'ordi ! )
 
 
* STRUCTURE de la MEMOIRE:
 
 
--------
 
--------
   
Line 678: Line 642:
 
----- .| | |
 
----- .| | |
 
x-2|--------|--------|x-1
 
x-2|--------|--------|x-1
| x|00001011|--------| OCTET :00001011 à l'adresse x
+
| x|00001011|--------| BYTE: 00001011 at address x
| x+2|--------|10110010| OCTET :10110010 en x+3 octets
+
| x+2|--------|10110010| BYTE: 10110010 at x+3 bytes
| x+4|--------|--------| (impaire)
+
| x+4|--------|--------| (odd)
| x+6|10001011|10110110| MOT :1000101110110110
+
| x+6|10001011|10110110| WORD: 1000101110110110
| .|--------|--------| en x+6 octets (paire)
+
| .|--------|--------| at x+6 bytes (even)
 
\|/ .|--------|--------|
 
\|/ .|--------|--------|
' x+12|01101100|00000000| L-M :011011000000000010111010-
+
' x+12|01101100|00000000| L-M: 011011000000000010111010-
SENS des .|10111010|01110111| 01110111
+
DIRECTION .|10111010|01110111| 01110111
adresses .|--------|--------| en x+12 octets (paire)
+
of INCREASING .|--------|--------| at x+12 bytes (even)
CROISSANTES .|--------|--------|
+
addresses .|--------|--------|
----------- x+20|--------|-------1| BIT :1 à l'adresse x+21 octets
+
----------- x+20|--------|-------1| BIT: 1 at address x+21 bytes
| .|--------|--------| (impaire)
+
| .|--------|--------| (odd)
| .|oct FORT| FAIBLE |
+
| .|HIGH-WT| LOW-WT |
 
\|/ .|--------| ------ |
 
\|/ .|--------| ------ |
 
' 15 7 0
 
' 15 7 0
 
| etc... |
 
| etc... |
Adresses PAIRES | | | Adresses IMPAIRES
+
EVEN Addresses | | | ODD Addresses
 
--------------- -----------------
 
--------------- -----------------
 
+-------+
 
+-------+
|MEMOIRE|
+
|MEMORY |
 
+-------+
 
+-------+
   
Exemple d'organisation de la m‚moire.
+
Example of memory organization.
 
-------------------------------------
 
-------------------------------------
(Octets,Mots,L-M,Bits fictifs)
+
(Bytes, Words, L-Ms, fictitious Bits)
   
   
Line 708: Line 672:
   
   
*** ORGANISATION DE LA MEMOIRE ***
+
*** ORGANIZATION OF MEMORY ***
 
----------------------------------
 
----------------------------------
   
- On distingue: .L'espace programme, qui contient les instructions de vos
+
- We distinguish: .The program space, containing the instructions of your
programmes cod‚es en BINaire.
+
programs coded in BINARY.
   
.L'espace donn‚es, qui contient les donn‚es du prg et les
+
.The data space, containing the program's data and the
zones de la m‚moire que vous avez initalis‚. (en BIN)
+
memory areas that you have initialized. (in BIN)
   
.Ces 2 zones sont dans la m‚moire vive (RAM), on ne peut
+
.These 2 zones are in the RAM (Random Access Memory),
pas ‚crire sur la m‚moire morte (ROM) car elle contient
+
and one cannot write on the ROM (Read-Only Memory)
tous les renseignements dont l'ordi a besoin pour fonc-
+
because it contains all the information needed for
tionner correctement.
+
the computer to function correctly.
La RAM est la m‚moire disponible en ‚criture au progra-
+
RAM is the memory available for writing to the programmer
mmeur (elle peut bien sur aussi être effac‚e.)
+
(it can, of course, also be erased.)
   
On dispose d'environ 512 Ko de m‚moire vive sur un 520ST
+
Approximately 512 KB of RAM is available on a 520ST
(un Kilo Octet=1024 Octets.) et d'1 M‚ga Octet soit 1024
+
(one Kilobyte = 1024 Bytes) and 1 Megabyte or 1024
Ko sur un 1040ST.
+
KB on a 1040ST.
   
   
Line 733: Line 697:
 
-----------------------
 
-----------------------
   
  +
- You are now ready to begin programming itself:
- Vous voilà prêts à pr‚sent à commencer la programmation proprement dite:
 
  +
remember well everything that has been said here (note it down somewhere if you
retenez bien tout ce qui a ‚t‚ dit ici (notez le quelquepart si vous le
 
  +
find it useful), read it again if your head is spinning, because in
jugez utile), relisez encore une fois si la tête vous tourne, car dans
 
  +
the next chapter, we start with the serious stuff.
le prochain chapitre, les choses s‚rieuses commencent.
 
   
   
Line 743: Line 707:
   
 
PIECHOCKI Laurent
 
PIECHOCKI Laurent
8,impasse Bellevue Suite dans [[pl_DEBUTS.DOC]]
+
8,impasse Bellevue Continue in DEBUTS.DOC
 
57980 TENTELING ----------
 
57980 TENTELING ----------
   
Line 749: Line 713:
 
</pre>
 
</pre>
 
Back to [[ASM_Tutorial]]
 
Back to [[ASM_Tutorial]]
  +
[[Category: 68000 ASSEMBLY ON ATARI ST Part 1 ]]

Latest revision as of 00:14, 17 December 2023



                       ------------------------------
                              CHAPTER number 2:
         
                       * FIRST STEPS IN ASSEMBLY *
           
                       ------------------------------



              *** SOFTWARE USE OF THE ASSEMBLER ***
              ----------------------------------------------

 -   As we saw in the previous chapter, programming in assembly language is only possible with: an EDITOR, an ASSEMBLER, and a LINKER.

 1) The EDITOR:  .It is the EDITOR that allows you to enter your listing:
    ----------
                   You will write your program using the functions of the editor. The editor will save and load your listings.

                   The saved files are ASCII files (like the files in this digital book) and can be modified at will with the editor.

                   Such a file is called SOURCE CODE.

                   The functions of the editor vary with the utility (DEVPAC, METACOMCO, PROFIMAT...) and simplify the input of the text (listing).

                  .A file from an editor cannot be executed!

                   It will first have to be ASSEMBLED and then LINKED.


 2) The ASSEMBLER .ASSEMBLY constitutes the second step:
    ------------
                  The ASCII codes (text) of the listing are translated by the Assembler and are converted (encoded) into BINARY (binary is recognized directly by the computer, unlike ASCII text)

                  Once processed (Assembled), the file (listing) is saved on the diskette in the format of a BINARY file called OBJECT CODE.

3) The LINKER     .LINK EDITION is the last step:
   ---------
                  The OBJECT CODE is loaded and the LINKER will integrate the MACRO INSTRUCTIONS that make up the library if the source file requires it. -->

                                    -------------
Let me explain:
--------------
  .In assembly language, you can create MACRO-INSTRUCTIONS
   (see previous chapter).

  .A MACRO is nothing more than a new instruction (parametrizable)
   which will be included by the LINKER every time it encounters its name
   in the OBJECT CODE.

An example:
-------
  .You create a MACRO that displays 'HELLO' on the screen:

   This MACRO actually delimits a PROGRAM whose function
   is to display 'HELLO' on the screen and you name it 'WRITE':

            Beginning of the Macro

   WRITE     .
             .
             .                      the listing that allows to display
             .                      'HELLO' on the screen
             .

             End of the Macro  
  
   Each time the LINKER encounters 'WRITE' (the name of the MACRO),
   in the OBJECT CODE, it will rewrite the 'WRITE' program segment in place of the MACRO.

     .A MACRO is therefore not a subroutine, it only allows for better
      readability in the listing.

     .A macro will be completely rewritten each time: so we lose
      a little bit more memory, but it is much faster than a subroutine.

     .Macros allow for better readability of the listing as
      You no longer have to type the ROUTINE corresponding to the name of the
      Macro, the Linker takes care of that.

  .You can therefore create a LIBRARY of MACROS (i.e. files
   defining MACROS) to call when you need them in your listing...

   The LINKER takes care of loading the MACROS used in the listing
   (if the listing contains them...) and rewriting them completely.

   It will be sufficient to indicate (at the beginning of the listing) the name of the file which
   contains the MACROS used, or to define the MACROS used
   at the beginning of the listing.
                            (WE WILL SEE IN DETAIL...)

  .We, we will create MACROS for the functions of GEM, XBIOS,
   BIOS and VDI (MACROS that handle calling the desired functions by passing the necessary parameters for speed and user-friendliness)

                                   --------------

                .The LINKER will also create the BASE PAGE, which contains
                 information about the program essential for the operating system to be able to load and execute
                 the LINKED program.
                 This is why LINKAGE is essential even if
                 the listing does not contain Macros.

                      (I will detail when I talk about GEMDOS)


                .The resulting file will be saved and can be
                 executed.



 SUMMARY:
 ------
     * EDITOR *              * ASSEMBLER *              * LINKER *

      |listing|    ------->    |object code|   -------> |executable prg|





                    *** SOME BASIC NOTIONS ***
                    -------------------------------------

Here are some VERY IMPORTANT notions:

1)  BINARY: 
    -----------
 .         Usually, for calculations, we use a decimal system,
  i.e. this system is composed of 10 digits: 0,1,2,3,4,5,6,7,8,9
  :This is a BASE of 10.

  If we want to express a set whose quantity exceeds 9: we increase
  the digit by one unit and we obtain a number:10,11,12,13,14...

 .The BINARY system (or BASE 2), consists of 2 digits: 0 and 1

   Thus, if we want to express a set whose quantity exceeds 1
   (i.e. >1 in decimal system!!) we increase by one unit.

Therefore:
This is how we count in BINARY:0,1,10,11,100,101,111,1000,1001,1011...

 .We will assume that each component of the computer's memory is represented
 (or coded) in BINARY.

 .The 0 and 1 of the BINARY system present in the components of
  the computer's structure are called BITS.

 .A BIT can be zero (or off):0    OR     activated (or on):1
                                       --
A BIT is the smallest modifiable and recognizable structure
 by the computer.

.We define a group of 8 BITS as an BYTE (The BYTE is also called BYTE
 in English, do not confuse it with 'bit'!)

We define a group of 2 BYTES as a WORD (so 16 BITS)

We define a group of 2 WORDS as a LONG WORD (so 4 BYTES or 32 BITS)

These groupings are arbitrary and deal with consecutive BITS
 (that follow each other) in memory.

 CONSEQUENCES: The internal components of the computer can be expressed
 ------------ in BITS, BYTES, WORDS or LONG WORDS.

SUMMARY:
-------
-  A BIT takes on the value of either 1 (activated) or 0 (turned off)
      ---
-  An BYTE is a group of 8 consecutive BITS in memory
      -----
-  A WORD is a group of 2 consecutive BYTES in memory
      ---
-  A LONG WORD is a group of 2 WORDS consecutive in memory
      --------
To simplify, we could say that the computer's memory is composed
of a multitude of small boxes (BITS) that can take either 1 or 0 as values depending on the actions of the Microprocessor and can be grouped (arbitrarily) in the form of BYTES, WORDS or LONG WORDS.

EXAMPLE:
---         {    0                                is a BIT
excerpts from {    01011101                         is a BYTE or 8 BITS
  memory    {    0101110111010110                 is a WORD or 16 BITS
            {    01011101110101101000100100101101 is a LONG WORD or 32 B


2) HEXADECIMAL:
   -------------
 .HEXADECIMAL is a BASE 16 system, the 16 components of this system
  are:0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

  Thus, to express a set whose quantity exceeds F (i.e. 16 in
  BASE 10), we change units: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,10,11,12,
  ,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22...

  As you can see, the real utility of this system is that a large number is represented by a minimum of digits.

 .An BYTE is represented in HEXA. by 2 digits

 .A WORD is represented in HEXA. by 4 digits

 .A LONG WORD is represented in HEXA. by 8 digits 


 3) NOTATIONS:
    ----------
-      In an ASM listing, digits coded  in BINARY are 
  represented with the prefix ' % ', those coded in
  HEXADECIMAL with the prefix ' $ '.

  (The use of the BASE 10 does not need to be indicated)

  After Linking, all digits will automatically be coded in
  Hexadecimal.

EXAMPLE:       %01001011   is a digit coded in BINARY (and an BYTE)
----           $1F0A       is a digit coded in HEXA.   (and a WORD)
                101001     is a digit coded in DECIMAL !


 4) REMARKS:
    ----------
 -  The leftmost BIT of an BYTE, a WORD, a LONG WORD is called
    M.S.B (Most Significant Bit) or Most significant bit.

 -  This bit allows for signing (positive/negative) a number.
    It is activated for a negative number.

 -  It is only used to sign a number!

  EXAMPLE:  $FFFFFFFF is a L-W that is -1 in decimal
  ----     %1111111111111111 is a WORD that is -1 in decimal
        %11111110 is an BYTE that is -2 in decimal and
        %00000010 is an BYTE that is 2: To invert the sign of the BYTE,
         we have 'extended' the leftmost 1 to the MSB.

  :Very theoretical examples, don't panic, it's not really useful
   in practice (and frankly useless, I assure you...) because there
   are instructions that perform all sorts of operations on the
   BITS, BYTES, WORDS and L-W... (and no one forces you to work in
   Binary system!)

  - According to our definitions: (the MSB is only used to sign the bit,
                              the BYTE, the word or the long word)

             therefore:            *         -2^7  ó BYTE < 2^7
                                        -128  ó BYTE < 128

                              *        -2^15  ó  WORD  < 2^15
                                       -32768 ó  WORD  < 32768

                              *        -2^31  ó  L-W  < 2^31
                                  -2147483648 ó  L-W  < 2147483648

  This, on the other hand, is something to remember: Overflows (BYTE too large...)
  cause errors.

 5) RECAPITULATION:
     ---------------
 .A component of the computer's structure: REGISTER,VARIABLE... (terms
  to be explained soon) can take the form of a BIT, BYTE, WORD or LONG WORD.

  In theory... We will study the exceptions: The choice is more limited in
                reality.


    CONSEQUENCES:   .A VARIABLE defined as a WORD cannot therefore
    -------------    have a value greater than 32768. (for example)

              NB:    This variable can only be a Long WORD (If its
              ---    value can be contained in a L-W , otherwise that
                     would cause an error since the computer does not recognize
                     any component whose quantity exceeds the L-W.)
                     (in theory...)

       REMARKS:   .A Variable that can be contained in an BYTE,
       ----------    so whose value is <128 can also be contained in a
                     WORD or a L-W.

                     But it is necessary to pay attention to what the component
                     (here the variable) can be defined as (BIT, BYTE,
                     WORD, L-W...).

                    .Therefore, for each component of the computer's internal structure
                     indicate the different forms it can take (BIT, BYTE, WORD, L-W...).

                     We will do this with precision.

  This is why it is necessary to know the different forms that can
  be used for programming (Registers, variables...)
  and also by what these forms are defined (BIT, BYTE...).
  This is why Assembler is very strict in its programming.


6) IMPORTANT:
   ----------

Sets such as BYTES, WORDS, L-W are composed of BITS, these BITS
are numbered like this (in BYTES, WORD, L-W, REGISTERS, VARIABLES...):

                        From RIGHT to LEFT.

     31 30 .  .  .     .  .  . 15  .  .  .  9  8  7  6  5  4  3  2  1  0
    [*][ ][.][.][.][ ][ ][ ][ ][*][.][.][.][ ][ ][*][ ][ ][ ][ ][ ][ ][*]

 - An BYTE is therefore numbered from right to left from 0 to 7

 - A WORD, from 0 to 15

 - A L-W, from 0 to 31

 - Bit 0 is the MOST SIGNIFICANT BIT (or LSB: Least significant Bit)

 - Bit 7 (15 for a WORD, 31 for a L-W) is the MOST
   SIGNIFICANT BIT (or MSB)

   THUS:
   ------                     <-----------  MOST SIGNIFICANT BITS

                     31<-- ...[][][][][][][][][][][][][]...  -->0

                               LEAST SIGNIFICANT BITS ---------->

   THEREFORE: A WORD is composed of 2 BYTES, one of lower WEIGHT (bits 0 to 7) and
   ----- one of higher WEIGHT: (bits 8 to 15)

     A L-W is composed of 2 WORDS, one of lower WEIGHT (bits 0 to 15) and
     one of higher WEIGHT (bits 16 to 31)

                           THIS NOTION IS FUNDAMENTAL 
                           -----------------------------


                              *** THE MEMORY ***
                              ------------------

 - It is assumed that memory is a sequence of numbers coded in BINARY.

    :We now know that these numbers can be grouped into
     BYTES, WORD, L-W.

 -      Programming in assembly language allows you to change the contents
        of the memory.

Memory is changed when the computer performs a task (a calculation,
 any search...).
 In this case, the computer takes care of organizing its memory, it is according to this order that one or other action takes place, the user therefore does not intervene: This is what happens at every moment, a computer is therefore never at rest (it checks if the disk is changed, erases
 the screen fifty times a second).

Memory of the computer can also be changed by the user, this is the
 purpose of programming. The consequence is a planned state (programmed)
 of the memory, so such and such action is performed.
 This is possible by using instructions specific to the language used or by modifying directly a portion of the memory. This last operation is carried out very easily in ASM and with a precision at the level of the BIT.
 We can therefore Move an BYTE, a WORD, a L-W (which we have defined)
 in the memory.(where it is possible...)

In order to navigate in the vast memory of our computer, we have divided the
 memory and named each portion of the memory by an ADDRESS (like addresses on a street...)

Theoretically, it would be possible to place a BIT, BYTE, WORD or L-W at
 any ADDRESS, but in reality this is not possible.

     - The user only has access to a part of the memory.
       (we will see which part)

     - It is necessary to take into account the parity and oddness of ADDRESSES:
       One cannot put anything at any address.

 IN FACT: If we SCHEMATICIZE the structure of memory, it looks like
  a band of limited length (start and end) and a WIDTH of 16 BITS, the different parts of which are numbered and addressed every 8 BITS. (at each BYTE)




                             etc...

              bits: 15        7        0
              ----- .|        |        |
                  x-2|--------|--------|
        |           x|10001011|--------|   BYTE: 10001011 at address x
        |         x+2|--------|10001101|   BYTE: 10001101 at x+3 BYTEs
        |         x+4|--------|--------|
        |         x+6|00101100|10110011|   WORD: 0010110010110011
        |           .|--------|--------|         at x+6 BYTEs
       \|/          .|--------|--------|
        '        x+12|11011111|01110100|   L-W: 110111110111010001011011-
     SENS des       .|01011011|01110100|         01110100
     adresses       .|--------|--------|         at x+12 BYTEs
    CROISSANTES     .|--------|--------|
    -----------  x+20|--------|-------1|   BIT: 1 at address x+21 BYTEs
        |           .|--------|--------|
        |           .|OCT FORT| FAIBLE |
       \|/          .|--------| ------ |
        '           15        7        0

                             ETC...

                          +-------+
                          |MEMORY |: (Example of organization)
                          +-------+


- Take a good look at this example, it is very easy to understand and this scheme
  must be in your head every time you program in ASM.

- You can see that:

             * Memory is addressable at the BYTE level *
               ----------------------------------------------
      *    :Between 2 different addresses X and X+1 or X-1, there is   *
      *     8 BITS or one BYTE.                                    *

                     bits n° 7  6  5  4  3  2  1  0

            X-1  ---------->
                             [ ][ ][ ][ ][ ][ ][ ][ ]
             X   ---------->
                             [ ][ ][ ][ ][ ][ ][ ][ ]
            X+1  ---------->
                             [ ][ ][ ][ ][ ][ ][ ][ ]


       * Memory can be represented as a WELL into which we
         DROP data: BITS, BYTE, WORDS, L-W:

         The width of this well is a WORD (so 16 BITS)
         The depth depends on the size of the memory.

         The purpose of the game:  Drop our data into the well without deforming
                         the data.

   i.e.: If you throw a WORD: 1010101110110110 (=2 bytes, 1 high-weight (on the right) and one low-weight (on the left)) at
      an even address x.


                      1010101110110110
                             |
                            \|/

                    |--------|--------|
  EVEN ADDRESSES    |--------|--------|  ODD ADDRESSES
  ---------------   |--------|--------|  -----------------
           bit nr° 15        7        0

                   
                       you obtain:

  EVEN ADDRESSES   x|10101011|10110110|  ODD ADDRESSES
  ---------------x+2|--------|--------|  -----------------
                    |--------|--------|
           bit nr° 15        7        0

               - The WORD has been placed at address x (EVEN)

               . The HIGH-WEIGHT Byte is at address x (EVEN)
               . The LOW-WEIGHT Byte is at address x+1 (ODD)


            however, if you throw this word at an odd address:



                               10101011
                      10110110
                              |
                             \|/

                     |--------|--------|
  EVEN ADDRESSES     |--------|--------|    ODD ADDRESSES
  ---------------    |--------|--------|    -----------------
            bit nr° 15        7        0

                   
                   
                        you obtain:

                  x-3|--------|--------|
  EVEN ADDRESSES x-1|--------|10101011|x   ODD ADDRESSES
  ---------------    |10110110|--------|x+2 -----------------
                     |--------|--------|
            bit nr° 15        7        0


               - The WORD has been placed at address x (ODD)

               . The HIGH-WEIGHT Byte is at an ODD address: x
               . The LOW-WEIGHT Byte is at an EVEN address: x+1

            In this case, the rules of our 'game' are no longer respected.
            If we had to throw another WORD at address x-3 in our
            well, its HIGH-WEIGHT Byte could not hold and would
            tumble down to x-1!

            CAUTION, in reality this would not happen, I am simply
            simplifying my explanation...

     In fact, to be able to move (place) WORDS in memory, one
     must ensure that the destination address is EVEN!

            For our example, the WORD must therefore be placed in memory
            (in our 'well') in this form:

                        +----------------+
                        |1010101110110110|
                        +----------------+
                                 |
                                \|/

                        |--------|--------|
  EVEN ADDRESSES      x|10101011|10110110|x+1   ODD ADDRESSES
  ---------------       |--------|--------|      -----------------
               bit nr° 15        7        0

                  .The HIGH-WEIGHT Byte (10101011) is at address x
                   which is EVEN

                  .The LOW-WEIGHT Byte (10110110) is at address x+1
                   which is ODD


            * The same applies when it's an L-M:
              --------------------------------------------

       Here's how to place an L-M, here too the destination address
       must be EVEN, to avoid the same complications
       as in our previous example.



                        +-----------------+
                        |1110001001100100-|
                        |1010110011010001 |
                        +-----------------+
                                 |
                                \|/

                        |--------|--------|
  EVEN ADDRESSES       |--------|--------|      ODD ADDRESSES
  ---------------       |--------|--------|      -----------------
                       x|11100010|01100100|x+1
                     x+2|10101100|11010001|x+3
                        |--------|--------|
               bit nr° 15        7        0

                  .The HIGH-WEIGHT Word (1110001001100100) is at
                   address x, which is EVEN

                  .The LOW-WEIGHT Word (1010110011010001) is at
                   address x+2, which is EVEN


            * For a BYTE or a BIT
              -----------------------

                 - Parity no longer matters!

      Thus, for a Byte: we have:
             --------------

                      01000110
                          |
                         \|/

                     |--------|--------|
  EVEN ADDRESSES   x|01000110|--------|x+1   ODD ADDRESSES
  ---------------    |--------|--------|      -----------------
            bit nr° 15        7        0


                     .The Byte (01000110) is at an address x, EVEN

           OR:
           --
                              01000110
                                  |
                                 \|/

                     |--------|--------|
  EVEN ADDRESSES x-1|--------|01000110|x     ODD ADDRESSES
  ---------------    |--------|--------|      -----------------
            bit nr° 15        7        0


                     .The Byte (01000110) is at an address x, ODD


             For a BIT: we have
             ------------


                         0
                         |
                        \|/

                     |--------|--------|
  EVEN ADDRESSES   x|-------0|--------|x+1   ODD ADDRESSES
  ---------------    |--------|--------|      -----------------
            bit nr° 15        7        0


                     .The BIT (0) is at an address x, EVEN

          OR:
          ---


                                  0
                                  |
                                 \|/

                     |--------|--------|
  EVEN ADDRESSES x-1| -------|-------0|x     ODD ADDRESSES
  ---------------    |--------|--------|      -----------------
            bit nr° 15        7        0


                     .The BIT (0) is at an address x, ODD


*** SUMMARY ***
----------------------

 * A BIT can be either at an EVEN address or an ODD address
      ---                            -----                -------
 * A BYTE can be either at an EVEN address or an ODD address
      -----                            -----              -------
 * A WORD is always located at an EVEN address in memory
      ---                               -----
 * An L-M is always located at an EVEN address in memory
      ---                               -----
   (Not following this rule leads to a computer crash!)

 * STRUCTURE of MEMORY:
                   --------


                            etc...
              bits: 15        7        0
              ----- .|        |        |
                  x-2|--------|--------|x-1
        |           x|00001011|--------|  BYTE: 00001011 at address x
        |         x+2|--------|10110010|  BYTE: 10110010 at x+3 bytes
        |         x+4|--------|--------|         (odd)
        |         x+6|10001011|10110110|  WORD: 1000101110110110
        |           .|--------|--------|        at x+6 bytes (even)
       \|/          .|--------|--------|
        '        x+12|01101100|00000000|  L-M: 011011000000000010111010-
     DIRECTION      .|10111010|01110111|        01110111
     of INCREASING  .|--------|--------|        at x+12 bytes (even)
     addresses      .|--------|--------|
    -----------  x+20|--------|-------1|  BIT: 1 at address x+21 bytes
        |           .|--------|--------|           (odd)
        |           .|HIGH-WT| LOW-WT |
       \|/          .|--------| ------ |
        '           15        7        0
                     |       etc...    |
 EVEN Addresses      |        |        |     ODD Addresses
 ---------------                             -----------------
                          +-------+
                          |MEMORY |
                          +-------+

              Example of memory organization.
              -------------------------------------
                 (Bytes, Words, L-Ms, fictitious Bits)





                   *** ORGANIZATION OF MEMORY ***
                   ----------------------------------

- We distinguish: .The program space, containing the instructions of your
                  programs coded in BINARY.

                 .The data space, containing the program's data and the
                  memory areas that you have initialized. (in BIN)

                 .These 2 zones are in the RAM (Random Access Memory), 
                  and one cannot write on the ROM (Read-Only Memory) 
                  because it contains all the information needed for 
                  the computer to function correctly.
                  RAM is the memory available for writing to the programmer 
                  (it can, of course, also be erased.)

                 Approximately 512 KB of RAM is available on a 520ST
                 (one Kilobyte = 1024 Bytes) and 1 Megabyte or 1024
                 KB on a 1040ST.   




                        -----------------------

- You are now ready to begin programming itself:
  remember well everything that has been said here (note it down somewhere if you
  find it useful), read it again if your head is spinning, because in
  the next chapter, we start with the serious stuff.





     PIECHOCKI Laurent
     8,impasse Bellevue                           Continue in DEBUTS.DOC
     57980 TENTELING                                         ----------


Back to ASM_Tutorial