BBC BASIC for Windows
« Using variables in Assember »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:31pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Using variables in Assember  (Read 962 times)
Matt
Developer

member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Using variables in Assember
« Thread started on: May 29th, 2013, 5:24pm »

Hi,

(Edit: just figured out what the problem to this is - memory allocation is too small.)

Ok. What am I missing here. I've checked all the help I can find, but I still can't work it out.

This works (extrapolated from BB4W help):
Code:
      ypos% = 10
      xpos% = 10
      DIM code 20
      FOR opt=1 TO 3 STEP 2
        P%=code
        [OPT opt
        .win
        push 5
        push 0
        push 0
        push ypos%
        push xpos%
        push 0
        push @hwnd%
        call "SetWindowPos"
        ret
        ]
      NEXT
      CALL win 


x/ypos% variables seem to be set in the memory as absolute vaues. Therefore changing them and then RE-calling the code makes no difference. This I understand.

However, looking at the code in MDILIB.BBC...

Code:
...
      .N%
      cmp dword [esp+8],&600 : jz M%
      pop eax : push [^O%] : push eax : jmp "CallWindowProc"
      ]
      SYS "GetWindowLong",@hwnd%,-4 TO O%
      SYS "SetWindowLong",@hwnd%,-4,N%
... 


This seems to imply form my novice perspective that using push [^variable] instead of just push variable should allow the variable to be changed and then the code to be re-called.

From BB4W Help:
Quote:
In assembly language code you might want to copy the value of a BBC BASIC (integer) variable into one of the processor's registers:
mov eax,[^variable%]


However,
Code:
      DIM code 20
      FOR opt=1 TO 3 STEP 2
        P%=code
        [OPT opt
        .win
        push 5
        push 0
        push 0
        push [^ypos%]
        push [^xpos%]
        push 0
        push @hwnd%
        call "SetWindowPos"
        ret
        ]
      NEXT
      ypos% = 10
      xpos% = 10
      CALL win 


not only doesn't work, it crashes BB4W.

I'm obviously missing something fundamental and probably quite obvious to others, but I just cannot figure this out (and I'm getting tired of restarting BB4W).

Matt
« Last Edit: May 29th, 2013, 9:01pm by Matt » User IP Logged

Matt
Developer

member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: Using variables in Assember
« Reply #1 on: May 29th, 2013, 9:04pm »

What's the easiest way to check what memory is required? The only way I can see of doing it is to over estimate, then look at the memory locations on the listing and work out the usage from that. This can then be used to edit the program.

Matt

Edit: Worked it out :- end code with PRINT P%-code
« Last Edit: May 29th, 2013, 9:17pm by Matt » User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Using variables in Assember
« Reply #2 on: May 29th, 2013, 9:18pm »

on May 29th, 2013, 5:24pm, Matt wrote:
Ok. What am I missing here.

What you are missing is that you are using FOR opt=1 TO 3 STEP 2 when you should be using FOR opt=9 TO 11 STEP 2 with L% initialised appropriately. That will raise an error if you exceed the allocated space.

Richard.
User IP Logged

Matt
Developer

member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: Using variables in Assember
« Reply #3 on: May 30th, 2013, 04:55am »

Thanks Richard,

I overlooked that 'bit'.

Matt
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls