Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Call absolute crashes after N calls?
#1
Heres the ASM code I'm trying to run:
Code:
5589E5B8054FBB00008B5606CD105DCA0200


55
89 E5
B8 05 4F
BB 00 00
8B 56 06
CD 10
5D
CA 02 00


push bp
mov bp, sp
mov ax, 4f05h
mov bx, 0
mov dx, [bp+6]
int 10h
pop bp
retf 0002

I load it into a string (converting to chr$()) and call absolute it.

After around ~5000 calls QB crashes, and I really mean crashes, it crashes in the middle of writing a string to a file for example, writing only half the string and such.

Why?, What did I do wrong?

EDIT:
No, I don't want to use a lib. I want to use call absolute unless this is a known bug with it. And if it is, is there a workaround?
Reply
#2
Sounds like you aren't cleaning up the stack properly. What are the parameters - how many?
Reply
#3
I'm only sending an integer value (ranging from 0-65535) nothing else.

And I reset each register used in the asm procedure:
Example:
mov bx,0


The weird thing is that it works ~5000 times, then suddenly everything crashes.
Reply
#4
Here's my suggestion: Write a simple test program that only sets a VESA screen mode, then CALL ABSOLUTEs that asm code over and over in a loop, and see if this program crashes too.

That will rule out the possibility that another part of your program is causing the problem.
Reply
#5
Obvious question: are you passing the parameter by value?

def seg = varseg(codeseg(0))
Call Absolute (BYVAL param%, 0)
Reply
#6
I'm using byval.

It's not call absolute, it is the asm code, it crashes after switching bank a number of times.

If it only draws on the same bank there is no problem, but when switching a lot it crashes, why?

Here's the debug file:
Code:
A             X             Y             Offset        NewBank       Bank
5150          341           323           207061        196608        262144
5151          48            41            26288         0             196608
5152          320           408           261440        196608        0
5153          492           448           287212        262144        196608
5154          591           89            57551         0             262144
5155          196           43            27716         0             0
5156          171           29            18731         0             0
5157          48            244           156208        131072        0
5158          148           98            62868         0             131072
5159          423           414           265383        262144        0
5160          366           361           231406        196608        262144
5161          308           70            45108         0             196608
5162          399           76            49039         0             0
5163          572           401           257212        196608        0
Where A is the number of calls (loops)
The X, Y position has nothing to do with anything, nor which bank to set, as Bank 0 has been used before.
NewBank is the Bank to be used in the NEXT call.
Bank is used on call N
NewBank is used on call N+1

If I fill the whole screen by using two for/next loops (X, Y, 640, 480) Then it works fine, it fills the whole screen, it's only when using random pixels it crashes.


And now I'm more confused then ever, it can plot 640*480 pixels, but not ~5000 random ones.

What am I doing wrong?
Reply
#7
I know nothing about ASM, but you said "random pixels",
are you using RND? If so, are you sure that the variables you
pass to the function are INTEGERS?

(Make sure you either DIMed them as INTEGERS, use the % suffix or you use DEFINT A-Z)

If not, is the ASM stuff made to accept other things than integers?

If it's some sort of pset routine, make sure that you don't pset outside

x = 0 TO screenmode_width - 1
y = 0 TO screenmode_height - 1
/post]
Reply
#8
Heh, I hope someone else is reading this, cos you've confused the hell outta me :p

What do those NewBank/Bank values stand for? They're not valid bank numbers you can stuff into registers. Are they just calculated window offsets? Where do you calculate the actual bank numbers?
Reply
#9
The real bank is: Bank/65536 (NewBank/65536)

I'm not dividing until just before I actually call the asm routine, it makes it faster. I'm testing to see if a bank switch is needed before dividing, if it's needed then I divide.


And red_marvin, thanks, but I'm using integers. The same x, y coordinate on itself works fine, and the bank has been used a lot of times before the crash call.

Also, it's not when calling it crashes, it can crash at any time after ~5000 call absolutes, like I said, sometimes the last row of the debug file is cut in half.


And it's only when using random pixel locations, ie: A lot of bank switching.
If I fill the whole screen it works fine. (for y=0 to 480: for x=0 to 640:next:next)
Reply
#10
What are you using to generate the Opcodes? I had problems with Debug and Debug98 in a windows environment.

Try to PM Plasma as he made the coolest OBJ to Opcode converter. :*)
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)