BBC BASIC
« Increment of a value in assembler? »

Welcome Guest. Please Login or Register.
Jan 23rd, 2018, 7:11pm


Cross-platform BBC BASIC (Win32, Linux x86, Android, Mac OS-X, Raspberry Pi)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Increment of a value in assembler?  (Read 258 times)
michaelgallup
Guest
xx Increment of a value in assembler?
« Thread started on: May 10th, 2016, 05:57am »

I am trying to learn how this works.
Actually this should go faster if I can send the increased information to the start variable value within the assembler.
I need to find out how to loop within the assembler, but what if I only increment a certain amount for each assembler use? I am doing something wrong I am sure..
Code:
      DIM bin% 3, bcd% 9
      PRINT "Please wait for increment to 2 million"
      PROCassemble
      !bin%=1000
      REPEAT
        CALL bin2bcd
        !bin%=!bcd%
      UNTIL !bcd%=2000000
      PRINT "DONE"
      END

      DEF PROCassemble
      LOCAL P%, L%
      DIM P% 12, L% -1
      [OPT 10
      .bin2bcd
      mov eax,[bin%]
      inc eax
      mov [bcd%],eax
      ret
      ]
      ENDPROC
 

Profiler report file - Mon.09 May 2016,23:54:42

File - Digits.BBC

Figures in the first column indicate approximate
time in milliseconds spent in each program line.

Figures in the second column indicate approximate
percentage of the total time spent in each program line.

Initial timeout setting : 1000 milliseconds.

Time spent Profiling : 1000 milliseconds.

0: DIM bin% 3, bcd% 9
2: 0.20 PRINT "Please wait for increment to 2 million"
0: PROCassemble
0: !bin%=1000
0: REPEAT
121: 12.10 CALL bin2bcd
842: 84.20 !bin%=!bcd%
35: 3.50 UNTIL !bcd%=2000000
0: PRINT "DONE"
0: END
0:
0: DEF PROCassemble
0: LOCAL P%, L%
0: DIM P% 12, L% -1
0: [OPT 10
0: .bin2bcd
0: mov eax,[bin%]
0: inc eax
0: mov [bcd%],eax
0: ret
0: ]
0: ENDPROC
« Last Edit: May 10th, 2016, 06:11am by michaelgallup » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 692
xx Re: Increment of a value in assembler?
« Reply #1 on: May 10th, 2016, 07:05am »

An alternative is for the assembler code to act on ordinary BASIC variables like this:

Code:
      PRINT "Please wait for increment to 2 million"
      PROCassemble
      bin%=1000
      REPEAT
        CALL bin2bcd
        bin%=bcd%
      UNTIL bcd%=2000000
      PRINT "DONE"
      END

      DEF PROCassemble
      LOCAL P%, L%
      DIM P% 12, L% -1
      [OPT 10
      .bin2bcd
      mov eax,[^bin%]
      inc eax
      mov [^bcd%],eax
      ret
      ]
      ENDPROC 

The difference is a subtle one, but I think there is some benefit, especially for a beginner, in not needing to reserve memory for the 'variables' or to use 'indirection' in the BASIC code.

Richard.
User IP Logged

michaelgallup
Guest
xx Re: Increment of a value in assembler?
« Reply #2 on: May 10th, 2016, 08:27am »

Thanks Richard !! And now I found a way to make it even faster !! I beat the profiler by 184 milliseconds !! That's speed!
But it appears to be almost 2 times slower than the hexdecimal example
and many times slower than the fastest program in the later posts after I posted it.
I think the only way to increase the speed is if I was able to loop within the assembly as it is being added to.

Oh well, it was something to experiment with.
Code:
      PRINT "Please wait for increment to 2 million"
      PROCassemble
      bin%=1000
      REPEAT
        CALL bin2bcd
      UNTIL bin%=2000000
      PRINT "DONE"
      END
      DEF PROCassemble
      LOCAL P%, L%
      DIM P% 12, L% -1
      [OPT 10
      .bin2bcd
      mov eax,[^bin%]
      inc eax
      mov [^bin%],eax
      ret
      ]
      ENDPROC
 

Profiler report file - Tue.10 May 2016,02:24:51

File - Digits.BBC

Figures in the first column indicate approximate
time in milliseconds spent in each program line.

Figures in the second column indicate approximate
percentage of the total time spent in each program line.

Initial timeout setting : 1000 milliseconds.

Time spent Profiling : 816 milliseconds.

1: 0.12 PRINT "Please wait for increment to 2 million"
0: PROCassemble
0: bin%=1000
2: 0.25 REPEAT
404: 49.51 CALL bin2bcd
409: 50.12 UNTIL bin%=2000000
0: PRINT "DONE"
0: END
0: DEF PROCassemble
0: LOCAL P%, L%
0: DIM P% 12, L% -1
0: [OPT 10
0: .bin2bcd
0: mov eax,[^bin%]
0: inc eax
0: mov [^bin%],eax
0: ret
0: ]
0: ENDPROC

0: Libraries and immediate mode
« Last Edit: May 10th, 2016, 08:54am by michaelgallup » User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Donate $6.99 for 50,000 Ad-Free Pageviews!


This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls