====== Small Programmes ======
Blanks are significant if among the last 8 characters before a tick, see [[loaderinput|proposal for formatting and comments]]
===== Test halt on overflow =====
As it is rather unusual that the machine stops on overflow, here is a small test program:
halt on overflow
;zzz0700'
/zzz0700'
00 b0016' get start
01 a0017' stops if overflow
u0001' loop
variables:
;zzz0716'
,zzz0002'
16 7ww00000' start
17 00002000' increment
go
.zzz0700'
===== Hello =====
The follwing program to print ''Hello'' on the console is rather untypical:
Print Hello
; 0600'
/ 0600'
xp1600' CR
xz0000' sync
xp0800' UC
xz0000'
xp4900' H
xz0000'
xp0400' LC
xz0000'
xp3700' e
xz0000'
xp0600' l = 1
xz0000'
xp0600' l
xz0000'
xp3500' o
xz0000'
xz0800' pause unless Br8
u0000' repeat
. 0600'
===== Simple Loop =====
Example looping program that prints a given number of asterisks:
simple loop
; 0900'
/ 0900'
00 xp0800' upper case
xz0000' sync
xp1600' CR
xz0000'
b0022' start value
u0007' avoid data wait
06 b0020' get counter
07 s0021' minus step
t0013' done if negative
h0020' save
xp1000' print *
xz0000'
u0006' repeat
13 xz0000' halt
14 u0000' restart
data:
; 0920'
,000 03'
20 00000000' counter
21 00000010' decrement
22 00000050' initial
start:
. 0900'
===== Printing all digits =====
The following example prints all characters in numerical sequence, all digits as an example.
It shows how to modify instructions:
print 10 digits
;zzz0800'
/zzz0800'
00 xp0400' lower case
xz0000'
xp1600' CR
xz0000'
04 xp0200' print 0
xz0000'
b0004' last printed
e0022' mask char code
a0020' increment
y0004' save
s0021' end?
t0004' no
12 xz0400' stop for repeat
b0023'
y0004' start over
u0000'
data area:
;zzz0820'
,zzz0004'
20 00000400' increment
21 00002700' last digit 9 = x26, plus 1
22 0000ww00' mask
23 00000200' digit 0
start here:
.zzz0800'
===== Fill and clear a track =====
Fills a track with its sector numbers, and then clears the same track again.
To fill in physical order, use ''0q4'' in location 34; for logical order, use ''004''
If Break 4 is not set, the programme waits before clear;
if Break 8 is not set, it waits after clear before repeat.
fill and clear a track in physical order
;zzz0400'
/zzz0400'
00 c0033' clear acc
c0033' clear sector
02 b0033' get sector
a0032' add track
y0005' set destination
05 hzzzz' store
a0034' advance
e0035' mask sector
h0033' save
s0036' ? >0
t0012' no, done
u0002' yes, repeat
12 z0400' pause unless BR4
c0033' clear track
c0033'
15 b0033'
a0032'
y0019'
c0037' discard and clear
19 hzzzz' clear mem
b0033'
a0034'
e0035'
h0033'
s0036' ? >0
t0027' no, done, again
u0015' yes, repeat
27 z0800' pause unless BR8
u0000'
data area:
;zzz0432'
,zzz0006'
32 00002100' track to fill
33 00000000' current sector
34 000000q4' sector increment
35 000000wj' sector mask
36 00000002' to test for zero
37 00000000' trash to clear acc
start here:
.zzz0400'