Assembler - Record numbers, shipment numbers in the register entry number in the register pair, scrolling the screen, set the output to
screen, clear screen.
ASSEMBLER FOR BEGINNERS
(C) THINKER
Many newspapers and magazines have a similar topic. However,
I did not know assembler, and gazed in amazement at the
"Unpretentious" procedure, clear the screen, I had to learn to
through other sources. Even now I still bad encoding, but
some of the following article seems interesting and useful.
First, you need special assembled
program (or suite), otherwise known as simply - an assembler. I
use ZX ASM-3, but, of course, we can take any another. At this
point we shall return.
Our beloved Speccy have a few pairs of registers. Here
the main ones: AF, BC, HL, DE. You can use them to
individually or in pairs, with exactly as written above
(It is not allowed entry: AH, DL, or BE). They serve to
store numbers. These registers are eight-bit.
For example, in Reg. 'B' we can write the number that in
binary system does not exceed eight characters, it is possible
to record the number of "98" (in the binary system of
calculation - this is 1100010%, the number of ones nulikov and
not more than eight), but you can not write the number of 350
(in binary notation - 101100010%, the number of bits-9). In
general, the highest number which can be written to register -
it's 255 (% 11111111).
You can also record and big numbers, but not in the
registers and the register pair (AF, BC, HL, DE). These
register pairs already shestnadtsatibitnye and the largest
number that can be written in them - these are the numbers that
the binary system does not exceed sixteen digits. The largest
number, 65535.
The simplest operation in assembly is to send
number in the register. For this is the mnemonic 'LD'. For
example:
LD A, 5, write to the register "A" number "5"
This program will record in the register of 'A' number '5 '.
However, if You run the files of (for this program must first
proassemblirovat, and then run), then your PC will almost
certainly hang. To prevent this from happening you need to
After all the files of the team put 'RET' (Return), it will
cause the computer to go back to assembler or BASIC
interpreter.
Now our programm looks like this:
LD A, 5, write to the register "A" number "5"
RET; return
Pay attention! The text appearing after the symbol ";" said
commentary on the program. To implement the program itself is
not irrelevant and the assembly program is ignored.
Comments are entered in the text solely for the sake of
convenience and readability of the program. For example,
programmers often supply the sources of his comments to some
time later did not have to painfully recall its algorithm. In
assembler, sign, "" can be likened to the operator 'REM' BASIC
language - all that is behind it - is not handled by the
translator. This property Comments can be effectively used when
debugging programs excluding from the performance of individual
teams and the whole procedure.
But I digress ...
In order to write the number in the register-pair, can also
use the mnemonic 'LD':
LD HL, 1998; register-write a couple of "HL" - "1998"
RET; return
Well, now you probably want to see something on the screen.
Start simple. Probably the very first program on your
Basic'e was a program to display some nobud words. No
What is not difficult to do it in assembler. Although it can be
a files of fold ... But we use Basic'om in principle
DO NOT themselves, but only to his routine. This routine is
ROM at address 16. (Shestantsaterichny address - # 10).
In order to apply to any routine in the memory, you can use
mnemonics 'CALL', after which you must specify the address, it
is the number of cell's capacity with which to ROM is stored
routine printing characters. For example, in assembler, you can
call a subroutine ROM - "scrolling screen":
CALL 3582; appeal to the address 3582.
, (Equivalent to "RANDOMIZE USR 3582)
RET; return
But back to the display. In order to print something, you
must pass the necessary routine information, such as: what kind
of symbol to print. For this we use registers, and the precise
case 'A'. In his need to write code characters to be printed,
but first you need to specify output (screen, printer, office
window or something). For this we use the routine ROM under the
address 5633, and the before going to the address of 5633, you
need to register 'A' Record number of the flow (2-main screen,
3-printer). For example, to set the display:
LD A, 2, set the output to the screen (Stream 2)
CALL 5633; subroutine call setup flow
RET; return
Pay attention! Register 'A' - the most important processor
registers. It is often called a battery, because namely, with
the participation This register is carried out most of the
mathematical and logical operations assembler.
Now is the time to learn how to perform the procedure clear
the screen. Benefit in memory of our Speccy is and this
subroutine. For example, here's how it will look this procedure
in assembler:
CALL 3435; is the address of the screen cleaning routines in
ROM.
RET; return
Now we are able to establish flow and clear the screen, then
You can try something to bring:
CALL 3435; clear the screen
LD A, 2; record in the battery thread number
CALL 5633; set flow
LD A, "*"; in Reg. 'A' puts '*' symbol
CALL 16, a subroutine call print
RET; return
Instead of 'CALL 16' can write 'RST 16'. RST - a team moving
to a strictly fixed address, (eg not allowed entry "RST 17"),
which takes up less memory in bytes and is faster.
Instead, characters in the battery can enter the codes of
these characters, without quotes. For example, if we substitute
in the fourth row our program: "LD A, 65" - appears on the
screen by the letter "A", tk 65 - is the decimal code of the
letter "A".
Now, as I promised, let's talk about assembly program.
If you have a "Spectrum 48K - you can take advantage of programs
type GENS-3, GENS-4, ZEUS. Owners of cars with the same memory
and 128K above were more fortunate: their attention is invited
over about various assemblers, are the main differences between
them are reduced to volume of service provided and some
additional amenities, such as the speed of assembly, etc.
Novice coders should be fine assemblers: TASM, ZX-ASM.
More advanced users will appreciate the XAS, ALASM,
STORM. Generally, the choice of a particular program
assemblirueschey purely individual - it is rather a matter of
taste. Later on, gaining the necessary experience, you can try
different assemblers, finding "Their" program, in which it will
be fun.
As a rule, along with the assembler you need and program
disassemblers (monitors, debuggers). Among the many such
programs, a well-deserved popularity of the monitor STS. It is
indispensable in case of burglary, debugging, tracing, provides
a rich service possibilities. Detailed analysis of these and
other funds, we will leave the following issues.
See you next issue!
Other articles:
Assembler - Record numbers, shipment numbers in the register entry number in the register pair, scrolling the screen, set the output to
screen, clear screen.
|
|
|
|
|
|
|
|
|
|
|
|
|