Assembler problem....

Just starting out? Need help? Post your questions and find answers here.
RichardL
Enthusiast
Enthusiast
Posts: 532
Joined: Sat Sep 11, 2004 11:54 am
Location: UK

Assembler problem....

Post by RichardL »

This is from a long time jaPBe + PureBasic user... but an absolute new boy with assembler on PC.
(But I wrote assemblers for other processors and know what they are about)

Please excuse posting here as well as in the jaPBe forum... I'm desparate :x

Simply put, the code snippet works when complied on its own BUT... when I copy and paste it into a larger program using the same jaPBe editor it:

(a) Does not highlight the op-codes
(b) Will not compile (Line 513 - Syntax Error!)
(c) Behaves the same when I copy the whole thing into PB's own editor.

Yes... it is declared in the large program.
Yes... ASM support is enabled.

I must be doing something really stupid; please can anyone suggest what?

Best regards
RichardL

Code: Select all

Declare ToggleWatchDog(TimeOut)

T.l = ToggleWatchDog(6)
Debug T.l

Procedure ToggleWatchDog(TimeOut)
  INC TimeOut
  MOV Eax, TimeOut
  ProcedureReturn 
EndProcedure
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Hi Richard,

I just pasted your snippet in several programs, and there is no problem : INC and MOV are highlighted, no compiler error.
Sorry I cannot reproduce the problem (using PB4.20 final).

Can you reproduce the problem from the command line, using PBCOMPILER.EXE directly? If yes, I would suspect a compiler bug.

PS : did you tried like this ?

Code: Select all

Procedure ToggleWatchDog(TimeOut) 
  !INC dword [p.v_TimeOut]
  !MOV Eax, dword [p.v_TimeOut]
  ProcedureReturn 
EndProcedure
So you don't need to enable inline asm.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
RichardL
Enthusiast
Enthusiast
Posts: 532
Joined: Sat Sep 11, 2004 11:54 am
Location: UK

Post by RichardL »

Hi,
I pasted your suggested code into the main program and I get highlighted code, but when I compile:

INC dword[p.v_Timeout]
error: undefined symbol

On its own (same instance of jaPBe) I get the same message.
Well at least we are getting consistent :)

I'm using:

jaPBe 3.8.3.697
PB 4.02

Thanks for your interest,
RichardL
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Just tried with PB4.02.
I only get an '!INC dword [p.v_TimeOut] : undefined symbol error' if TimeOut is not defined in the code, like

Code: Select all

Procedure ToggleWatchDog(TimesOut) 
  !INC dword [p.v_TimeOut] 
  !MOV Eax, dword [p.v_TimeOut] 
  ProcedureReturn 
EndProcedure
or

Code: Select all

Procedure ToggleWatchDog(Timeout) 
  !INC dword [p.v_TimeOut] 
  !MOV Eax, dword [p.v_TimeOut] 
  ProcedureReturn 
EndProcedure
Maybe some upper/lower case problem ?
But I am no asm guru ...
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

Your code runs fine here:

Code: Select all

Declare ToggleWatchDog1(TimeOut)
Declare ToggleWatchDog2(TimeOut)

T.l = ToggleWatchDog1(1)
Debug T.l
T.l = ToggleWatchDog1(2)
Debug T.l

Procedure ToggleWatchDog1(TimeOut)
  INC TimeOut
  MOV Eax, TimeOut
  ProcedureReturn
EndProcedure

Procedure ToggleWatchDog2(TimeOut)
  ! INC dword [p.v_TimeOut]
  ! MOV dword Eax, [p.v_TimeOut]
  ProcedureReturn
EndProcedure
As compiler options:

- enable inline support

I don't see a problem...

See also here:

http://www.xs4all.nl/~bluez/datatalk/pu ... _purebasic
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Post Reply