Jump to content

Can't get jumping to work

- - - - -

  • Please log in to reply
3 replies to this topic

#1
Smilex

Smilex

    Learning Programmer

  • Members
  • PipPipPip
  • 84 posts
error A2006: undefined symbol : exit

I have been following the assembly tutorials on these forums ( thanks Darguetta and Gokuajmes ) and I made the code below. But I get the error above, and I don't see why. I see that 'exit' is used before it's defined, yet I don't see how it could be done any other way, to get around this.
EDIT: I'm using WinASM


.386

.model flat, stdcall

option casemap:none


include windows.inc

include kernel32.inc

includelib kernel32.lib

include user32.inc

includelib user32.lib


.data


MsgBoxCaption 		db "Simple MessageBox Program",0

MsgBoxTextTrue		db "TRUE" ,0

MsgBoxTextFalse		db "FALSE" ,0



.code


mov ebx, 0

cmp ebx, 1

jne DO_FALSE

invoke MessageBox, NULL, addr MsgBoxTextTrue, addr MsgBoxCaption, MB_OK

jmp exit


DO_FALSE:

invoke MessageBox, NULL, addr MsgBoxTextFalse, addr MsgBoxCaption, MB_OK

end DO_FALSE


exit:


invoke ExitProcess,0


end exit


Edited by Smilex, 22 February 2011 - 03:26 AM.
Missing information


#2
Gunner

Gunner

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts
Well, MASM needs to know the starting and end address of your code and you do that with 2 labels... a start label (name it anything you want) and a matching end label...

.386

.model flat, stdcall

option casemap:none


include windows.inc

include kernel32.inc

includelib kernel32.lib

include user32.inc

includelib user32.lib


.data


MsgBoxCaption 		db "Simple MessageBox Program",0

MsgBoxTextTrue		db "TRUE" ,0

MsgBoxTextFalse		db "FALSE" ,0



.code

StartMyApp: ; < ---- need this label, name it anything you want

	mov ebx, 0

	cmp ebx, 1

	jne DO_FALSE

	invoke MessageBox, NULL, addr MsgBoxTextTrue, addr MsgBoxCaption, MB_OK

	jmp exit

	

	DO_FALSE:

	invoke MessageBox, NULL, addr MsgBoxTextFalse, addr MsgBoxCaption, MB_OK

	; end DO_FALSE  < ------ this is wrong and not needed


exit:


	invoke ExitProcess,0


end StartMyApp ; < ---- needs to match your start label


#3
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,252 posts
  • Location:C:\Countries\US
You use labels to mark different locations in your code; labels don't have to be terminated.

If you used binary 1s and 0s to make programs then you would have had to work with addresses directly and actually enter the offsets, having to change each address almost every time you modify your program (maybe you already know this, but I decided to say it anyway).

#4
Smilex

Smilex

    Learning Programmer

  • Members
  • PipPipPip
  • 84 posts
Thanks guys, got it working.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users