Page 1 of 1

Assembler problem....

Posted: Thu Jul 03, 2008 12:05 pm
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

Posted: Thu Jul 03, 2008 12:43 pm
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.

Posted: Thu Jul 03, 2008 1:00 pm
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

Posted: Thu Jul 03, 2008 1:13 pm
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 ...

Posted: Thu Jul 03, 2008 6:39 pm
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