Specifications

poke(356+ii,ord(date)) {bytes (or 356 to 366 decimal, inclusive). Eleven}
end; {characters are maximum for the date set.}
writeln;
for ii:=0 to 10 do
write(chr(peek(356+ii)));
writeln
end.
« » «
program timesetsee_pd(input,output); {Enters time and then reads it.}
var
timeset,ii:integer;
begin *
writeln(chr(12));
writeIn('Enter hh,mm,ss,jj without commas, and with a RETURN after each.');
for ii:=0 to 3 do
begin {Time is kept in four consecutive bytes, as follows:}
read (timeset); {$160, hours; $161, rains; $162, sec; $163, jiffies.}
poke(352+ii,timeset) {This converts to 352 through 355, decimal.}
end;
writeln('New time is', peek(352),1:',peek(353),':',peek(354),':',peek(355))
end.
< x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x >
B I T S B I T E S ft HBQUES s by Gary L. Ratliff,Sr.
215 Pemberton Drive, Pearl, Mississippi 39208
Let's answer the questions of the last issue. The first: What alterations to
code are needed if 'pshs d,x' is used in place of: pshs x - tfr d,x - pshs d'.
This method saves considerable time, as each push onto the stack takes five cy
cles, plus one additional cycle for each byte pushed. Pshs x and pshs d, there
fore, account for 14 cycles; five for each push, plus two additional cycles for
each of the two-byte registers. In contrast, 'pshs d,x' needs only nine cycles.
As to what revisions are needed if pshs d,x' is used: As you'll see in the ans
wer to the question of the order of push and pull to the stack, the order of the
registers (relative to the stack pointer) remains the same with the new method,
so that the 'subd ,s' code needs no change. If the order had been reversed, and
the D register had been placed on the stack prior to the X register, then the
'subd ,s' instruction would need revision to 'subd 2,s' to account for this. The
original and revised codes are compared at left. The X register and the D regis-
ster are saved in one step, which kills the need for
the pshs d instruction. The answer in D must now
be placed on the stack, as it will be recovered by
the subsequent pull. This saves some time and also
eliminates one line of code. But isn't it more con
fusing and a little more error prone than the method
used originally?
The second question (what is the order of push and pull to the stack?) is best
answered by a demonstration. We can't use the system stack for this, since it is
used by all interrupts and JSR and RETURN instructions. Instead, we substitute
the user stack and show the order in which registers are pushed and pulled. To
see this, enter the monitor (from the mED with: raon <RETURN>, or from DEVELOP
MENT or main menu with: m <RETURN>). We 'm' for 'modify memory,' starting the
code at $1000. The line of code tells the
>m 1000 ce 20 00 36 ff 3f computer to set the U (for User) Stack to
from to
pshs x pshs x,d
pshs d (eliminate)
ldx 2,s std ,s
leas 4,s puls x,d
SuperPET Gazette, Vol.I No.11
-176-
December 1983/January 1984