ZX Computings - OpenLibra
ZX Computings - OpenLibra
ZX Computings - OpenLibra
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Machine code<br />
First steps in Machine<br />
code<br />
There seems to be a myth surrounding<br />
<strong>ZX</strong>81 machine code.<br />
For some strange reason it is a<br />
common belief that programming<br />
in machine code is not easy.<br />
Indeed there are even people<br />
who would go as far as to call it<br />
difficult. Suffice to say this is<br />
not the case for, while it is true<br />
that the use of machine code<br />
was omitted from the Sinclair<br />
Manual, all you need is one little<br />
(BASIC) program taken from<br />
the book. Mastering Machine<br />
Code On Your <strong>ZX</strong>81. to get you<br />
started. Here it is . . .<br />
10<br />
20<br />
30<br />
40<br />
50<br />
60<br />
70<br />
80<br />
INPUT X<br />
LET A*-" "<br />
IF A$ » " " THEN INPUT A$<br />
IF A* -"S" THEN STOP<br />
POKE X. 16*CODE A$ +<br />
CODE A»(2)-476<br />
LET X - X + 1<br />
LET AS AS(3 TO) note<br />
there is nothing between<br />
"TO" and "I"<br />
GOTO 30<br />
Now obviously there isn't<br />
enough room in this article for<br />
Machine code may seem<br />
bewildering, but Toni Baker —<br />
author of Mastering Machine Code<br />
on Your <strong>ZX</strong>81 or <strong>ZX</strong>80 — is<br />
convinced the whole subject is a<br />
piece of cake. Here, Toni<br />
attempts to convince you, with a<br />
clever screen-handling routine<br />
and the raw ingredients of a<br />
BREAKOUT game.<br />
me to teach the whole of<br />
machine code from scratch —<br />
that would be like trying to<br />
squash Sinclair's BASIC<br />
Manual into two or three pages<br />
— so instead I'll give you one or<br />
two little machine code<br />
routines which you can use in<br />
your own BASIC programs.<br />
Try this one. Load the above<br />
program, then add the following<br />
line:<br />
1 REM 123456789023456789<br />
Now RUN the program and input:<br />
16514<br />
"2A0C40"<br />
"0618"<br />
"23"<br />
"7E"<br />
"EE80"<br />
"FEF6"<br />
"2803"<br />
"77"<br />
"18F5"<br />
"10F3"<br />
"C9"<br />
Machine<br />
code address<br />
LD HL.<br />
(D FILE)<br />
LD B,<br />
twentyfour<br />
LOOP: INC HL<br />
LD A.IHL)<br />
XOR80h<br />
CP F6h<br />
HR Z.EXIT<br />
LD (HL).A<br />
JR LOOP<br />
EXIT: DJNZ LOOP<br />
RET<br />
Now please note — you do not<br />
need to understand what I've<br />
written in the right-hand col<br />
umn. All you need to do is enter<br />
what's written in the left column.<br />
When you've done that<br />
type "S" to stop the program.<br />
Now add these lines:<br />
100 IF INKEY$ < >*' " THEN<br />
GOTO 100<br />
105 IF INKEYt = " " THEN GOTO<br />
105<br />
110 RAND USR 16514<br />
120 GOTO 100<br />
46 <strong>ZX</strong> COMPUTING SUMMER 1962 <strong>ZX</strong> C<br />
Gf<br />
IK<br />
Sq<br />
M<br />
ad<br />
vo<br />
IK<br />
Mj<br />
Ca<br />
Pa<br />
1K<br />
BR<br />
36 I<br />
ST{