Page 1 of 1

ASM Questions

Posted: Sun May 29, 2005 10:06 am
by willib
HI all freaks.
Newly I try to code ASM in Purebasic.
Here the first try:

Code: Select all

Declare MyTest(dwoffset.l,anza.l)
testa.s=" DFDGHJKGHJKGbHJKDHSKJGADHJKHGJ"
; test.s= ""
a=MyTest(@testa,Len(testa))
Debug a
MessageRequester("ASM Example", "Should be 101: "+Str(a), 0)
End 
Procedure.l MyTest(dwoffset.l,anz.l)
  MOV eax, 0
  MOV ebx, dwoffset      ;ebx = ptr to buffer 
  MOV ecx, anz           ;ecx = length of buffer (counter) 
  schleif:  
  MOV dl, byte [ebx] 
  CMP dl,"b" 
  JNE l_scha
  ADD eax,1
  scha:
  ;MOV dl, byte [ebx] 
  CMP dl,"A" 
  JNE l_schb
  ADD eax,100
  schb:
  INC ebx
  DEC ecx  
  JNZ l_schleif  
  ProcedureReturn  
EndProcedure
; ExecutableFormat=Windows
; EnableAsm
; EOF
And here are the question:
Why do I get an "illegal instruction" error ( ASM ) if I enable the test.s in the 3rd line.
Why do i get a "garbage to the end of line" error ( Compiler ) if I enable the 2nd MOV d1, byte [ebx] statement.
I do not need it here but later I want to work with 2 strings. And for me it is codeable.
Any help would be appreciated.
Best regards.
W. Bückmann
WIN XP JAPBE 1.4.4.25 PB 3.92

Re: ASM Questions

Posted: Sun May 29, 2005 12:56 pm
by jack
willib wrote: Why do I get an "illegal instruction" error ( ASM ) if I enable the test.s in the 3rd line.
Why do i get a "garbage to the end of line" error ( Compiler ) if I enable the 2nd MOV d1, byte [ebx] statement.
I do not need it here but later I want to work with 2 strings. And for me it is codeable.
Any help would be appreciated.
Best regards.
W. Bückmann
WIN XP JAPBE 1.4.4.25 PB 3.92
test is an assembler opcode, with inline asm-enabled it is treated as such.
about your second question, there's no problem, I copied and pasted your code and removed the comment that's right after the label "scha:" and it compiled and run just fine.
btw i think you mistyped your 2nd question.

Posted: Sun May 29, 2005 8:46 pm
by willib
HI Jack

Many thanks for the informations you gave me.
It seems to be that the error only occurs in 392 I have installed
the 393 version and now it runs. :oops:


Willi