From d6ff86499ebb21037a8f84d7d1b406ea08707c47 Mon Sep 17 00:00:00 2001 From: "(Tim) Efthimis Kritikos" Date: Sun, 5 May 2024 11:45:38 +0100 Subject: [PATCH] Programs: Added initial draft of quicksort porgram that is currently broken and two other benchmarks --- Makefile | 2 +- programs/cube_benchmark.asm | 278 +++++++++++++++++++++++++++++++++++ programs/max_performance.asm | 68 +++++++++ programs/quicksort.asm | 184 +++++++++++++++++++++-- 4 files changed, 518 insertions(+), 14 deletions(-) create mode 100644 programs/cube_benchmark.asm create mode 100644 programs/max_performance.asm diff --git a/Makefile b/Makefile index 30b7289..c094ec5 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ USE_AALIB=1 OBJECT_FILES=gui.o gui_display.o gui_internals.o main.o simdata.o assembly.o cpu.o MAIN_ROM=programs/utah_teapot.rom -ROMS=test.rom ${MAIN_ROM} programs/cube.rom programs/quicksort.rom +ROMS=test.rom ${MAIN_ROM} programs/cube.rom programs/quicksort.rom programs/max_performance.rom programs/cube_benchmark.rom UTAH_TEAPOT_ASCII_STL=assets/Utah_teapot_ascii.stl AXIL_PROGS=auxiliary_progs/stl_to_source_code diff --git a/programs/cube_benchmark.asm b/programs/cube_benchmark.asm new file mode 100644 index 0000000..f06d827 --- /dev/null +++ b/programs/cube_benchmark.asm @@ -0,0 +1,278 @@ +MOV $0xFF0000,%SP +#Set up vector mode +MOV $0xFFFC,%R4l +MOV $0x00FF,%R4h +MOV $0xFFFF,%R1l +MOV $0xFFFF,%R1h +MOV %R1,(%R4) +MOV $0x0008,%R7l +MOV $0x0000,%R7h #The number of rotate,render itrations +:MAIN_LOOP +PUSH %R7 +CALL $RENDER +CALL $SPIN +POP %R7 +DEC %R7 +JMP,NZ $MAIN_LOOP +HALT + +:SPIN +MOV $0x0008,%R2l +MOV $0x0000,%R2h #Constant 8 +MOV $0x0004,%R5l +MOV $0x0000,%R5h #Constant 4 + +MOV $>DATA_START,%R0l +MOV $DATA_START,%R0l +MOV $= end CMP %R2,%R3 JMP,NS $BAIL -ADD %R2,%R3 +#Get pivot to %R5 +MOV $DATA,%R7l +MOV %R3,%R6 +SL %R6 +SL %R6 +ADD %R7,%R6 +MOV (%R6),%R5 + +#Set %R0 and %R1 +MOV %R3,%R0 +DEC %R0 +MOV %R3,%R1 + +#MAIN LOOP +:MAIN_LOOP + +#Get current data being pointed to %R4 +MOV %R1,%R6 +SL %R6 +SL %R6 +ADD %R7,%R6 +MOV (%R6),%R4 + +#Check if we swap +CMP %R5,%R4 +JMP,NS $COND_EXIT + +INC %R0 + +PUSH %R2 +#Do swap +MOV %R1,%R6 +SL %R6 +SL %R6 +ADD %R7,%R6 +MOV (%R6),%R2 + +MOV %R0,%R6 +SL %R6 +SL %R6 +ADD %R7,%R6 +MOV (%R6),%R4 +MOV %R2,(%R6) + +MOV %R1,%R6 +SL %R6 +SL %R6 +ADD %R7,%R6 +MOV %R4,(%R6) + +POP %R2 + +:COND_EXIT + +INC %R1 + +CMP %R2,%R1 +JMP,NZ $MAIN_LOOP + + +INC %R0 + +#Do swap +PUSH %R2 +MOV %R2,%R6 +SL %R6 +SL %R6 +ADD %R7,%R6 +MOV (%R6),%R2 + +MOV %R0,%R6 +SL %R6 +SL %R6 +ADD %R7,%R6 +MOV (%R6),%R4 +MOV %R2,(%R6) + +MOV %R0,%R6 +SL %R6 +SL %R6 +ADD %R7,%R6 +MOV %R4,(%R6) +POP %R2 + +DEC %R0 + +#SAVE REGISTERS +PUSH %R0 +PUSH %R1 +PUSH %R2 +PUSH %R3 +PUSH %R4 + +#PASS PARAMETERS +PUSH %R2 +PUSH %R0 + +CALL $QUICKSORT +#SKIP PARAMETERS +POP %R4 +POP %R4 + +#RESTORE REGISTERS +POP %R4 +POP %R3 +POP %R2 +POP %R1 +POP %R0 + +#SAVE REGISTERS +PUSH %R0 +PUSH %R1 +PUSH %R2 +PUSH %R3 +PUSH %R4 + +#PASS PARAMETERS +INC %R0 +INC %R0 +PUSH %R0 +PUSH %R3 + +CALL $QUICKSORT +#SKIP PARAMETERS +POP %R4 +POP %R4 + +#RESTORE REGISTERS +POP %R4 +POP %R3 +POP %R2 +POP %R1 +POP %R0 :BAIL RET :DATA -DDW $0x00000000 -DDW $0x00000004 +DDW $0x00000010 +DDW $0x00000007 +DDW $0x00000008 DDW $0x00000009 -DDW $0x00000031 -DDW $0x000000BB -DDW $0x0000000e -DDW $0x00000002 -DDW $0x000000BB -DDW $0x01000000 -:DATA_END -DDW $0xFFFFFFFF +DDW $0x00000001 +DDW $0x00000005 +#DDW $0x00000006 +#DDW $0x00000007 +#DDW $0x00000008 +#DDW $0x00000009 +#DDW $0x0000000a +#DDW $0x0000000b +#DDW $0x0000000c +#DDW $0x0000000d +#DDW $0x0000000e +#DDW $0x00000010 + +#DDW $0xfe4cb7ad +#DDW $0xb925a7a6 +#DDW $0xce117350 +#DDW $0xd587026a +#DDW $0xc341474a +#DDW $0x709182e0 +#DDW $0x3b3d9cb8 +#DDW $0x9b36108d +#DDW $0x069a847f +#DDW $0x0137e24c +#DDW $0xe848d5dc +#DDW $0xf98a1bc4 +#DDW $0xe019a8e4 +#DDW $0xd42640c3 +#DDW $0x9dba659a +#DDW $0xdd94f7b9