Adapted to new assembler and made re-entrant.

This commit is contained in:
ceriel 1986-07-22 13:37:16 +00:00
parent f514411cea
commit 399a46eb92
37 changed files with 452 additions and 292 deletions

View file

@ -1,4 +1,4 @@
tail_em.a libem_s.a
ari.s ari.s
ara.s ara.s
cvf.s cvf.s
@ -30,4 +30,3 @@ trp.s
dia.s dia.s
printf.s printf.s
dvu.s dvu.s
sav.s

View file

@ -1,17 +1,33 @@
# $Header$ # $Header$
install: MACH=m68k4
../../install tail_em.a tail_em install: all
../../install end.s end_em ../../install head_em.o head_em
../../install libem_o.a tail_em.rt
../../install end.o end_em
cmp: cmp: all
-../../compare tail_em.a tail_em -../../compare head_em.o head_em
-../../compare end.s end_em -../../compare libem_o.a tail_em.rt
-../../compare end.o end_em
clean : all: head_em.o libem_o.a end.o
end.o: end.s
$(MACH) -I../../../h -c end.s
head_em.o: head_em.s
$(MACH) -I../../../h -c head_em.s
libem_o.a: libem_s.a
ASAR=aal ; export ASAR ;\
march . libem_o.a
clean:
rm -f *.o
opr : opr :
make pr | opr make pr | opr
pr: pr:
@arch pv tail_em.a | pr -h `pwd`/tail_em.a @pr `pwd`/head_em.s
@pr `pwd`/end.s @arch pv libem_s.a | pr -h `pwd`/libem_s.a
@pr `pwd`/end.s

View file

@ -1,9 +1,13 @@
.define .outch1,.outch2,.inch1,.inch2 .define .outch1,.outch2,.inch1,.inch2
.sect .text
.sect .rom
.sect .data
.sect .bss
! a0,d4 used ! a0,d0 used
! character in d1 ! character in d1
.text .sect .text
.inch1: .inch1:
move.l #acia1,a0 move.l #acia1,a0
bra .inch bra .inch
@ -23,11 +27,10 @@
.outch2: .outch2:
move.l #acia2,a0 move.l #acia2,a0
.outch: .outch:
move.b (a0),d4 move.b (a0),d0
asr #2,d4 asr #2,d0
bcc .outch bcc .outch
move.b d1,2(a0) move.b d1,2(a0)
rts rts
.align 2 .align 2

View file

