Swapping Programs - Sharp MZ-80B Basic Manual

Personal computer double precision disc
Hide thumbs Also See for MZ-80B:
Table of Contents

Advertisement

1. 7 Swapping programs

The SWAP st at ement reads a program from a diskett e file, overlays anot her program wit h it or links
t hem, and leaves cont rol t o t hat program t ext, resu ming cont rol by t he original program t he inst ant
t he execut ion of t he t ext h as been complet ed . Su ch behaviou r is ju st t he same as referring t o a su b­
rout ine in a t ext; a fet ched program retu rns t o t he locat ion next t o t he one t hat has been su bject ed t o
t he SWAP st at emen t, Hence, t he SWAP st at ement can be grasped as a su brout ine call. To achieve t he
above-ment ioned act ion correct ly a program t ext t hat has t he SWAP st at ement mu st be t emporarily
st ored in a diskett e before t he execut ion of swapping . The program cont rol process cannot t hen retu rn
t o t he st ored original program t ext before t he t ext area is renewed and t he su bprogram is called and
complet ely execut ed . The SWAP st at ement is generally available in t he following form.
SWAP FDd@v , " file name"
This form orders t he syst em t o swap a su bprogram specified by " f ile name" t hat is st ored on t he
diskett e wit h vol u me nu mber v present in drive d (d
execut ion of a su bprogram occu rs ont o t he diskett e present in t he drive t ha t has last execut ed t he D I R
F Dd command. This means t hat t he drive mu st b e loaded wit h a diskett e t hat allows t emporary writ ­
ing of a program t ext. The swapping level mu st be less t han 1 .
Let' s follow t he program file behaviou r by t aking a simple example in order t o u nderst and t he
SWAP st at ement . How does t he file when t he D I R FD 1 command is execut ed?
o
m
[P r
g r a
present in t he t ext ar ea]
1 0 REM COMPOSER
+
20 M l $
" A7B6
+
+
=
3 0 M 2 $
" B
C
=
40 M3 $
" + F6A3
=
5 0 PRINT " PLAY THE CELLO"
60 SWAP F D 2@7 , "PLAYE R"
70 PRINT " VERY GOOD"
80 E ND
[P r
I
C3A7A3 "
20 MUSIC M l $, M 2 $, M3 $
D + E6A3 "
3 0 PRINT " OK?"
+
E7"
40 END
This file is present on slave diskette
No. 7 inserted in drive No. 2.
1 t o 4). St oring of a program t ext prior t o
=
o
m
g r a
file "PLAYER"]
0 REM CELLO PLAYER
l
13

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents