NASM Forum > Programming with NASM

Weird problem with "call"

(1/3) > >>

isywum:
Hi all :)

I'm have a big problem with "call".
I'm writing a funtion to draw a line (for my OS), it's absolutely empty but I can "call" it only 13 times.

--- Code: ---DrawLine:
dl_start:
     ; just empty
ret

; ...

call DrawLine
call DrawLine
call DrawLine
call DrawLine
call DrawLine
call DrawLine
call DrawLine
call DrawLine
call DrawLine
call DrawLine
call DrawLine
call DrawLine
call DrawLine
call DrawLine

; ...

--- End code ---
If I call it the 14th time it crashes and stops.
Does anyone know why this happens?

Thanks in advance!

Frank Kotler:
I don't see anything in what you show that could be a problem. Could it be the size of the code, rather than the number of call instructions? (trying to run more code than you've loaded, or some such?) As a "debugging experiment", can you call your empty function 14(+) times in a loop, rather than with multiple "inline" calls?

I'm sure it doesn't matter, but I'm curious how you happened to discover this problem. Why are you calling an empty function 14 times? I suppose it wasn't empty when you first noticed it...

I've read generic debugging advice that says, "If your program doesn't work, something you believe to be true is not true." Now you just have to figure out what that is! :) Since I can't see anything wrong here, I suspect the problem must be elsewhere...

Very strange! If you can't figure it out, give us more "context"...

Best,
Frank

isywum:
Hi,

You're right, my function wasn't empty before but I wanted to check out if the code in the function is the reason. I forgot to tell you one really important thing. I have a boot.bin and a kernel.bin file. I want to copy them (with the cmd copy function) to an *.img. I had often the problem that a huge part of the kernel.bin wasn't copied to the *.img until I copied it binary -> copy /b boot.bin + kernel.bin OS.img. There wasn't the "call problem" before. Maybe the reason isn't Assembler (there are no errors and warning) but the copying. It is an Operation System and not an application and I don't have a lot of experience...
I'm gonna try your proposes. :)

Thanks!

EDIT:
The size of the application is always the same because of

--- Code: ---times 1228247-($-$$)-2 db 0

--- End code ---

isywum:
Well, I tried this code

--- Code: ---mov cx, 0
calltest:
call dl_DrawLine
inc cx
cmp cx, 9999
je ende
jne calltest

--- End code ---
and it works! But it doesn't help me because I can't use this function like this. :D
Do you have an idea why the first way dosn't work?

Thanks!

Frank Kotler:
Size. You copy boot.bin and kernel.bin to os.img. In your boot.bin, you read some number of sectors into memory, presumably. How many? Enough? Have you got enough memory there to fit without overwriting anything? That's the kind of thing I'd be looking at. Hard to say without seeing the whole setup...

If it wuz easy, everybody'd be doing it! :)

Best,
Frank

Navigation

[0] Message Index

[#] Next page

Go to full version