@ -1,15 +1,18 @@
.define .sar .define .sar
.define .lar .define .lar
.define .aar .define .aar
.sect .text
.sect .rom
.sect .data
.sect .bss
!register usage: !register usage:
! a0 : descriptor address ! a0 : descriptor address
! d0 : index ! d0 : index
! a1 : base address ! a1 : base address
.text .sect .text
.aar: .aar:
movem.l d0/d1/a0/a1,.savreg move.l (sp)+,d2 ! return address
move.l (sp)+,.retara ! return address
move.l (sp)+,a0 ! descriptor address move.l (sp)+,a0 ! descriptor address
move.l (sp)+,d0 ! index move.l (sp)+,d0 ! index
move.l (sp)+,a1 ! base address move.l (sp)+,a1 ! base address
@ -19,85 +22,77 @@
jsr .mlu jsr .mlu
add.l d1,a1 ! address of element add.l d1,a1 ! address of element
move.l a1,-(sp) ! returned on stack move.l a1,-(sp) ! returned on stack
move.l .retara,-(sp) move.l d2,-(sp)
movem.l d0/d1/a0/a1,.savreg
rts rts
.lar: .lar:
! register usage: like .aar ! register usage: like .aar
! d2 : # bytes / element
movem.l d0/d1/d2/a0/a1,.savreg move.l (sp)+,d2 ! return address
move.l (sp)+,.retara ! return address
move.l (sp)+,a0 move.l (sp)+,a0
move.l (sp)+,d0 move.l (sp)+,d0
move.l (sp)+,a1 move.l (sp)+,a1
sub.l (a0),d0 sub.l (a0),d0
move.l 8(a0),d2 ! # bytes / element
move.l d0,-(sp) move.l d0,-(sp)
move.l d2,-(sp) move.l 8(a0),d0
move.l d0,-(sp)
jsr .mlu jsr .mlu
add.l d1,a1 ! address of element add.l d1,a1 ! address of element
add.l d2,a1 ! a1++ because of predecrement add.l 8(a0),a1 ! a1++ because of predecrement
clr.l d1 !?nodig? clr.l d1 !?nodig?
asr #1,d2 asr #1,d0
bne 3f bne 3f
move.b -(a1),d1 ! 1 byte element move.b -(a1),d1 ! 1 byte element
move.l d1,-(sp) move.l d1,-(sp)
bra 5f bra 5f
3: 3:
asr #1,d2 asr #1,d0
bne 4f bne 4f
move.w -(a1),d1 ! 2 byte element move.w -(a1),d1 ! 2 byte element
move.l d1,-(sp) move.l d1,-(sp)
bra 5f bra 5f
4: 4:
sub.l #1,d2 sub.l #1,d0
1: 1:
move.l -(a1),-(sp) ! 4n byte element (n = 1,2,...) move.l -(a1),-(sp) ! 4n byte element (n = 1,2,...)
dbf d2,1b dbf d0,1b
5: 5:
move.l .retara,-(sp) move.l d2,-(sp)
movem.l .savreg,d0/d1/d2/a0/a1
rts rts
.sar: .sar:
!register usage: same as lar !register usage: same as lar
movem.l d0/d1/a0/a1,.savreg move.l (sp)+,d2
move.l (sp)+,.retara
move.l (sp)+,a0 move.l (sp)+,a0
move.l (sp)+,d0 move.l (sp)+,d0
move.l (sp)+,a1 move.l (sp)+,a1
sub.l (a0),d0 sub.l (a0),d0
move.l 8(a0),d2 ! # bytes / element
move.l d0,-(sp) move.l d0,-(sp)
move.l d2,-(sp) move.l 8(a0),d0 ! # bytes / element
move.l d0,-(sp)
jsr .mlu jsr .mlu
add.l d1,a1 add.l d1,a1
clr.l d1 !?nodig? clr.l d1 !?nodig?
asr #1,d2 asr #1,d0
bne 3f bne 3f
move.l (sp)+,d1 move.l (sp)+,d1
move.b d1,(a1) ! 1 byte element move.b d1,(a1) ! 1 byte element
bra 4f bra 4f
3: 3:
asr #1,d2 asr #1,d0
bne 5f bne 5f
move.l (sp)+,d1 move.l (sp)+,d1
move.w d1,(a1) ! 2 byte element move.w d1,(a1) ! 2 byte element
bra 4f bra 4f
5: 5:
sub.l #1,d2 sub.l #1,d0
1: 1:
move.l (sp)+,(a1)+ ! 4n byte element (n = 1,2,...) move.l (sp)+,(a1)+ ! 4n byte element (n = 1,2,...)
dbf d2,1b dbf d0,1b
4: 4:
move.l .retara,-(sp) move.l d2,-(sp)
movem.l .savreg,d0/d1/a0/a1
rts rts
.data
.retara: .long 0
.align 2 .align 2

View file

@ -1,36 +1,36 @@
.define .sari .define .sari
.define .lari .define .lari
.define .aari .define .aari
.sect .text
.sect .rom
.sect .data
.sect .bss
.text .sect .text
.aari: .aari:
move.l (sp)+,.retari ! return address move.l (sp)+,d0 ! return address
cmp.l #4, (sp)+ ! size of descriptor elements cmp.l #4, (sp)+ ! size of descriptor elements
bne 9f bne 9f
jsr .aar move.l d0,-(sp)
move.l .retari,-(sp) jmp .aar
rts
.lari: .lari:
move.l (sp)+,.retari ! return address move.l (sp)+,d0 ! return address
cmp.l #4, (sp)+ ! size of descriptor elements cmp.l #4, (sp)+ ! size of descriptor elements
bne 9f bne 9f
jsr .lar move.l d0,-(sp)
move.l .retari,-(sp) jmp .lar
rts
9: 9:
move.w #EILLINS,-(sp) move.w #EILLINS,-(sp)
jmp .fat jmp .fat
.sari: .sari:
move.l (sp)+,.retari ! return address move.l (sp)+,d0 ! return address
cmp.l #4, (sp)+ ! size of descriptor elements cmp.l #4, (sp)+ ! size of descriptor elements
bne 9b bne 9b
jsr .sar move.l d0,-(sp)
move.l .retari,-(sp) jmp .sar
rts
.data
.retari: .long 0
.align 2 .align 2

View file

@ -1,8 +1,11 @@
.define .cii .define .cii
.sect .text
.sect .rom
.sect .data
.sect .bss
.text .sect .text
.cii: .cii:
movem.l a0/d0/d1,.savreg
move.l (sp)+,a0 ! return address move.l (sp)+,a0 ! return address
move (sp)+,d0 ! destination size move (sp)+,d0 ! destination size
sub (sp)+,d0 ! destination - source size sub (sp)+,d0 ! destination - source size
@ -19,6 +22,6 @@
dbf d0,2b dbf d0,2b
3: 3:
move.l a0,-(sp) move.l a0,-(sp)
movem.l .savreg,a0/d0/d1
rts rts
.align 2 .align 2

