Hi javor.pas.
I am not a specialist. but I wrote this code and compiled.
Code: Select all
program ForumQuest;
begin
{This couldnt be compiled}
// while NVMCON.15 = 1 do ;
while NVMCON.15 = 1 do
nop;
{This code could be compiled}
repeat
until NVMCON.15 <> 1;
{I prefer this. But not so different.}
while NVMCON and $8000 = $8000 do
nop;
{use lib}
while TestBit(NVMCON, 15) do
nop;
{Maybe fastest. but something funy}
asm
uniqLabel:
BTSC NVMCON, 15; why not #15?
GOTO uniqLabel
end;
end.
And then click View-View Assembly to see ".asm" file.
(for description, I add comment)
Code: Select all
;==================================
;ForumQuest.dpas,7 :: while NVMCON.15 = 1 do
$0106 $ ForumQuest_L_2:
$0106 $803B01 MOV NVMCON, W1
$0108 $280000 MOV #32768, W0
$010A $608080 AND W1, W0, W1
$010C $2000F0 MOV #15, W0
$010E $DE0880 LSR W1, W0, W1
$0110 $508061 SUB W1, #1, W0
$0112 $3A0003 BRA NZ ForumQuest_L_3, ForumQuest_L_3
;ForumQuest.dpas,8 :: nop;
$0114 $000000 NOP
$0116 $040106 GOTO ForumQuest_L_2
$011A $ ForumQuest_L_3:
:====================================
;ForumQuest.dpas,11 :: repeat
$011A $ ForumQuest_L_6:
;ForumQuest.dpas,12 :: until NVMCON.15 <> 1;
$011A $ ForumQuest_L_7:
$011A $803B01 MOV NVMCON, W1
$011C $280000 MOV #32768, W0
$011E $608080 AND W1, W0, W1
$0120 $2000F0 MOV #15, W0
$0122 $DE0880 LSR W1, W0, W1
$0124 $508061 SUB W1, #1, W0
$0126 $320002 BRA Z ForumQuest_L_9, ForumQuest_L_9
$0128 $ ForumQuest_L_10:
$0128 $040130 GOTO ForumQuest_L_8
$012C $ ForumQuest_L_9:
$012C $04011A GOTO ForumQuest_L_6
$0130 $ ForumQuest_L_8:
;============================================
;ForumQuest.dpas,15 :: while NVMCON and $8000 = $8000 do
$0130 $ ForumQuest_L_12:
$0130 $803B01 MOV NVMCON, W1
$0132 $280000 MOV #32768, W0
$0134 $608100 AND W1, W0, W2
$0136 $280001 MOV #32768, W1
$0138 $510001 SUB W2, W1, W0
$013A $3A0003 BRA NZ ForumQuest_L_13, ForumQuest_L_13
;ForumQuest.dpas,16 :: nop;
$013C $000000 NOP
$013E $040130 GOTO ForumQuest_L_12
$0142 $ ForumQuest_L_13:
;============================================
;ForumQuest.dpas,19 :: while TestBit(NVMCON, 15) do
$0142 $ ForumQuest_L_17:
$0142 $803B01 MOV NVMCON, W1
$0144 $280000 MOV #32768, W0
$0146 $608080 AND W1, W0, W1
$0148 $2000F0 MOV #15, W0
$014A $DE0880 LSR W1, W0, W1
$014C $E00001 CP0 W1
$014E $320003 BRA Z ForumQuest_L_18, ForumQuest_L_18
;ForumQuest.dpas,20 :: nop;
$0150 $000000 NOP
$0152 $040142 GOTO ForumQuest_L_17
$0156 $ ForumQuest_L_18:
:=============================================
;ForumQuest.dpas,24 :: uniqLabel:
$0156 $ UNIQLABEL:
;ForumQuest.dpas,25 :: BTSC NVMCON, 15; why not #15?
$0156 $AFE760 BTSC NVMCON, 15
;ForumQuest.dpas,26 :: GOTO uniqLabel
$0158 $040156 GOTO UNIQLABEL
;ForumQuest.dpas,27 :: end;
(If you not familiar with asm, it is not so bad idea to think that number of lines with leading $0***(PC) means speed.)
if
The goal is to achieve fastest respond time with fewer instructions.
Answer is in *.asm file.