MSX Assembly Fibonacci

Page 2/2
1 |

By Gorlock

Supporter (11)

Gorlock's picture

17-01-2022, 04:30

That would be awesome! Thank you so much Santiago!

By thegeps

Paladin (1020)

thegeps's picture

17-01-2022, 06:42

I think that the best way is to use BCD math so ASCII conversion and printing will be easier

By ARTRAG

Enlighted (6828)

ARTRAG's picture

17-01-2022, 08:16

If you need code to convert integers to strings look for long2ascii here
It expects a 32 bit number in HLDE and a RAM pointer in BC where to put the result

By thegeps

Paladin (1020)

thegeps's picture

17-01-2022, 11:44

Oh, I remember that routine. It was discussed in this forum too. But when I noticed it I had already ready my BCD score routine for Freedom Fighter

By ro

Scribe (4669)

ro's picture

17-01-2022, 11:54

Ah, cool. Recently I did do a recursive Fibo in asm myself. I was just testing some stuff in the realm of compression techniques, binary trees and stuff. Just for fun and understanding Smile

By santiontanon

Paragon (1633)

santiontanon's picture

17-01-2022, 14:26

There you go:
- example assembler: https://braingames.santiontanon.dev/uploads/tmp/example.asm
- compiled rom: https://braingames.santiontanon.dev/uploads/tmp/example.rom

It's limited to 16 bit numbers, so, if you enter 50000 + 50000, the result will be wrong, of course. Also, only positive numbers :)

Converting ascii to integer and viceversa is always a bit tricky to start (as it involves multiplications and divisions, which the Z80 doesn't know how to do, and hence you have to write routines). But I hope the code is not too confusing :)

I had never used these CHPUT/CHGET BIOS routines, so, it was fun learning how to use them btw :)

By Gorlock

Supporter (11)

Gorlock's picture

17-01-2022, 19:58

Thank you guys! Much appreciated!

Page 2/2
1 |