problem with a bit of code

This is a discussion on problem with a bit of code within the ASM x86 ASM 370 forums in Programming Languages category; Hi guys as you know i have not learned much of asm till now but i wrote a simple programme using icezelion tutorial in fasm .I know there are lots of mistake so pleae help me to do away with the mistake.The code is Code: include 'win32a.inc' msgboxcap db "my first programme' msgboxtext db "asm is great" invoke MessageBox, NULL, addr MsgBoxText, addr MsgBoxCaption, MB_OK invoke ExitProcess, NULL I am using fasm so i had to modify the code.As i am compiling it the fasm is opening another file called win32a and its written at the top of a dialog ...

Go Back   Application Development Forum > Programming Languages > ASM x86 ASM 370

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-03-2008, 04:31 PM
palbodhisattwa2016
Guest
 
Default problem with a bit of code

Hi guys as you know i have not learned much of asm till now but i
wrote a simple programme using icezelion tutorial in fasm .I know
there are lots of mistake so pleae help me to do away with the
mistake.The code is
Code:
include 'win32a.inc'
msgboxcap db "my first programme'
msgboxtext db "asm is great"
invoke MessageBox, NULL, addr MsgBoxText, addr MsgBoxCaption, MB_OK
invoke ExitProcess, NULL
I am using fasm so i had to modify the code.As i am compiling it the
fasm is opening another file called win32a and its written at the
top of a dialog box :file not found. I opened the fasm file and looked
into the include folder i saw the file "win32a".And another thing is
that at the right hand bottom of the task bar there is a warning
fasmw.exe is a corrupt file.When i bought the computer windows came
installed with it.For the first time i installed linux in my box on my
own and i made a partition from the drive where my fasm exist.Some
softwares were ruined i had to install them again so can this be a
problem for the above mentioned problem.Should i install the compiler
again

Reply With Quote
  #2  
Old 09-04-2008, 01:01 AM
NathanCBaker
Guest
 
Default Re: problem with a bit of code

On Sep 3, 4:31*pm, palbodhisattwa2016 <spamt...@crayne.org> wrote:
> Hi guys as you know i have not learned much of asm till now but i
> wrote a simple programme using icezelion tutorial in fasm .I know
> there are lots of mistake so pleae help me to do away with the
> mistake.The code is
>
Code:
include 'win32a.inc'
> msgboxcap db "my first programme'
> msgboxtext db "asm is great"
> invoke MessageBox, NULL, addr MsgBoxText, addr MsgBoxCaption, MB_OK
> invoke ExitProcess, NULL
> I am using fasm so i had to modify the code.As i am compiling it *the
> fasm *is opening another *file called win32a and its written at the
> top of a dialog box :file not found. I opened the fasm file and looked
> into the include folder i saw the file "win32a".And another thing is
> that at the right hand bottom of the task bar there is a warning
> fasmw.exe is a corrupt file.When i bought the computer windows came
> installed with it.For the first time i installed linux in my box on my
> own and i made a partition from the drive where my fasm exist.Some
> softwares were ruined i had to install them again so can this be a
> problem for the above mentioned problem.Should i install the compiler
> again


If you look in the ..\source\win32 subdirectory, you will see an
example of how to do a Windows program from Fasm. However, I believe
it would be too big of a job for a beginner to attempt to convert an
Iczelion Tutorial into Fasm code, so I suggest you enquire at the Fasm
forum to see if anyone has already accomplished this task.

http://board.flatassembler.net/

Nathan.

Reply With Quote
  #3  
Old 09-04-2008, 07:45 AM
James Harris
Guest
 
Default Re: problem with a bit of code

On 3 Sep, 21:31, palbodhisattwa2016 <spamt...@crayne.org> wrote:
> Hi guys as you know i have not learned much of asm till now but i
> wrote a simple programme using icezelion tutorial in fasm .I know
> there are lots of mistake so pleae help me to do away with the
> mistake.The code is
>
Code:
include 'win32a.inc'
> msgboxcap db "my first programme'
> msgboxtext db "asm is great"
> invoke MessageBox, NULL, addr MsgBoxText, addr MsgBoxCaption, MB_OK
> invoke ExitProcess, NULL


