Older code now crashes!

Discussions related to using the integrated assembler
Post Reply
User avatar
hellomike
Posts: 13
Joined: Sat 09 Jun 2018, 09:47

Older code now crashes!

Post by hellomike » Mon 23 Jul 2018, 20:18

Hi,

IN 2014, I contributed the following program to Rosettacode.

http://rosettacode.org/wiki/Machine_code#BBC_BASIC

As you can see, a very small and simple program. Of course I tested it thoroughly.
Today, in 2018, I find that exactly the same code now crashes BB4W!

Differences 2014 vs 2018 (now): Windows 7 32bit hardware vs Windows 10 64bit hardware.

On Windows 7 32bit hardware it still works.
Both are on BB4W v6.11a.

Also I'm pretty sure that I ran the code like a week ago successfully on the same (Win10) system but in such situations one starts doubting everything :?
I hope someone sees the inconstancy or can test the program on their machine because I'm totally and utterly flabbergasted :shock:

Thanks

Mike

DDRM
Administrator
Posts: 48
Joined: Mon 02 Apr 2018, 18:04

Re: Older code now crashes!

Post by DDRM » Tue 24 Jul 2018, 12:14

Hi Mike,

Seems to work here (Win7 64 bit).

Interesting: I've never seen SYS used like that to call an assembled fragment. I like the way you can pass parameters and get a result. I guess you couldn't use USR because of the terms of the challenge?

best wishes,

D

Zaphod
Posts: 33
Joined: Sat 23 Jun 2018, 15:51

Re: Older code now crashes!

Post by Zaphod » Wed 25 Jul 2018, 00:09

Mike, works here on Windows 10 64 bit, both in the IDE and compiled, so it is a mystery.
At times like that I usually look out the window in case there is a UFO hovering overhead. Not seen one yet though.
Z

User avatar
hellomike
Posts: 13
Joined: Sat 09 Jun 2018, 09:47

Re: Older code now crashes!

Post by hellomike » Wed 25 Jul 2018, 08:57

Thanks folks.

Yes, my Win10 has a very deeply rooted abnormality somewhere. VirtualRPC stopped working (crashes) and the Win10 1803 update just doesn't install. I would almost suspect a virus, almost.
But this is so basic.

For a while I suspected the two values on the stack because when the code returns (ret), should the stack be left clean by it?
I.e. isn't the code responsible for cleaning up its own stack section before returning? I'm not that knowledgeable with assembly code.
Of course its isn't the reason because it works everywhere.

Regards,

Mike

User avatar
hellomike
Posts: 13
Joined: Sat 09 Jun 2018, 09:47

Re: Older code now crashes!

Post by hellomike » Fri 27 Jul 2018, 09:53

Well, it gets even better. I simplified the code as follows:

Code: Select all

      DIM Dimmed% 15
      P%=Dimmed%
      [OPT 3
      ret
      ]
      CALL Dimmed%

      SYS "GlobalAlloc", 0, 16 TO GAlloc%
      IF GAlloc%==0 ERROR 100,"GlobalAlloc failed"
      P%=GAlloc%
      [OPT 3
      ret
      ]
      REMCALL GAlloc%
      SYS "GlobalFree", GAlloc%
      END
This works but when I remove the REM, the code crashed BB4W. Even when operating in Save Mode!
Application Log simply reports "Exception code: 0xc0000005".

On a Win10 laptop, there is no problem.

It seems as if I'm not allowed to Execute code in memory allocated with GlobalAlloc. Really super awkward! For the rest this desktop is running perfectly with very complex game-applications and more. Also all my other BB4W programs run fine.

I hope Richard or someone else knowledgeable reads this and can give some kind of hint. It certainly isn't a BB4W issue so definitely off-topic but I feel I'm sooo close in tackling this.

Thanks

Mike

Post Reply