You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
1.7 KiB
81 lines
1.7 KiB
2 years ago
|
.include "instr.inc"
|
||
|
.text
|
||
|
|
||
|
.global _start
|
||
|
_start:
|
||
|
# Check if the program is running from the right address
|
||
|
push_pc
|
||
|
pop_r3
|
||
|
cp_r3 _start
|
||
|
jp_eq main
|
||
|
ld_r2_r3
|
||
|
add_r2 (str_wrong_address - _start)
|
||
|
jp PrintStr
|
||
|
|
||
|
main:
|
||
|
ld_r2 str_intro
|
||
|
call PrintStr
|
||
|
|
||
|
# Ask for input, continue if user confirms
|
||
|
ld_r2 mem_input
|
||
|
ld_r3 7
|
||
|
call ReadStr
|
||
|
|
||
|
ldr_r0 mem_input
|
||
|
cp_r0 'Y'
|
||
|
jp_eq check
|
||
|
cp_r0 'y'
|
||
|
jp_eq check
|
||
|
cp_r0 ('Y' + '\n' * 0x100)
|
||
|
jp_eq check
|
||
|
cp_r0 ('y' + '\n' * 0x100)
|
||
|
jp_eq check
|
||
|
|
||
|
# The user hasn't confirmed
|
||
|
ld_r2 str_aborted
|
||
|
call PrintStr
|
||
|
ret
|
||
|
|
||
|
check:
|
||
|
copr 0x66
|
||
|
loop:
|
||
|
copr 0x64
|
||
|
call 0x3009
|
||
|
copr 0x65
|
||
|
cp_r0 2
|
||
|
jp_eq fail
|
||
|
cp_r0 1
|
||
|
jp_eq loop
|
||
|
ret
|
||
|
|
||
|
fail:
|
||
|
ld_r2 str_unsuccessful
|
||
|
call PrintStr
|
||
|
ret
|
||
|
|
||
|
str_intro:
|
||
|
.ascii "Glitch Research Laboratory Math Coprocessor\n"
|
||
|
.ascii "Testing Software: Function SQRT\n"
|
||
|
.ascii "\n"
|
||
|
.ascii "This program will test the SQRT function of the math module.\n"
|
||
|
.ascii "This function, executable with CALL 0x3009, should compute the\n"
|
||
|
.ascii "integer part of sqrt(R0) and return it in R0 (preserving R1-R3).\n"
|
||
|
.ascii "\n"
|
||
|
.ascii "Math module results will be compared with the coprocessor.\n"
|
||
|
.ascii "Note - if math module is not loaded, this test might crash the machine!\n"
|
||
|
.ascii "Report any bugs to administrator: ax.arwen@glitchlabsresearch.internal\n"
|
||
|
.ascii "\n"
|
||
|
.ascii "Continue with running the test (Y/N): \0"
|
||
|
|
||
|
str_aborted:
|
||
|
.ascii "Aborted.\n\0"
|
||
|
|
||
|
str_unsuccessful:
|
||
|
.ascii "Test was unsuccessful.\n\0"
|
||
|
|
||
|
str_wrong_address:
|
||
|
.ascii "Please load this program at address $2000.\n\0"
|
||
|
|
||
|
mem_input:
|
||
|
.ascii "________\0"
|