First off I'd suggest you include more white space in your
listings.... The above is awful hard to read and it's only five lines.

Second, welcome to the whacky world of assembler.

If it helps take a look at a piece of code to do something similar to
what you are trying - i.e. pop up a message box and then exit.

http://codewiki.wikispaces.com/winpopup.nasm

Maybe it will help you find what else you need to do to your code.

--
James

Reply With Quote
  #4  
Old 09-04-2008, 09:56 PM
NathanCBaker
Guest
 
Default Re: problem with a bit of code

On Sep 3, 4:31*pm, palbodhisattwa2016 <spamt...@crayne.org> wrote:
> Hi guys as you know i have not learned much of asm till now but i
> wrote a simple programme using icezelion tutorial in fasm .I know
> there are lots of mistake so pleae help me to do away with the
> mistake.The code is
>
Code:
include 'win32a.inc'
> msgboxcap db "my first programme'
> msgboxtext db "asm is great"
> invoke MessageBox, NULL, addr MsgBoxText, addr MsgBoxCaption, MB_OK
> invoke ExitProcess, NULL


I found a working example:

----8<----
format PE GUI
entry start

section '.code' code readable executable

start:

push 0
push _caption
push _message
push 0
call [MessageBox]

push 0
call [ExitProcess]

section '.data' data readable writeable

_caption db 'Win32 assembly program',0
_message db 'Hello, world!',0

section '.idata' import data readable writeable

dd 0,0,0,RVA kernel_name,RVA kernel_table
dd 0,0,0,RVA user_name,RVA user_table
dd 0,0,0,0,0

kernel_table:
ExitProcess dd RVA _ExitProcess
dd 0
user_table:
MessageBox dd RVA _MessageBoxA
dd 0

kernel_name db 'KERNEL32.DLL',0
user_name db 'USER32.DLL',0

_ExitProcess dw 0
db 'ExitProcess',0
_MessageBoxA dw 0
db 'MessageBoxA',0

section '.reloc' fixups data readable discardable
---->8----

Found that here:
http://en.wikibooks.org/wiki/Transwi...indows.2C_FASM

Nathan.

Reply With Quote
  #5  
Old 09-05-2008, 07:17 AM
palbodhisattwa2016
Guest
 
Default Re: problem with a bit of code

Thanks for the sorce code but i want to ask what is the stack used for
in asm.I know what is a stack,LIFO (last in first out).I made a
linked list programme in c++.Does this"stack" denote any place in the
memory or something else.In the following line
push _caption
As far as i think is _caption is a variable name .Where does this
"_caption" go.Where does the stack exist.Some place in memory???

Reply With Quote
  #6  
Old 09-05-2008, 01:46 PM
Wolfgang Kern
Guest
 
Default Re: problem with a bit of code


"palbodhisattwa2016" asked:

> Thanks for the sorce code but i want to ask what is the stack used for
> in asm.


It can be used the same way as in C, but in ASM we got much more
freedom to decide the how/why and when.

> I know what is a stack,LIFO (last in first out).I made a
> linked list programme in c++.
> Does this "stack" denote any place in the memory or something else.


Stack is precious memory anyway, pointed to by the SS:ESP pair.
A problem might be that return-addresses from CALL/Invoke and
arguments share the same stack in C-styled coding like winAPI
(x86 CPUs unfortunately got only one stack-pointer).

> In the following line
> push _caption
> As far as i think is _caption is a variable name.


Yes. But we push a 32-bit var-pointer rather than its name.
You wont find your variables by name in the final code.

> Where does this "_caption" go.


Usually defined somewhere in the data section,
it's the compilers job to tranform this symbolic name into
a binary address pattern, either an offset in a data-segment
if DOS or a flat pointer if windoze, Lunix or another flat-OS.

> Where does the stack exist. Some place in memory???


Yes, hopefully apart from code and other data, but we can
(at least in real-mode DOS) define ourself where it shall
reside in memory by loading SS and (E)SP.

I'd recommend you to read any of the tutorials on basic things
like registers, memory and stack, beside the mandatory RTFM
__
wolfgang

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 08:47 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.