Albert Koelmans newest version

This commit is contained in:
ceriel 1990-11-12 17:09:15 +00:00
parent 064258aa8b
commit 0a1b11973a
9 changed files with 308 additions and 48 deletions

View file

@ -3,3 +3,7 @@ los.s
sts.s
dvi.s
mli.s
csab.s
dvu.s
mlu.s
rck.s

57
mach/arm/libem/csab.s Normal file
View file

@ -0,0 +1,57 @@
.define _Csa, _Csb
.sect.text
_Csa:
LDMFD R12<, {R0}
LDMFD R12<, {R1}
STMFD R12<, {R4}
LDR R2, [R0, #4]
MOV R4,R2
LDR R3, [R0, #8]
CMP R1,R2
BLT 1F
ADD R2,R2,R3
CMP R1,R2
BGT 1F
ADD R2, R0, #12
SUB R1,R1,R4
ADD R2, R2, R1, LSL #2
LDR R2, [R2]
CMP R2, #0
BAL 2F
1:
LDR R2, [R0]
CMP R2, #0
2:
BNE 3F
BAL.L _CasErr
3:
LDMFD R12<,{R4}
MOV R15,R14
_Csb:
LDMFD R12<, {R0}
LDMFD R12<, {R1}
STMFD R12<,{R4}
LDR R2, [R0, #4]
LDR R3, [R0]
ADD R0, R0, #8
1:
CMP R2, #0
BEQ 3F
LDR R4, [R0]
CMP R4, R1
BNE 2F
LDR R3, [R0, #4]
BAL 3F
2:
ADD R0, R0, #8
SUB R2,R2,#1
BAL 1B
3:
CMP R3, #0
BNE 4F
BAL.L _CasErr
4:
LDMFD R12<,{R4}
MOV R15, R14

View file

@ -3,13 +3,16 @@
.sect .text
.dvi: LDMFD R12<,{R1,R2}
MOV R3,#0
STMFD R12<,{R4}
CMP R1,#0
ADD.MI R3,R3,#1
RSB.MI R1,R1,#0
BEQ dbyzero
MOV R4,#0
CMP R1,#0
ADD.LT R4,R4,#1
RSB.LT R1,R1,#0
CMP R2,#0
ADD.MI R3,R3,#2
RSB.MI R2,R2,#0
ADD.LT R4,R4,#2
RSB.LT R2,R2,#0
MOV R0,#1
div1: CMP R1,#0x80000000
CMP.CC R1,R2
@ -23,9 +26,14 @@ div2: CMP R2,R1
MOV.S R0,R0,LSR #1
MOV.NE R1,R1,LSR #1
BNE div2
TST R4, #2
RSB.NE R2,R2,#0
TST R4, #1
TST.NE R4, #1
RSB.NE R3,R3,#0
CMP R4, #1
RSB.EQ R3,R3,#0
CMP R4,#2
RSB.EQ R3,R3,#0
LDMFD R12<,{R4}
MOV R15,R14
dbyzero:
MOV R0,#6
STMFD R12<,{R0}
BAL _EmTrp

32
mach/arm/libem/dvu.s Normal file
View file

@ -0,0 +1,32 @@
.define .dvu
.sect .text
.dvu:
LDMFD R12<,{R0,R1}
STMFD R12<,{R4}
CMP R0,#0
BEQ divbyzero
MOV R2,#0
MOV R3,#0
MOV R4,#32
DVU11:
SUB.S R4,R4,#1
LDMFD.EQ R12<,{R4}
MOV.EQ R15,R14
MOV.S R1,R1,ASL #1
BPL DVU11
DVU22:
MOV.S R1,R1,ASL #1
ADC R2,R2,R2
CMP R2,R0
SUB.CS R2,R2,R0
ADC R3,R3,R3
SUB.S R4,R4,#1
BNE DVU22
LDMFD R12<,{R4}
MOV R15,R14
divbyzero:
MOV R0,#6
STMFD R12<,{R0}
BAL _EmTrp

View file

@ -1,49 +1,178 @@
.define begdat, begbss
.define hol0, argv, envp, reghp
.define ignmask, trpreg, rcktrap
! head_em.s
.define begdat,begbss,hol0,argv,envp,_RegHp,_incptflag
.define _Lineno,_Filna,_IgnoreMask,_TrpReg
.sect .text
.sect .rom
.sect .data
.sect .bss
.sect .text
.sect .rom
.sect .data
.sect .bss
.sect .text
ADR R0,begbss
ADR R1,_endbss
MOV R2,#0
.sect .text
.base 0x8000
ADR R0,begbss
ADR R1,_endbss
MOV R2,#0
ADR R3,_incptflag
STR R2,[R3]
1:
STR R2,[R0],#4
CMP R0,R1
BGT 1b
MOV R12, #0x100000
ADR R11, envp
STMFD R12<, {R11}
ADR R11, argv
STMFD R12<, {R11}
MOV R11, #1
STMFD R12<, {R11}
BAL.L _m_a_i_n
rcktrap:
SWI 1
STR R2,[R0],#4
CMP R0,R1
BLT 1B
! the next 2 lines are OS specific:
SWI 16 ! OS_Getenv
SUB R12, R1, #8 ! Get end of ram
! R0 points to command string
! (argv,argc) code for C
! or Pascal file names
MOV R9,R0 ! save pt in R0
MOV R8,#0 ! string length
len:
LDR.B R7,[R9],#1
CMP R7,#0
ADD.NE R8,R8,#1
BNE len
MOV R7,R8 ! save len in R7
! round up to multiple of 4
ADD R8,R8,#4
MVN R6, #3 !FFFFFFFC
AND R8,R8,R6
! make room on stack
SUB R12,R12,R8 ! word aligned
! now determine argc
! OS intercepts blank lines, so
! there must be at least one arg
MOV R9,R0
MOV R6,#0 ! holds argc
MOV R5,#0 ! char count
loop1:
CMP R5,R7
BGT next1
LDR.B R4,[R9],#1
ADD R5,R5,#1
CMP R4,#32
BEQ loop1 !skip spaces
ADD R6,R6,#1 ! new arg
nospace1:
CMP R5,R7
BGT next1
LDR.B R4,[R9],#1
ADD R5,R5,#1
CMP R4,#32
BNE nospace1
CMP R5,R7
BCC loop1
! BEQ loop1
next1:
! store argc
ADR R5,argc
STR R6,[R5]
! copy the string
! onto the stack
MOV R9,R0 !source
MOV R2,R12 !dest
MOV R3,R7 !#chars
loop2:
LDR.B R4,[R9],#1
STR.B R4,[R2],#1
SUB.S R3,R3,#1
BNE loop2
MOV R4, #0 ! zero terminator
STR.B R4,[R2]
! create space on the stack for
! the pointers to individual args
MOV R11, R12 ! string pt
MOV R8,R6,LSL #2
SUB R12,R12,R8
! save pointer to argv[0]
ADR R1,argv
STR R12,[R1]
! determine argv[0] .. argv[argc-1]
! and store on stack
! R11 = start of string
! R7 = string lenth
! R12 = stack pointer
! R6 = argc
MOV R9, #0 !char count
MOV R8, #0 !arg count
MOV R5,R11
loop3:
CMP R9,R7
BGT next2
LDR.B R4,[R5],#1
ADD R9,R9,#1
CMP R4,#32
BEQ loop3
CMP R9,R7
BGT next2
SUB R4,R5,#1 !compensate for incr
STR R4,[R12,R8,LSL #2]
ADD R8,R8,#1
nospace2:
CMP R9,R7
BGT next2
LDR.B R4,[R5],#1
ADD R9,R9,#1
CMP R4,#32
BNE nospace2
CMP R9,R7
BCC loop3
! BEQ loop3
! finally, replace spaces by 0
next2:
MOV R5,R11 !string ptr
MOV R6,R7 !string length
MOV R3,#0
loop4:
CMP R6,#0
BEQ next3
LDR.B R4,[R5]
CMP R4,#32
STR.EQ.B R3,[R5]
ADD R5,R5,#1
SUB R6,R6,#1
BAL loop4
next3:
ADR R11, envp
STMFD R12<,{R11}
ADR R11,argv
LDR R11,[R11]
STMFD R12<,{R11}
ADR R11, argc
LDR R11,[R11]
STMFD R12<,{R11}
BAL.L _m_a_i_n
MOV R11,#0
STMFD R12<,{R11}
MOV R11,#1
STMFD R12<,{R11}
BAL.L _EmMon
.sect .bss
begbss:
.sect .data
begdat:
hol0:
.data4 0
.data4 0
.data4 0
.data4 0
argv:
.data4 2f
.data4 0
envp:
.data4 0
.data4 0
argc:
.data4 0
2:
.asciz 'PROGRAM'
reghp:
.data4 _endbss
ignmask:
.data4 0
trpreg:
.data4 0
.asciz 'PROGRAM'
.align
_RegHp:
.data4 _endbss
_Lineno:
.data4 0
_Filna:
.data4 0
_IgnoreMask:
.data4 0
_TrpReg:
.data4 0
_incptflag:
.data4 0

View file

@ -3,6 +3,7 @@
.sect .text
.mli: LDMFD R12<,{R1,R2}
STMFD R12<,{R4}
MOV R3,#0
MOV R0,#0
CMP R1,#0
@ -24,4 +25,5 @@
BNE 1B
TST R3,#1
RSB.NE R0,R0,#0
LDMFD R12<,{R4}
MOV R15,R14

14
mach/arm/libem/mlu.s Normal file
View file

@ -0,0 +1,14 @@
.define .mlu
.sect .text
.mlu:
LDMFD R12<,{R0,R1}
MOV R2, #0
_mluloop:
MOV.S R0,R0,LSR #1
ADD.CS R2,R2,R1
ADD R1,R1,R1
BNE _mluloop
MOV R0,R2
MOV R15,R14

14
mach/arm/libem/rck.s Normal file
View file

@ -0,0 +1,14 @@
.define _RckTrap,_CasErr
.sect .text
_RckTrap:
MOV R0,#1
STMFD R12<,{R0}
BAL.L _EmTrp
_CasErr:
MOV R0,#20
STMFD R12<,{R0}
BAL.L _EmTrp

View file

@ -23,5 +23,5 @@
ADD R1,R1,#4
CMP R1,R3
MOV.EQ R15,R14
STMFD R12<,{R2}
LDMFD R12<,{R2}
BAL 1b