Qbasicnews.com

Full Version: I suck at Assembly, so...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
... could you help? I am writing this simple routine using Power Basic's inline assembly capabilities. It just blits a buffer to video memory (16 kb). For some reason, the program keeps crashing after some iterations. I'm sure that the problem is in this routine:

Code:
Sub Blit (BYVAL Ssegment AS WORD, BYVAL Soffset AS WORD) '(BYVAL var AS DWord)

    ' PB35 inline assembly ROCKS! (8086 only, but still...)

    ! push ds
    ! push es
    ! mov ax, Ssegment
    ! mov ds, ax
    ! mov si, SOffset

    ! mov ax, &hb800
    ! mov es, ax
    ! mov di, 0

    ! mov cx, 8192
    ! rep movsw
    ! pop es
    ! pop ds

End Sub

Thanks!
You should CLD before the rep movsw to make sure it copies forward. Other than that, I don't see why it wouldn't work...

Could you be copying too many bytes?
Yeah, I forgot the CLD. I'm gonna try it out. Maybe another stuff in the program makes the copy go backwards and that's why it crashes after some iterations.

I'm copying 16 Kb: a buffer to CGA memory. Thanks!

EDITED: Nah, it still crashes. Something must be corrupting my string space, 'cause some text should be printed in the buffer and it isn't being printed. I watched the string variables containing the text that has to be put and they are empty :o. I'm pretty sure that this is the routine which doesn't work 'cause if I remove the call to "Blit" and I use the screen directly (not the buffer) everything works like cake... Odd enough Sad
mov cx, 8192


Dunno but try to append an "d".

"h" is prolly the norm. ;*)
BTW, where can you find PB?


That looks cool!!!!
Quote:mov cx, 8192


Dunno but try to append an "d".

"h" is prolly the norm. ;*)
BTW, where can you find PB?


That looks cool!!!!

As far as the PB help reads, the number format is the same than in BASIC (I.E. I use &hb800 format, for example), anyhow I'll play with it.

About wher to find PB... Maybe in your inbox some time later Wink As long as you have ~400 spare Kb...
I've no idea why your code dosn't work. But what i try is to save di and si.

Maybe PB use them in same way.
Thanks, Xhantt, I'll try that as well.

Phew! This is getting though! AND I NEED THAT BLITTER!!! ARGHH!!