
APPENDIX B
PROGRAM SHELLS AND
I/O SUBROUTINES
Shell foe the Atari ST computers.
text
Your program goes here
<PROGRAM>
Return to system.
fini: move.w #0,-(sp)
trap <1
Subroutines
putc: movem.l d0-d7/a0-a6,-(sp)
andi.l #5ff,d0
dOr-(sp)
*2,-(sp)
*1
*4,sp
(sp)+,d0-d7/a0-a6
move.w
move.w
trap
addq.1
movem.1
rts
getc:
movem.l dl-d7/a0-a6,-(sp)
move.w #l,-(sp)
trap il
andi.l #$7f,d0
addg.l #2,sp
movem.l (sp)+,dl-d7/a0-a6
rts
save regs.
make sure we have only a byte
push arg. on stack
dos function 2
trap to dos
clean up stack
restore regs.
return
save regs.
dos function 1
trap to dos
mask to 7 bits
clean up stack
restore regs.
return
The following subroutine to input a decimal number accumulates
the number by multiplying the partially accumulated number by ten
and adding in the current digit. A double precision multiply is
performed to allow a full 32 bit number to be entered.
indecO:
indec: movem.l
clr .1
jar
subi.b
bit
cmp.b
/jointfilesconvert/427777/bgt
move.w
clr .w
swap
mulu
swap
mulu
add.l
add.l
bra
indedt move.l
dl-d2,-(sp)
dl
getc
I'O’rdO
indecl
*9,d0
indecl
dl,d2
dl
dl
*10,dl
dl
*10,d2
d2,dl
d0,dl
indecO
dl,d0
save registers
initialize number to zero
get a character
make ascii into digit
terminate if not a digit
not a digit i > 9
also terminate if so
save low order word of number
clear low order word
move high word to low word
multiply by ten
put result back in high word
multiply low order word of number by ten
add low order word to high order word
add in the current digit
get another digit
move number into dO
Kommentare zu diesen Handbüchern