View file

@ -1,12 +1,15 @@
.define .cmi, .cmi_ .define .cmi, .cmi_
.sect .text
.sect .rom
.sect .data
.sect .bss
! NUM == 4 ! NUM == 4
! result in d1 ! result in d1
.text .sect .text
.cmi: .cmi:
.cmi_: .cmi_:
move.l (sp)+,.savret move.l (sp)+,d2
move.l d0,.savd0
move.l #1,d1 move.l #1,d1
move.l (sp)+,d0 move.l (sp)+,d0
cmp.l (sp)+,d0 cmp.l (sp)+,d0
@ -16,7 +19,7 @@
ble 2f ble 2f
neg.l d1 neg.l d1
2: 2:
move.l .savd0,d0 move.l d2,-(sp)
move.l .savret,-(sp)
rts rts
.align 2 .align 2

View file

@ -1,9 +1,12 @@
.define .cmp .define .cmp
.sect .text
.sect .rom
.sect .data
.sect .bss
.text .sect .text
.cmp: .cmp:
move.l (sp)+,.savret ! return address move.l (sp)+,d2 ! return address
move.l d0,.savd0
move.l #1,d1 move.l #1,d1
move.l (sp)+,d0 move.l (sp)+,d0
cmp.l (sp)+,d0 cmp.l (sp)+,d0
@ -13,7 +16,7 @@
bcs 2f bcs 2f
neg.l d1 neg.l d1
2: 2:
move.l .savd0,d0 move.l d2,-(sp)
move.l .savret,-(sp)
rts rts
.align 2 .align 2

View file

@ -1,8 +1,12 @@
.define .cms .define .cms
.sect .text
.sect .rom
.sect .data
.sect .bss
! d0 contains set size ! d0 contains set size
.text .sect .text
.cms: .cms:
move.l (sp)+,a2 ! return address move.l (sp)+,a2 ! return address
move.l sp,a0 move.l sp,a0

View file

@ -1,12 +1,15 @@
.define .cmu .define .cmu
.sect .text
.sect .rom
.sect .data
.sect .bss
! d0 : # bytes of 1 block ! d0 : # bytes of 1 block
.text .sect .text
.cmu: .cmu:
movem.l d2/a0/a1/a2,.savreg
move.l (sp)+,a2 ! reta
move.l sp,a0 ! top block move.l sp,a0 ! top block
move.l sp,a1 add.l #4,a0
move.l a0,a1
add.l d0,a1 ! lower block add.l d0,a1 ! lower block
move.l d0,d2 move.l d0,d2
asr.l #2,d0 asr.l #2,d0
@ -22,8 +25,8 @@
neg.l d1 ! less neg.l d1 ! less
3: 3:
asl.l #1,d2 asl.l #1,d2
move.l (sp)+,a0
add.l d2,sp ! new sp add.l d2,sp ! new sp
move.l a2,-(sp) jmp (a0)
movem.l .savreg,d2/a0/a1/a2
rts
.align 2 .align 2

View file

@ -1,8 +1,11 @@
.define .csa .define .csa
.sect .text
.sect .rom
.sect .data
.sect .bss
.text .sect .text
.csa: .csa:
movem.l d0/a0/a1/a2,.savreg
move.l (sp)+,a0 ! case descriptor move.l (sp)+,a0 ! case descriptor
move.l (sp)+,d0 ! index move.l (sp)+,d0 ! index
move.l (a0)+,a1 ! default address move.l (a0)+,a1 ! default address
@ -21,9 +24,9 @@
beq 2f beq 2f
move.l a1,-(sp) ! jump address move.l a1,-(sp) ! jump address
3: 3:
movem.l .savreg,d0/a0/a1/a2
rts ! not a real rts rts ! not a real rts
2: 2:
move.w #ECASE,-(sp) move.w #ECASE,-(sp)
jmp .fat jmp .fat
.align 2 .align 2

View file

@ -1,8 +1,11 @@
.define .csb .define .csb
.sect .text
.sect .rom
.sect .data
.sect .bss
.text .sect .text
.csb: .csb:
movem.l d0/d1/a0/a1,.savreg
move.l (sp)+,a0 ! case descriptor move.l (sp)+,a0 ! case descriptor
move.l (sp)+,d0 ! index move.l (sp)+,d0 ! index
move.l (a0)+,a1 ! default jump address move.l (a0)+,a1 ! default jump address
@ -23,6 +26,5 @@
move.l (a0)+,a1 ! get jump address move.l (a0)+,a1 ! get jump address
4: 4:
move.l a1,-(sp) move.l a1,-(sp)
movem.l .savreg,d0/d1/a0/a1
rts rts
.align 2 .align 2

