Commit ace2e66f authored by Jeffrey Lee's avatar Jeffrey Lee
Browse files

Avoid unnecessary remainder calculations

Detail:
  s/Wimp01, s/Wimp02, s/Wimp05, s/Wimp08s, s/Wimp10 - Avoid unnecessary remainder calculations in DivRem macro. Also make more use of DivRem's ability to accept a constant (not a register) as the divisor.
Admin:
  Tested on Cortex-A15


Version 5.52. Tagged as 'Wimp-5_52'
parent a8c4aa91
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "5.51"
Module_Version SETA 551
Module_MajorVersion SETS "5.52"
Module_Version SETA 552
Module_MinorVersion SETS ""
Module_Date SETS "29 Nov 2015"
Module_ApplicationDate SETS "29-Nov-15"
Module_Date SETS "08 May 2016"
Module_ApplicationDate SETS "08-May-16"
Module_ComponentName SETS "Wimp"
Module_ComponentPath SETS "castle/RiscOS/Sources/Desktop/Wimp"
Module_FullVersion SETS "5.51"
Module_HelpVersion SETS "5.51 (29 Nov 2015)"
Module_FullVersion SETS "5.52"
Module_HelpVersion SETS "5.52 (08 May 2016)"
END
/* (5.51)
/* (5.52)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 5.51
#define Module_MajorVersion_CMHG 5.52
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 29 Nov 2015
#define Module_Date_CMHG 08 May 2016
#define Module_MajorVersion "5.51"
#define Module_Version 551
#define Module_MajorVersion "5.52"
#define Module_Version 552
#define Module_MinorVersion ""
#define Module_Date "29 Nov 2015"
#define Module_Date "08 May 2016"
#define Module_ApplicationDate "29-Nov-15"
#define Module_ApplicationDate "08-May-16"
#define Module_ComponentName "Wimp"
#define Module_ComponentPath "castle/RiscOS/Sources/Desktop/Wimp"
#define Module_FullVersion "5.51"
#define Module_HelpVersion "5.51 (29 Nov 2015)"
#define Module_LibraryVersionInfo "5:51"
#define Module_FullVersion "5.52"
#define Module_HelpVersion "5.52 (08 May 2016)"
#define Module_LibraryVersionInfo "5:52"
......@@ -3423,7 +3423,7 @@ gotwork
;
SWI XOS_ReadMemMapInfo ; R0 = page size, R1 = number of pages
MOV R1,#DefaultNextSlot
DivRem R2,R1,R0,R14 ; R2 = number of pages for 640k (or whatever)
DivRem R2,R1,R0,R14,norem ; R2 = number of pages for 640k (or whatever)
STR R2,slotsize
;
[ DontCheckModeOnInit
......@@ -5900,7 +5900,7 @@ resizecommandwindow
SUB R1,R1,cy1,LSR #4
ADD R1,R1,cy1,LSR #6
SUB R1,R1,cy1,LSR #8 ; 0.45 * screen height (or pretty close to)
DivRem cy0,R1,R0,R14
DivRem cy0,R1,R0,R14,norem
BIC cy0,cy0,#1 ; round down to even number of rows
MUL cy0,R0,cy0 ; scale back to OS units
CMP cy0,#1024
......@@ -5910,7 +5910,7 @@ resizecommandwindow
BIC cx1,cx1,R0 ; ensure left aligned if odd number of columns
LDR R0,textxsize
SUB R1,cx1,cx1,LSR #2 ; 0.75 * screen width
DivRem cx0,R1,R0,R14
DivRem cx0,R1,R0,R14,norem
BIC cx0,cx0,#1 ; round down to even number of columns
MUL cx0,R0,cx0 ; scale back to OS units
CMP cx0,#1280
......@@ -5958,7 +5958,7 @@ commandtextwindow
TST R1,#2 ; ensure text window entirely contained
ADDEQ x0,x0,cx1 ; within Wimp window
SUBNE x0,x0,cx1 ; (NB y-coords are upside-down)
DivRem R0,x0,cx0, R14
DivRem R0,x0,cx0,R14,norem
SWI XOS_WriteC
SUBS R1,R1,#1
BNE %BT01
......
......@@ -1189,8 +1189,7 @@ $lab SetConfig $string, $unit, $cmosbyte, $cmosbit, $cmossize, $shift, $eor,
MOVLS R3, R2
MOVLS R4, #0
BLS %FT07
MOV R1, #10
DivRem R3, R2, R1, R0 ; R3 = R2 DIV 10, R2 = R2 MOD 10
DivRem R3, R2, #10, R0, norem ; R3 = R2 DIV 10
CMP R3, #((1 :SHL: $cmossize) - 1) / 10 ; do we need to round down to 15?
MOVEQ R3, #(1 :SHL: $cmossize) - 1
MOVEQ R4, #0
......@@ -9514,7 +9513,7 @@ muldivR0
;
MUL x0,R0,cx0
ADD x0,x0,cx1,ASR #1 ; round to nearest
DivRem R0,x0,cx1, R14
DivRem R0,x0,cx1,R14,norem
;
Pull "R1,cx0,cx1,x0,PC"
......
......@@ -5132,10 +5132,8 @@ intopmenu
MOVS R5,R4 ; R5 = icon handle
BMI notinamenu
MOV R1,#3
Push "R5"
DivRem R0,R5,R1, R14 ; get (icon/3)
Pull "R5"
MOV R1,R5
DivRem R0,R1,#3,R14,norem ; get (icon/3)
BLVC trymenuhighlight ; R0 = selection index, R14=0 => shaded
BVS exitscanmenu ; only re-highlighted if different
......@@ -5476,10 +5474,8 @@ leavescan
; extra entry point for <cr> in writable menu
crmenuselection
MOV R1,#3
Push "R4"
DivRem R0,R4,R1, R14 ; R0 = R4 (icon) / 3
Pull "R4"
MOV R1,R4
DivRem R0,R1,#3,R14,norem ; R0 = R4 (icon) / 3
BVS longjumpexit
LDR R1,whichmenu
ADRL R14,menuselections
......@@ -5570,8 +5566,7 @@ SWIWimp_GetMenuState
CMP R3,#0
MOVLT R5,#-1 ; system icon => no selection
BLT %FT01
MOV R4,#3
DivRem R5,R3,R4,R14 ; R5 = menu selection index of icon
DivRem R5,R3,#3,R14,norem ; R5 = menu selection index of icon
01
; scan list of menus until the specified window is found
......
......@@ -79,7 +79,7 @@ SWIWimp_SlotSize ROUT
BEQ %FT01
ADD R2,R2,R0 ; R2 = (R2+size-1) DIV size * size
SUB R2,R2,#1
DivRem R3,R2,R0, R14
DivRem R3,R2,R0,R14,norem
STR R3,slotsize ; [slotsize] = no of pages
01
Push "R0-R1"
......
......@@ -3556,17 +3556,17 @@ tintfunc Entry "R1-R8"
SUB R2, R8, R2 ; R2 = distance from white
MUL R0, R1, R2 ; scale up by new size
DivRem R2, R0, #&44, R14 ; scale down by old size
DivRem R2, R0, #&44, R14,norem ; scale down by old size
SUB R2, R8, R2 ; make relative to white again
SUB R3, R8, R3
MUL R0, R1, R3
DivRem R3, R0, #&44, R14
DivRem R3, R0, #&44, R14, norem
SUB R3, R8, R3
SUB R4, R8, R4
MUL R0, R1, R4
DivRem R4, R0, #&44, R14
DivRem R4, R0, #&44, R14, norem
SUB R4, R8, R4
B %FT01
......@@ -3584,7 +3584,7 @@ tintfunc Entry "R1-R8"
RSBLT R5, R5, #0 ; R5 = |R5|
SavePSR R8 ; remember flags for later
MUL R0, R1, R5 ; scale up by new size
DivRem R5, R0, #&BB, R14 ; scale down by old size
DivRem R5, R0, #&BB, R14,norem ; scale down by old size
RestPSR R8,,f ; restore flags
ADDLT R2, R2, R5 ; make relative to new background
SUBGT R2, R2, R5 ; (accounting for the sign of R2-R5 above)
......@@ -3594,7 +3594,7 @@ tintfunc Entry "R1-R8"
RSBLT R6, R6, #0
SavePSR R8
MUL R0, R1, R6
DivRem R6, R0, #&BB, R14
DivRem R6, R0, #&BB, R14, norem
RestPSR R8,,f
ADDLT R3, R3, R6
SUBGT R3, R3, R6
......@@ -3604,7 +3604,7 @@ tintfunc Entry "R1-R8"
RSBLT R7, R7, #0
SavePSR R8
MUL R0, R1, R7
DivRem R7, R0, #&BB, R14
DivRem R7, R0, #&BB, R14, norem
RestPSR R8,,f
ADDLT R4, R4, R7
SUBGT R4, R4, R7
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment