4 ; Fiddle with hourglass from command line
6 ; © 1994-1998 Straylight
9 ;----- Licensing note -------------------------------------------------------
11 ; This file is part of Straylight's core utilities (coreutils).
13 ; Coreutils is free software; you can redistribute it and/or modify
14 ; it under the terms of the GNU General Public License as published by
15 ; the Free Software Foundation; either version 2, or (at your option)
18 ; Coreutils is distributed in the hope that it will be useful,
19 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ; GNU General Public License for more details.
23 ; You should have received a copy of the GNU General Public License
24 ; along with Coreutils. If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ;----- Standard header ------------------------------------------------------
34 ;----- External dependencies ------------------------------------------------
38 ;----- Main code ------------------------------------------------------------
42 AREA |!!!Util$$Code|,CODE,READONLY
46 STMFD R13!,{R14} ;Save the return address
47 ADR R0,hour__cmdDef ;Point to command definition
48 MOV R2,R12 ;Point to a workspace buffer
49 MOV R3,#256 ;Size of the buffer
50 SWI XOS_ReadArgs ;Try to interpret the args
51 BVS %90main ;If it failed, return
53 ; --- Handle the arguments ---
55 LDMIA R12,{R0-R4} ;Load values from block
57 CMP R0,#0 ;Does he want some help?
58 BNE hour__help ;Yes -- display help then
60 ; --- Make sure at most one is set ---
62 MOV R14,#0 ;Clear argument count
63 MOV R0,#1 ;Default is to turn on
68 CMP R$count,#0 ;Is the argument on?
69 ADDNE R14,R14,#1 ;Yes -- bump the counter
70 MOVNE R0,#count-1 ;And remember the argument
74 CMP R14,#2 ;Is the count valid?
75 ADRCS R0,hour__badArgs ;No -- point to error
76 BCS %90main ;And return to caller
78 ; --- Now do the necessaries ---
80 ; The following should be two words long each -- this enables
81 ; most operations to be done inline with just a SWI and a
84 MOV R14,PC ;Set up return address
85 ADD PC,PC,R0,LSL #3 ;Do what we must do
86 LDMFD R13!,{PC} ;Return to caller
88 ; --- Disable the hourglass ---
93 ; --- Enable the hourglass ---
98 ; --- Trash hourglass totally ---
103 ; --- Turn on the percentage indicator ---
105 ; To save space, this should be the last option.
107 LDRB R0,[R4],#1 ;Load the expression type
108 CMP R0,#0 ;Is it numeric?
109 ADRNE R0,hour__badType ;No -- must be a bad type
110 ORRNES PC,R14,#V_flag ;So return the error
111 AND R2,R4,#3 ;Get non-wordalignedness
112 BIC R4,R4,#3 ;Word align the address
113 LDMIA R4,{R0,R1} ;Load two overlapping words
114 MOV R2,R2,LSL #3 ;Convert bytes to bits
115 RSB R3,R2,#32 ;And get reverse shift size
116 MOV R0,R0,LSR R2 ;Get the bottom end right
117 ORR R0,R0,R1,LSL R3 ;And move in the top end
118 SWI XHourglass_Percentage ;Set the percentage as reqd
119 MOV PC,R14 ;And return to caller
121 90main LDMFD R13!,{R14} ;Load the return address
122 ORRS PC,R14,#V_flag ;And return an error
124 hour__cmdDef DCB "help/S," ;Offset 0 (R0)
125 DCB "off/S," ;Offset 8 (R1)
126 DCB "on/S," ;Offset 4 (R2)
127 DCB "smash/S," ;Offset 12 (R3)
128 DCB "percent/K/E," ;Offset 16 (R4)
132 DCB "Syntax: hour [<command>]",0
135 DCB "Percentage must be a number",0
137 hour__help ADR R0,hour__helpText ;Point to the help text
138 MOV R1,#0 ;No dictionary please
139 LDR R2,=version ;Find the version string
140 ADR R14,main ;Find my base address
141 ADD R2,R14,R2 ;Find the actual message
142 SWI XOS_PrettyPrint ;Print the message
143 LDMFD R13!,{PC}^ ;And return to caller
147 hour__helpText DCB "hour ",27,0,13
149 DCB "Syntax: hour [<command>]",13
151 DCB "Performs an Hourglass operation as specified by "
152 DCB "<command>. If no command is specified, the "
153 DCB "Hourglass is turned on.",13
155 DCB "Commands allowed are:",13
157 DCB "-help",9,9,"Displays this help text",13
158 DCB "-on",9,9,"Turns the Hourglass on",13
159 DCB "-off",9,9,"Turns the Hourglass off",13
160 DCB "-smash",9,9,"Forces the Hourglass off",13
161 DCB "-percent",9,"Displays the given percentage",13
164 ;----- That's all, folks ----------------------------------------------------