View file

@ -1,8 +1,12 @@
.define .ciu .define .ciu
.define .cui .define .cui
.define .cuu .define .cuu
.sect .text
.sect .rom
.sect .data
.sect .bss
.text .sect .text
.ciu: .ciu:
.cui: .cui:
.cuu: .cuu:
@ -18,4 +22,5 @@
clr -(sp) clr -(sp)
dbf d0,2b dbf d0,2b
jmp (a0) jmp (a0)
.align 2 .align 2

View file

@ -1,6 +1,10 @@
.define .cfi,.cif,.cfu,.cuf,.cff .define .cfi,.cif,.cfu,.cuf,.cff
.sect .text
.sect .rom
.sect .data
.sect .bss
.text .sect .text
! this is a dummy float conversion routine ! this is a dummy float conversion routine
.cfi: .cfi:
@ -13,4 +17,5 @@
sub (sp)+,d0 ! diff. in sizes sub (sp)+,d0 ! diff. in sizes
sub d0,sp sub d0,sp
jmp (a0) jmp (a0)
.align 2 .align 2

View file

@ -1,12 +1,16 @@
.define .diagnos .define .diagnos
.sect .text
.sect .rom
.sect .data
.sect .bss
space = 040 space = 040
del = 0177 del = 0177
.text .sect .text
.diagnos: .diagnos:
move.l hol0,-(sp) move.l hol0,-(sp)
move.l hol0+FILN_AD,d2 move.l hol0+4,d2
beq 1f beq 1f
move.l d2,a0 move.l d2,a0
move.l #40,d0 move.l #40,d0
@ -31,7 +35,7 @@ del = 0177
move.l #unknwn,d2 move.l #unknwn,d2
bra 2b bra 2b
.data .sect .data
fmt: .asciz "%s, line %d: " fmt: .asciz "%s, line %d: "
unknwn: .asciz "unknown file" unknwn: .asciz "unknown file"
.align 2 .align 2

View file

@ -1,12 +1,15 @@
.define .dvi .define .dvi
.sect .text
.sect .rom
.sect .data
.sect .bss
! signed long divide ! signed long divide
.text .sect .text
.dvi: .dvi:
movem.l d0/d4,.savdvi move.l 4(sp),d0
move.l (sp)+,.retdvi move.l 8(sp),d1
move.l (sp)+,d0 move.l d4,-(sp)
move.l (sp)+,d1
clr.l d4 clr.l d4
tst.l d0 ! divisor tst.l d0 ! divisor
bpl 1f bpl 1f
@ -32,11 +35,10 @@
bpl 6f bpl 6f
neg.l d2 ! remainder neg.l d2 ! remainder
6: 6:
movem.l .savdvi,d0/d4 move.l (sp)+,d4
move.l .retdvi,-(sp) move.l (sp)+,a0
add.l #8,sp
move.l a0,-(sp)
rts rts
.data
.savdvi: .space 12
.retdvi: .long 0
.text
.align 2 .align 2

View file

@ -1,4 +1,8 @@
.define .dvu .define .dvu
.sect .text
.sect .rom
.sect .data
.sect .bss
! unsigned long divide ! unsigned long divide
! register usage: ! register usage:
@ -6,12 +10,11 @@
! d1 dividend ! d1 dividend
! exit : d1 quotient ! exit : d1 quotient
! d2 remainder ! d2 remainder
.text .sect .text
.dvu: .dvu:
movem.l d0/d3,.savreg move.l 4(sp),d0
move.l (sp)+,.savret move.l 8(sp),d1
move.l (sp)+,d0 move.l d3,-(sp)
move.l (sp)+,d1
tst.l d0 tst.l d0
bne 0f bne 0f
move.w #EIDIVZ,-(sp) move.w #EIDIVZ,-(sp)
@ -28,7 +31,10 @@
add #1,d1 add #1,d1
4: 4:
dbf d3,3b dbf d3,3b
movem.l .savreg,d0/d3 move.l (sp)+,d3
move.l .savret,-(sp) move.l (sp)+,a0
add.l #8,sp
move.l a0,-(sp)
rts rts
.align 2 .align 2

View file

@ -1,15 +1,16 @@
.define endtext,enddata,endbss .define endtext,enddata,endbss,_etext,_edata,_end
.define _end, _etext, _edata .sect .text
.sect .rom
.sect .data
.sect .bss
.sect .end ! only for declaration of _end and endbss.
.text .sect .text
endtext: endtext:
_etext: _etext:
.align 4 .sect .data
.data
enddata: enddata:
_edata: _edata:
.align 4 .sect .end
.bss
.align 4
endbss:
_end: _end:
endbss:

