Square root of an integer number

Page 5/5
1 | 2 | 3 | 4 |

By flyguille

Prophet (3029)

flyguille's picture

19-12-2008, 19:09

now, who will do the code, an call it in a all the range and measure the time taken???'

the hard is to precalc the table....

then to compare with the time used using just the original routine, in the same all range of inputs.

and offcourse, to test that both outputs the same results.

By flyguille

Prophet (3029)

flyguille's picture

19-12-2008, 19:46

is there a emulator that in debug mode, allows to count up used cycles? from a given breack point to another brackpoint?

By GhostwriterP

Hero (527)

GhostwriterP's picture

19-12-2008, 20:28

How about this untested 8 bit version. I just drunk a lot of a beer so I cant tell if it is any good or faster even... either way it is definitly larger.

; in hl
; out a = sqrt(hl)

sqrt
  ld e,1

  bit 6,h
  jr nz,.large

  inc h
  ld a,l

.lus
  sub e
  inc e
  inc e
  jp nc,.lus

  dec h
  jp nz,.lus

  ld a,e
  rra
  dec a
  ret

.large
  ld a,h
  sub 63   ;-64+1
  ld h,a

  ld a,l  

.lusl
  sub e
  inc e
  inc e
  jr c,.flow 
  dec h
  jp nz,.lusl

  jp .lexit

.flow
  dec h
  jr z,.lexit
  dec h
  jp nz,.lusl

.lexit
  ld a,e
  scf
  rra
  dec a
  ret

By wouter_

Champion (422)

wouter_'s picture

20-12-2008, 00:41

is there a emulator that in debug mode, allows to count up used cycles? from a given breack point to another brackpoint?

It's already possible with openMSX: there is a command to get the current time in seconds (as a floating point number) since the MSX machine booted. Use this command twice, take the difference and multiply by the clockfrequency. So something like this:

<breakpoint 1 hit>
>  set t1 [machine_info time]

<breakpoint 2 hit>
> set t2 [machine_info time]
> expr ($t2 - $t1) * 3579545

Or write a script to automate (part of) this.

By ARTRAG

Enlighted (6330)

ARTRAG's picture

20-12-2008, 10:16

How do you set a break point in openmsx ?
Can I import the a symbol table from an assembler ?
Hmmm...
How do you call the command line ?
:-)

By GhostwriterP

Hero (527)

GhostwriterP's picture

20-12-2008, 12:17

; in hl
; out a = sqrt(hl)

sqrt
  ld e,1

  ld a,h
  sub 64
  jr nc,.large

  inc h
  ld a,l

.lus
  sub e
  inc e
  inc e
  jp nc,.lus

  dec h
  jp nz,.lus

  ld a,e
  rra
  dec a
  ret

.large
  ld h,a

  inc h
  ld a,l  

.lusl
  sub e
  inc e
  inc e
  jr c,.flow 
  dec h
  jp nz,.lusl

  ld a,e
  scf
  rra
  dec a
  ret

.flow
  dec h
  jr z,.lexit
  dec h
  jp nz,.lusl

.lexit
  ld a,e
  scf
  rra
  dec a
  ret

By Manuel

Ascended (16034)

Manuel's picture

20-12-2008, 13:31

How do you set a break point in openmsx ?

See: http://openmsx.sourceforge.net/manual/commands.html#debug
use the subcommand set_bp

Can I import the a symbol table from an assembler ?

Using the graphical gui for the debugger, you can. A snapshot can be downloaded from our web site: http://openmsx.sourceforge.net/temp/openmsx-debugger-win32-bin-snapshot.zip

You can also set breakpoints with that debugger of course.


Hmmm...
How do you call the command line ?
:-)

Hit F10, see also: http://openmsx.sourceforge.net/manual/user.html#console

Page 5/5
1 | 2 | 3 | 4 |