Line 35... |
Line 35... |
*
|
*
|
* Arguments to functions are passed in r3 through r8.
|
* Arguments to functions are passed in r3 through r8.
|
* r9 is the link (return address)
|
* r9 is the link (return address)
|
* r11 is for returning results
|
* r11 is for returning results
|
*
|
*
|
* Only r1 and r2 are preserved across function calls. It is up to the callee
|
* All registers apart from r2, r9 and r11 are preserved across function calls.
|
* to save any other registers required.
|
|
* ------------------------------------------------------------------------- */
|
* ------------------------------------------------------------------------- */
|
|
|
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
* This library contains the stack implementation and reset sequence and a set
|
* This library contains the stack implementation and reset sequence and a set
|
* of library functions.
|
* of library functions.
|
Line 149... |
Line 148... |
* Parameters:
|
* Parameters:
|
* r3 Pointer to the string to print
|
* r3 Pointer to the string to print
|
* ------------------------------------------------------------------------- */
|
* ------------------------------------------------------------------------- */
|
.global _puts
|
.global _puts
|
_puts:
|
_puts:
|
|
PUSH (r3)
|
l.add r2,r0,r3 /* Copy the string pointer */
|
l.add r2,r0,r3 /* Copy the string pointer */
|
|
|
/* Loop getting and printing each char until end of string */
|
/* Loop getting and printing each char until end of string */
|
60: l.lbz r3,0(r2)
|
60: l.lbz r3,0(r2)
|
l.sfeq r3,r0 /* NULL termination? */
|
l.sfeq r3,r0 /* NULL termination? */
|
Line 160... |
Line 160... |
|
|
l.addi r2,r2,1 /* Delay slot, move to next char */
|
l.addi r2,r2,1 /* Delay slot, move to next char */
|
l.j 60b /* Repeat */
|
l.j 60b /* Repeat */
|
l.nop NOP_PUTC /* Delay slot */
|
l.nop NOP_PUTC /* Delay slot */
|
|
|
61: l.jr r9 /* Return */
|
61: POP (r3)
|
|
l.jr r9 /* Return */
|
|
l.nop
|
|
|
|
/* ----------------------------------------------------------------------------
|
|
* Subroutine to print out a register in hex
|
|
*
|
|
* Parameters:
|
|
* r3 The value to print
|
|
* ------------------------------------------------------------------------- */
|
|
.section .rodata
|
|
62: .string "0123456789abcdef"
|
|
.section .text
|
|
|
|
.global _puth
|
|
_puth:
|
|
PUSH (r3)
|
|
PUSH (r4)
|
|
|
|
l.add r2,r0,r3 /* Copy the value pointer */
|
|
LOAD_CONST (r4,62b) /* Ptr to digit chars */
|
|
|
|
l.srli r3,r2,28 /* Print each digit in turn. */
|
|
l.add r3,r4,r3
|
|
l.lbz r3,0(r3)
|
|
l.nop NOP_PUTC
|
|
|
|
l.srli r3,r2,24
|
|
l.andi r3,r3,0xf
|
|
l.add r3,r4,r3
|
|
l.lbz r3,0(r3)
|
|
l.nop NOP_PUTC
|
|
|
|
l.srli r3,r2,20
|
|
l.andi r3,r3,0xf
|
|
l.add r3,r4,r3
|
|
l.lbz r3,0(r3)
|
|
l.nop NOP_PUTC
|
|
|
|
l.srli r3,r2,16
|
|
l.andi r3,r3,0xf
|
|
l.add r3,r4,r3
|
|
l.lbz r3,0(r3)
|
|
l.nop NOP_PUTC
|
|
|
|
l.srli r3,r2,12
|
|
l.andi r3,r3,0xf
|
|
l.add r3,r4,r3
|
|
l.lbz r3,0(r3)
|
|
l.nop NOP_PUTC
|
|
|
|
l.srli r3,r2,8
|
|
l.andi r3,r3,0xf
|
|
l.add r3,r4,r3
|
|
l.lbz r3,0(r3)
|
|
l.nop NOP_PUTC
|
|
|
|
l.srli r3,r2,4
|
|
l.andi r3,r3,0xf
|
|
l.add r3,r4,r3
|
|
l.lbz r3,0(r3)
|
|
l.nop NOP_PUTC
|
|
|
|
l.andi r3,r2,0xf
|
|
l.add r3,r4,r3
|
|
l.lbz r3,0(r3)
|
|
l.nop NOP_PUTC
|
|
|
|
POP (r4) /* Return */
|
|
POP (r3)
|
|
l.jr r9
|
l.nop
|
l.nop
|
|
|
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
* Subroutine to print out a test name prompt
|
* Subroutine to print out a test name prompt
|
*
|
*
|
Line 196... |
Line 266... |
* The string is followed by a newline
|
* The string is followed by a newline
|
* ------------------------------------------------------------------------- */
|
* ------------------------------------------------------------------------- */
|
.global _pok
|
.global _pok
|
_pok:
|
_pok:
|
PUSH(r9) /* Save the return address */
|
PUSH(r9) /* Save the return address */
|
|
PUSH (r3)
|
|
|
LOAD_STR(r3, "OK\n")
|
LOAD_STR(r3, "OK\n")
|
l.jal _puts
|
l.jal _puts
|
l.nop
|
l.nop
|
|
|
|
POP (r3)
|
POP (r9)
|
POP (r9)
|
l.jr r9
|
l.jr r9
|
l.nop
|
l.nop
|
|
|
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
Line 213... |
Line 285... |
* The string is followed by a ": ", which will then allow a report
|
* The string is followed by a ": ", which will then allow a report
|
* ------------------------------------------------------------------------- */
|
* ------------------------------------------------------------------------- */
|
.global _pfail
|
.global _pfail
|
_pfail:
|
_pfail:
|
PUSH(r9) /* Save the return address */
|
PUSH(r9) /* Save the return address */
|
|
PUSH (r3)
|
|
|
LOAD_STR(r3, "Failed: ")
|
LOAD_STR(r3, "Failed: ")
|
l.jal _puts
|
l.jal _puts
|
l.nop
|
l.nop
|
|
|
|
POP (r3)
|
POP (r9)
|
POP (r9)
|
l.jr r9
|
l.jr r9
|
l.nop
|
l.nop
|
|
|
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
* Subroutine to print out "TRUE"
|
* Subroutine to print out "TRUE"
|
* ------------------------------------------------------------------------- */
|
* ------------------------------------------------------------------------- */
|
.global _ptrue
|
.global _ptrue
|
_ptrue:
|
_ptrue:
|
PUSH(r9) /* Save the return address */
|
PUSH(r9) /* Save the return address */
|
|
PUSH (r3)
|
|
|
LOAD_STR(r3, "TRUE")
|
LOAD_STR(r3, "TRUE")
|
l.jal _puts
|
l.jal _puts
|
l.nop
|
l.nop
|
|
|
|
POP (r3)
|
POP (r9)
|
POP (r9)
|
l.jr r9
|
l.jr r9
|
l.nop
|
l.nop
|
|
|
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
* Subroutine to print out "FALSE"
|
* Subroutine to print out "FALSE"
|
* ------------------------------------------------------------------------- */
|
* ------------------------------------------------------------------------- */
|
.global _pfalse
|
.global _pfalse
|
_pfalse:
|
_pfalse:
|
PUSH(r9) /* Save the return address */
|
PUSH(r9) /* Save the return address */
|
|
PUSH (r3)
|
|
|
LOAD_STR(r3, "FALSE")
|
LOAD_STR(r3, "FALSE")
|
l.jal _puts
|
l.jal _puts
|
l.nop
|
l.nop
|
|
|
|
POP (r3)
|
POP (r9)
|
POP (r9)
|
l.jr r9
|
l.jr r9
|
l.nop
|
l.nop
|
|
|
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
Line 260... |
Line 338... |
* Preceded by a space and followed by a newline
|
* Preceded by a space and followed by a newline
|
* ------------------------------------------------------------------------- */
|
* ------------------------------------------------------------------------- */
|
.global _punexpected
|
.global _punexpected
|
_punexpected:
|
_punexpected:
|
PUSH(r9) /* Save the return address */
|
PUSH(r9) /* Save the return address */
|
|
PUSH (r3)
|
|
|
LOAD_STR(r3, " unexpected\n")
|
LOAD_STR(r3, " unexpected\n")
|
l.jal _puts
|
l.jal _puts
|
l.nop
|
l.nop
|
|
|
|
POP (r3)
|
POP (r9)
|
POP (r9)
|
l.jr r9
|
l.jr r9
|
l.nop
|
l.nop
|