View file

@ -1,10 +1,13 @@
.define .exg .define .exg
.sect .text
.sect .rom
.sect .data
.sect .bss
! d0 : exchange size in bytes ! d0 : exchange size in bytes
.text .sect .text
.exg: .exg:
move.l (sp)+,.savret move.l (sp)+,d2
movem.l d1/a1/a2,.savreg
move.l sp,a1 move.l sp,a1
sub.l d0,sp sub.l d0,sp
move.l sp,a2 move.l sp,a2
@ -21,6 +24,5 @@
sub #1,d1 sub #1,d1
bgt 1b bgt 1b
move.l a1,sp move.l a1,sp
movem.l .savreg,d1/a1/a2 move.l d2,-(sp)
move.l .savret,-(sp)
rts rts

View file

@ -1,6 +1,10 @@
.define .fat .define .fat
.sect .text
.sect .rom
.sect .data
.sect .bss
.text .sect .text
.fat: .fat:
jsr .trp jsr .trp
jmp EXIT jmp EXIT

View file

@ -1,16 +1,19 @@
.define .inn .define .inn
.sect .text
.sect .rom
.sect .data
.sect .bss
! d0 : set size in bytes ! d0 : set size in bytes
! d1 : bitnumber ! d1 : bitnumber
.text .sect .text
.inn: .inn:
movem.l d1/d2/a0/a1,.savreg move.l (sp)+,a1
move.l (sp)+,.savret
move.l (sp)+,d1 move.l (sp)+,d1
move.l sp,a1 move.l d0,-(sp)
add.l d0,a1
move.l sp,a0 move.l sp,a0
add.l #4,a0
move.l d1,d2 move.l d1,d2
asr.l #4,d2 asr.l #4,d2
!bchg.l #0,d2 !bchg.l #0,d2
@ -25,7 +28,7 @@
1: 1:
clr.l d0 clr.l d0
2: 2:
move.l a1,sp move.l (sp)+,d1
movem.l .savreg,d1/d2/a0/a1 add.l d1,sp
move.l .savret,-(sp) move.l a1,-(sp)
rts rts

View file

@ -1,6 +1,10 @@
.define .lfr .define .lfr
.sect .text
.sect .rom
.sect .data
.sect .bss
.text .sect .text
.lfr: .lfr:
move.l (sp)+,a0 move.l (sp)+,a0
cmp #2,d7 cmp #2,d7

View file

@ -1,11 +1,14 @@
.define .los .define .los
.sect .text
.sect .rom
.sect .data
.sect .bss
! d0 : # bytes ! d0 : # bytes
! a0 : source address ! a0 : source address
.text .sect .text
.los: .los:
movem.l d0/a0,.savreg move.l (sp)+,a1
move.l (sp)+,.savret
move.l (sp)+,d0 move.l (sp)+,d0
move.l (sp)+,a0 move.l (sp)+,a0
cmp.l #1,d0 cmp.l #1,d0
@ -30,7 +33,5 @@
sub.l #1,d0 sub.l #1,d0
bgt 4b bgt 4b
3: 3:
movem.l .savreg,d0/a0 jmp (a1)
move.l .savret,-(sp)
rts
.align 2 .align 2

View file

@ -1,12 +1,15 @@
.define .mli .define .mli
.sect .text
.sect .rom
.sect .data
.sect .bss
.text .sect .text
.mli: .mli:
move.l d5,.savmli move.l 4(sp),d1
move.l (sp)+,.retmli move.l 8(sp),d0
move.l (sp)+,d1 move.l d5,-(sp)
move.l (sp)+,d0
clr d5 clr d5
tst.l d0 tst.l d0
bpl 1f bpl 1f
@ -26,11 +29,9 @@
neg.l d1 neg.l d1
negx.l d0 negx.l d0
3: 3:
move.l .savmli,d5 move.l (sp)+,d5
move.l .retmli,-(sp) move.l (sp)+,a0
rts add.l #8,sp
.data jmp (a0)
.savmli: .long 0
.retmli: .long 0
.text
.align 2 .align 2

View file

