💾 Archived View for mirrors.apple2.org.za › archive › www.textfiles.com › apple › ml.part.i captured on 2023-11-14 at 11:49:13.
View Raw
More Information
⬅️ Previous capture (2023-03-20)
-=-=-=-=-=-=-
- **************************************
- *
- *
- MACHINE LANGUAGE TUTORIAL DISK *
- *
- WRITTEN BY DR. FIRMWARE *
- *
- *
- **************************************
The aim of this disk is for you the
reader to understand machine language
to an extent so that you can program
fully in machine language (ml).
PART I
The fundamentals.
The first part of the course is number
bases. if you undestand binary and
hexadecimal numbers and conversion
between these and decimal, you can skip
to the next section.
Binary: Base two.
Number bases are what we are dealing
with here. The number base that we
normally use in everday life is
decimal. 'Decimal' comes from latin
where it meant ten. We have ten digits,
0,1,2,3,4,5,6,7,8, and 9, which are
combined in various ways to produced
other numbers. It is understood that
the number '345' means 3x100+4x10+5x1.
The right-most digit has the least
significance, while the left-most has
the most significance. From left to
right, the numbers that are multiplied
with the digits are successive powers
of 10. 1=10~0, 10=10~1, 100=10~2, etc.
Now applying these fundamentals, we'll
construct the base two, or binary,
number system. First there are two
digits, 0, and 1. So, the right-most
digit has the least significance and
the left-most, the most significance,
just like in decimal. Now, the numbers
multiplied with the digits will be
successive powers of two. 2~0=1, 2~1=2,
2~2=4, 2~3=8, etc. We now have the
basics down, so we'll take a number,
such as '1001101', and find it's
decimal value.
To start, we'll take the right-most
digit and find out what it is
multiplied with. Since it's the right-
most digit, it's multiplied with two
to the power of zero. 1x2~0=1. Now,
repeat the process, this time with the
second right most digit, which is a 0.
0x2~1=0. Continueing produces: 1x2~2=4,
1x2~3=8, 0x2~4=0, 0x2~5=0, and
1x2~6=64. Summing the results,
1+0+4+8+0+0+64=77. So 77 is the decimal
value of the binary number 1001101.
If you want to practice some, just make
strings of 0's and 1's and do what we
did above.
Conversion from decimal to binary is a
little more complex. Suppose we take a
decimal number, 35. To convert, we do a
series of steps.
1> Divide the number by two, and put
the remainder aside.
2> Replace the dividend with the
quotient.
3> Repeat step 1 & 2 until the number
reaches zero.
4> Take the remainders and place them
in a row, the first is right-most, the
last is left-most.
And that's it. To demostrate, we'll
convert 35 to binary.
0 R=1 -------
--- !
2) 1 R=0 !
--- !
2) 2 R=0 !
--- v
2) 4 R=0 100011
--- ~
2) 8 R=1 !
--- !
2) 17 R=1 ------------
---
2) 35
There. Quite simple. The diagram would
look somewhat better on paper, but this
will have to do in the mean while.
Hexadecimal
'Hex', as it is affectionately called
by in most computerese dialects, is
nothing more than a base sixteen number
system. Let's go through some basics.
It has 16 digits. These digits are the
numbers 0-9, and the letters A-F. The
reason why the letters are included is
because there aren't enough numbers.
Let's take a number, $4A. Note that
when you see a '