@ -1,20 +1,24 @@
.define .mlu .define .mlu
.sect .text
.sect .rom
.sect .data
.sect .bss
! entry : d0 multiplicand ! entry : d0 multiplicand
! d1 multiplier ! d1 multiplier
! exit : d0 high order result ! exit : d0 high order result
! d1 low order result ! d1 low order result
.text .sect .text
.mlu: .mlu:
move.l (sp)+,.savret movem.l d3/d4/d6,-(sp)
move.l (sp)+,d1 move.l 16(sp),d1
move.l (sp)+,d0 move.l 20(sp),d0
cmp.l #32768,d0 cmp.l #32768,d0
bgt 1f bgt 1f
cmp.l #32768,d1 cmp.l #32768,d1
bls 2f bls 2f
1: movem.l d2/d3/d4/d6,.savreg 1:
move.l d1,d3 move.l d1,d3
move.l d1,d2 move.l d1,d2
swap d2 swap d2
@ -36,12 +40,13 @@
swap d2 swap d2
swap d3 swap d3
add.l d2,d0 add.l d2,d0
add.l d3,d0 add.l d3,a0
movem.l .savreg,d2/d3/d4/d6 bra 3f
move.l .savret,-(sp)
rts
2: mulu d0,d1 2: mulu d0,d1
clr d0 clr d0
move.l .savret,-(sp) 3:
rts movem.l (sp)+,d3/d4/d6
move.l (sp)+,a0
add #8,sp
jmp (a0)
.align 2 .align 2

View file

@ -1,12 +1,17 @@
.define .mon .define .mon
.text .sect .text
.sect .rom
.sect .data
.sect .bss
.sect .text
.mon: .mon:
move.l (sp)+,a0 move.l (sp)+,a0
pea fmt pea fmt
jsr .diagnos jsr .diagnos
add #6,sp add #8,sp
jmp EXIT jmp EXIT
.data .sect .data
fmt: .asciz "system call %d not implemented" fmt: .asciz "system call %d not implemented"
.align 2 .align 2

View file

@ -1,6 +1,10 @@
.define .nop .define .nop
.sect .text
.sect .rom
.sect .data
.sect .bss
.text .sect .text
.nop: .nop:
pea 4(sp) pea 4(sp)
move.l hol0,-(sp) move.l hol0,-(sp)
@ -9,6 +13,6 @@
add.l #12,sp add.l #12,sp
rts rts
.data .sect .data
fmt: .asciz "test %d, sp %d\n" fmt: .asciz "test %d, sp %d\n"
.align 2 .align 2

View file

@ -1,78 +1,125 @@
.sect .text;.sect .rom;.sect .data;.sect .bss
.define _printn
.define _printf .define _printf
.define _putchar .extern _printf
.define _getal .sect .text
.define _char
.bss
_getal:
.space 12
_char:
.space 1
.align 2
.data
sav:
.long 0
.text
_printf:
movem.l d0/d1/d2/a0/a1/a2/a3/a4/a5/a6,.savreg
move.l (sp)+,sav !return address
move.l sp,a6 !a6 <- address of arguments
move.l (a6)+,a5 !a5 <- address of format
clr.l d0 !d0 <- char to be printed
next: move.b (a5)+,d0
beq out
cmp.b #'%',d0
beq procnt
put: move.l d0,-(sp)
jsr _putchar !argument is long en op de stack
tst.l (sp)+
jmp next
procnt: move.b (a5)+,d0
cmp.b #'d',d0 !NOTE: %d means unsigned.
beq digit
cmp.b #'s',d0
beq string
cmp.b #'%',d0 !second % has to be printed.
beq put
tst.b -(a5) !normal char should be printed
jmp next
string: move.l (a6)+,a2 !a2 <- address of string
sloop: move.b (a2)+,d0
beq next
move.l d0,-(sp)
jsr _putchar !argument is long en op de stack
tst.l (sp)+
jmp sloop
digit: move.l (a6)+,d1 !d1 <- integer
move.l #_getal+12,a3 !a3 <- ptr to last part of buf
move.b #0,-(a3) !stringterminator
dloop: move.l d1,-(sp)
move.l #10,-(sp)
jsr .dvu !d1 <- quotient d2 <- remainder
add.l #'0',d2
move.b d2,-(a3)
tst.l d1 !if quotient = 0 then ready
bne dloop
move.l a3,a2
jmp sloop !print digitstring.
out:
move.l sav,-(sp)
movem.l .savreg,d0/d1/d2/a0/a1/a2/a3/a4/a5/a6
rts
_putchar: _putchar:
movem.l d0,.savreg move.l #1,-(sp)
move.l 4(sp),d0 pea 9(sp)
move.b d0,_char move.l #1,-(sp)
move.l #1,-(sp) jsr _write
move.l #_char,-(sp) add.l #12,sp
move.l #1,-(sp) rts
jsr _write _printf:
add.l #12,sp tst.b -56(sp)
movem.l .savreg,d0 link a6,#-16
rts !Local -4 into d7
.align 2 !Local -12 into d6
!Local -8 into a5
!Local 8 into a4
!Local -16 into a3
movem.l d7/d6/a5/a4/a3,-(sp)
move.l 8(a6),a4
lea 12(a6),a1
move.l a1, a5
I0014:
move.l a4, a0
add.l #1,a4
clr.l d0
move.b (a0),d0
move.l d0, d7
cmp.l #37,d7
beq I0015
tst.l d7
beq I0012
move.l d7,-(sp)
jsr _putchar
add #4,sp
jmp I0014
I0015:
move.l a4, a0
add.l #1,a4
clr.l d0
move.b (a0),d0
move.l d0, d7
cmp.l #100,d7
beq I0018
cmp.l #117,d7
bne I0017
I0018:
move.l a5, a0
add.l #4,a5
move.l (a0), d6
cmp.l #100,d7
bne I0019
tst.l d6
bge I0019
clr.l d2
sub.l d6,d2
move.l d2, d6
pea 45
jsr _putchar
add #4,sp
I0019:
move.l d6,-(sp)
jsr _printn
add #4,sp
jmp I0014
I0017:
cmp.l #115,d7
bne I0014
move.l a5, a0
add.l #4,a5
move.l (a0), a3
I001c:
move.l a3, a0
add.l #1,a3
clr.l d0
move.b (a0),d0
move.l d0, d7
tst.l d7
beq I0014
move.l d7,-(sp)
jsr _putchar
add #4,sp
jmp I001c
I0012:
movem.l (sp)+,d7/d6/a5/a4/a3
unlk a6
rts
.extern _printn
_printn:
tst.b -44(sp)
link a6,#-4
!Local -4 into d7
move.l d7,-(sp)
.sect .data
_14:
.data4 808530483
.data4 875902519
.data4 943259648
.sect .text
move.l 8(a6),-(sp)
pea 10
jsr .dvu
move.l d1, d7
tst.l d7
beq I0023
move.l d7,-(sp)
jsr _printn
add #4,sp
I0023:
pea _14
move.l 8(a6),-(sp)
pea 10
jsr .dvu
move.l (sp)+,a1
add.l d2,a1
clr.l d0
move.b (a1),d0
move.l d0,-(sp)
jsr _putchar
add #4,sp
move.l (sp)+,d7
unlk a6
rts

View file

@ -1,9 +1,12 @@
.define .rck .define .rck
.sect .text
.sect .rom
.sect .data
.sect .bss
.text .sect .text
.rck: .rck:
movem.l d0/a0,.savreg move.l (sp)+,a1
move.l (sp)+,.savret
move.l (sp)+,a0 ! descriptor address move.l (sp)+,a0 ! descriptor address
move.l (sp),d0 move.l (sp),d0
cmp.l (a0),d0 cmp.l (a0),d0
@ -14,7 +17,6 @@
move.l #ERANGE,-(sp) move.l #ERANGE,-(sp)
jsr .trp jsr .trp
2: 2:
movem.l .savreg,d0/a0 jmp (a1)
move.l .savret,-(sp)
rts
.align 2 .align 2

View file

@ -1,6 +1,10 @@
.define .ret .define .ret
.sect .text
.sect .rom
.sect .data
.sect .bss
.text .sect .text
.ret: .ret:
beq 3f beq 3f
cmp #2,d0 cmp #2,d0

View file

@ -1,11 +1,14 @@
.define .set .define .set
.sect .text
.sect .rom
.sect .data
.sect .bss
! d0 : setsize in bytes ! d0 : setsize in bytes
! d1 : bitnumber ! d1 : bitnumber
.text .sect .text
.set: .set:
movem.l d1/d2/a1,.savreg move.l (sp)+,a0
move.l (sp)+,.savret
move.l (sp)+,d1 move.l (sp)+,d1
move.l d0,d2 move.l d0,d2
asr.l #2,d2 asr.l #2,d2
@ -20,13 +23,10 @@
cmp.l d0,d2 cmp.l d0,d2
bcs 1f bcs 1f
move.w #ESET,-(sp) move.w #ESET,-(sp)
move.l .savret,-(sp) jsr .trp
jmp .trp
1: 1:
add.l d2,a1 add.l d2,a1
move.l (a1),d2 move.l (a1),d2
bset d1,d2 bset d1,d2
move.l d2,(a1) move.l d2,(a1)
movem.l .savreg,d1/d2/a1 jmp (a0)
move.l .savret,-(sp)
rts

View file

@ -1,9 +1,12 @@
.define .strhp .define .strhp
.sect .text
.sect .rom
.sect .data
.sect .bss
.text .sect .text
.strhp: .strhp:
move.l d0,.savreg move.l (sp)+,a0
move.l (sp)+,.savret
move.l (sp)+,d0 ! heap pointer move.l (sp)+,d0 ! heap pointer
move.l d0,.reghp move.l d0,.reghp
cmp.l .limhp,d0 cmp.l .limhp,d0
@ -14,9 +17,7 @@
cmp.l d0,sp cmp.l d0,sp
ble 2f ble 2f
1: 1:
move.l .savreg,d0 jmp (a0)
move.l .savret,-(sp)
rts
2: 2:
move.w #EHEAP,-(sp) move.w #EHEAP,-(sp)
jmp .fat jmp .fat

View file

@ -1,13 +1,14 @@
.define .sig .define .sig
.sect .text
.sect .rom
.sect .data
.sect .bss
.text .sect .text
.sig: .sig:
movem.l a1/a2,.savreg move.l (sp)+,a0
move.l (sp)+,.savret
move.l (sp)+,a1 ! trap pc move.l (sp)+,a1 ! trap pc
move.l .trppc,-(sp) move.l .trppc,-(sp)
move.l a1,.trppc move.l a1,.trppc
movem.l .savreg,a1/a2 jmp (a0)
move.l .savret,-(sp)
rts
.align 2 .align 2

View file

@ -1,11 +1,14 @@
.define .sts .define .sts
.sect .text
.sect .rom
.sect .data
.sect .bss
! d0 : # bytes ! d0 : # bytes
! a0 : destination address ! a0 : destination address
.text .sect .text
.sts: .sts:
movem.l d0/a0,.savreg move.l (sp)+,a1
move.l (sp)+,.savret
move.l (sp)+,d0 move.l (sp)+,d0
move.l (sp)+,a0 move.l (sp)+,a0
cmp #1,d0 cmp #1,d0
@ -27,7 +30,5 @@
move.l (sp)+,(a0)+ move.l (sp)+,(a0)+
dbf d0,3b dbf d0,3b
4: 4:
movem.l .savreg,d0/a0 jmp (a1)
move.l .savret,-(sp)
rts
.align 2 .align 2

View file

@ -1,18 +1,22 @@
.extern _errno .extern _errno
.data .sect .text
.sect .rom
.sect .data
.sect .bss
.sect .data
_errno: _errno:
.extern _lseek .extern _lseek
.short 0 .short 0
.text .sect .text
_lseek: _lseek:
link a6,#-0 link a6,#-0
.data .sect .data
_13: _13:
.short 29561 .short 29561
.short 29489 .short 29489
.short 11875 .short 11875
.short 0 .short 0
.text .sect .text
move.l #_13,.filn move.l #_13,.filn
move.w #8,.lino move.w #8,.lino
move.w #0,-(sp) move.w #0,-(sp)

View file

@ -1,7 +1,11 @@
.extern _exit .extern _exit
.sect .text
.sect .rom
.sect .data
.sect .bss
! Fake system call for 68000 running MACSBUG ! Fake system call for 68000 running MACSBUG
.text .sect .text
_exit: _exit:
jmp 0x0200f6 jmp 0x0200f6

View file

@ -1,31 +1,41 @@
.define .trp .define .trp
.sect .text
.sect .rom
.sect .data
.sect .bss
.text .sect .text
.trp: .trp:
move.l (sp)+,a2 ! return address cmp.l #16,4(sp)
move.l (sp)+,d0 ! error number
move.l a2,-(sp)
move.l d0,-(sp)
cmp.l #16,d0
bcc 1f bcc 1f
move.l d0,-(sp)
move.l 8(sp),d0
btst d0,.trpim btst d0,.trpim
bne 3f bne 3f
1: 1:
move.l a0,-(sp)
move.l .trppc,a0 move.l .trppc,a0
move.l a0,d0 move.l a0,d0
beq 9f beq 9f
clr.l .trppc clr.l .trppc
move.l 12(sp),-(sp)
jsr (a0) jsr (a0)
add.l #4,sp
move.l (sp)+,a0
3: 3:
add #4,sp move.l (sp)+,d0
move.l (sp)+,(sp)
rts rts
9: 9:
move.l (sp)+,a0
move.l (sp)+,d0
move.l 4(sp),-(sp)
pea fmt pea fmt
jsr .diagnos jsr .diagnos
add #4,sp add #4,sp
jsr __cleanup jsr __cleanup
jmp EXIT jmp EXIT
.data .sect .data
fmt: .asciz "trap %d called\n" fmt: .asciz "trap %d called\n"
.align 2 .align 2