hiya i have look at some examples and try c/p some but doesn't work - simply MessageBoxA example.
CODE
align 4
DLL_TEST7A:
PUSH 'user32.dll'
CALL LoadLibraryA
OR EAX,EAX
JZ >L4
PUSH EAX
PUSH 'MessageBoxA'
PUSH EAX
CALL GetProcAddress
OR EAX,EAX
JZ >L3
push 0
push 'hello'
push 'hello'
push 0
CALL EAX
L3:
CALL FreeLibrary
L4:
XOR EAX,EAX
RET
Not taking credit just c/p
Thanks
- Edit got to work
CODE SECTION
START:
PUSH 'user32.dll'
CALL LoadLibraryA
OR EAX,EAX
JZ >L4
PUSH EAX
PUSH 'MessageBoxA'
PUSH EAX
CALL GetProcAddress
OR EAX,EAX
JZ >L3
push 0
push 'hello'
push 'hello'
push 0
CALL EAX
L3:
CALL FreeLibrary
L4:
XOR EAX,EAX
invoke ExitProcess,0
thanks anyway :8)
You can do it like this too.
Code Section
Start:
INVOKE MessageBoxA,0,"Hello","Hello",0x0
ret
Then
c:\goasm /fo msgbox.obj msgbox.asm
Then
c:\golink /console msgbox.obj user32.dll
I mean I ain't no expert but I sure like to play around with GoAsm. :bg
I know but only possible to do with Standard WIN32 APIs if i wanna go for commands in my own dlls or any other i need that way =)
Your second version is correct. :thumbu
So I think that you don't need the attached file containing the EXE.
Welcome in GoAsm world !
Patrick
[attachment deleted by admin]
Hi RedApple,
There is no need to use LoadLibrary for the standard Windows libraries or your own. That is only necessary for delayed loading where you want to verify that the DLL exists before you call a function in it but do not wish to stop the application, for example when choosing between ToolHelp and PSAPI. Another possible scenario for needing LoadLibrary is when you do not know the name of the DLL at compile time, for example third party plugins, but these are the only ones I can think of. In GoAsm you can simply use the invoke statement with the DLL specified as follows...
invoke User32.dll:MessageBoxA, param0, param1, param2, param3
Similarly with your own DLL you can use...
invoke Mylib.DLL:MyFunction, param...
You can also specify the DLL name in the build file or on the command line and it is no longer necessary to include it in the invoke statement. In any case there is rarely a need to use LoadLibrary as the PELoader will generate an error message for you if the DLL is not found and stop your application from running, a very useful thing to take advantage of. The INVOKE statement in GoAsm is one of the most powerful tools available in the assembler and it is a good idea to make use of that power both for code flexibility and legibility. The other main advantage of using INVOKE is when you switch to 64 bit it will automatically switch to the FASTCALL convention from STDCALL, something that cannot be done with the PUSH/PUSH/CALL method without a major rewrite.
Donkey
In fact you don't even have to specify the dll extension when using it with the function.
Although specifing the dll with golink and not in the code is easier.
code
Start:
invoke user32:MessageBoxA, 0,"Hello","Hello",0x0
invoke kernel32:ExitProcess, 0
ret
Very nice :bg i have one question i know its a bit losely Question. What about Functions can i make functions in anyway?
I know its a bit losely to ask about since ASM don't got it, but im currectly working on a little project. Its about Translate a high lvl language to Goasm for fast and sizeable programs.
If not you got any suggestions how to do this ? push variables pop them and how would be easiest to find used parameters?
i have program FASM before but i feel GoAsm is so much easier to understand and easier to use.
Regards
Edit:
One more thing where to read this ? i haven't seen any good tutorials or documents about GoAsm hard to learn from nothing
Hi,
Generally functions are simply procedures in assembler, in GoAsm you would use the FRAME keyword to set up a function and call it using INVOKE, the help file has extensive documentation on how to use both. There are a number of good examples on Jeremy's site as well as links to other examples in GoAsm, my site also has a number of example projects using the RadASM IDE with GoAsm. In addition to this you can ask any question you have here and we will either point you in the right direction or help you directly.
For larger GoAsm projects you can look at my WinExplorer program, it is available on my website with complete GoAsm source, it demonstrates just about every feature in GoAsm and provides some very useful snippets of code including simple macros, COM calls, calling functions by ordinal, using static libraries and mutliple source files
BTW, welcome to GoTools :U
Donkey
Quote from: RedApple on August 30, 2006, 08:08:51 PM
What about Functions can i make functions in anyway? I know its a bit losely to ask about since ASM don't got it
Assembly has everything!
Here is a simple function example:
;*********************************************************************
; simple function example
; goasm hello.asm
; golink hello.obj /console /entry start
code
start:
push "Hello World!" ; parameter
call hello ; function call
ret
;---------------------------------------------------------------------
hello: ; function
push ebp
mov ebp,esp
push [ebp+8h] ; using the hello parameter as a
call crtdll:printf ; parameter for the function printf
add esp,4h ; balance the stack after a cdecl call
pop ebp
ret 4h
;*********************************************************************
Quote from: RedApple on August 30, 2006, 08:08:51 PM
i haven't seen any good tutorials or documents about GoAsm hard to learn from nothing
Read then manual and then start creating a bunch of small test programs. It is the best
way to learn.
I created some test applications when I was learning goasm. If you wish, email me and I'll
send them to you.
@donkey Thanks but its funny i found it too on the homesite when i just reflesh this side for see if any wrote back =)
@bracx =S too harsh for me to the begiing but i see the point.
I made my langauge so far(translate language)
msgbox("hello","okay")
function msgbox(msg,title) {
invoke MessageBoxA,0,[msg],[title],0
}
; or you can do
void msgbox(msg,title) {
invoke MessageBoxA,0,[msg],[title],0
endfunc
; or you can also
void msgbox(msg,title) {
invoke MessageBoxA,0,[msg],[title],0
}
; or ofkoz if you want it simple
int msgbox(msg,title)
invoke MessageBoxA,0,[msg],[title],0
endfunction
is going to be translated to
CODE SECTION
START:
invoke msgbox,"hello world","okay"
RET
msgbox FRAME title,msg
invoke MessageBoxA,0,[title],[msg],0
RET
ENDF
thats just function part, still working only worked like 2hours on it but goes fast.
I would hope that you guys would make UserDefined library. ofcourse you get Credit etc. The language going to be totaly free and just as the start supplier for Goasm.
I know sounds pointless and just doing it for fun but it could be really good if you can simulate almost look a like other languages to assembler.
Ah, you want to make your own language thats compiled to goasm.
Sounds like a fun project!
it is :bg i have made a VERY beta version of it. Please check it out at
http://www.4shared.com/dir/771256/fe289f94/Extender.html
the ex.txt is a included userdefined file. You can include with
include ex.txt
when you made some things you wanna implant then just drop it of here and i implant it.
any suggestions, bug reports, bad/good things please tell me.
I know this isn't GoASM but it make it COMPLETLY goasm, that only can compile with goasm.
One thing any got a good name for my translator - GoHigh :lol
WARNING it save the Goasm file as sammy.txt - may get removed if you have one allready there
Regardsz
I did a similar type of project for a hobby game I was working on. Instead of a full blown compiler
I used a macro processor for the translator into goasm. I even was able to implement a prototype
like object system. You may want to look at M4 or ML1 or GEMA or FunnelWeb as a translator.
For example these functions:
FUNC StMenuInput
do c keypressed
if eax = -1
do c readkey
shr eax,8
let [rkey] = eax
if B[rkey] = 20
do [GmManager.PopState]
elseif B[rkey] = 59
do [GmManager.ChangeState] <- addr StStop
endif
endif
RET
FUNC StMenuDraw
deref [screen] -> eax
do c blit <- [mdisp], eax, 0, 0, 0, 0, 640, 480
RET
Were translated to:
StMenuInput:
call keypressed
cmp eax,-1
jne >ZA0456
call readkey
shr eax,8
mov [rkey],eax
cmp B[rkey],20
jne >ZA0463
call [GmManager+20]
jmp >ZZ463
ZA0463:
cmp B[rkey],59
jne >ZA3463
push addr StStop
call [GmManager+12]
jmp >ZZ463
ZA3463:
ZZ463:
jmp >ZZ456
ZA0456:
ZZ456:
ret
StMenuDraw:
mov eax,[screen]
mov eax,[eax]
push 480
push 640
push 0
push 0
push 0
push 0
push eax
push [mdisp]
call blit
add esp,32d
ret
With the following macro definitions: excerpt of the full file
MCSKIP ; WITH ; NL
;; ********************************************************************
;; File: ml1-goasm.src
;; Desc: ML/I macro definitions to use with GoAsm
;; Author:Brian Algeri
;; Rev: Init 01/10/2006
;; Under darcs version control
;; Editor: MicroEmacs
;; ********************************************************************
;;
MCSKIP MT,{}
MCSKIP T,`'
MCSKIP SNL NL
MCSKIP DESIGN ENDNOTES
MCSKIP NOTES ENDNOTES
;;
;;====================================================================
;;
MCINS %.
;;
;;====================================================================
;;
MCDEF FUNC NL RET AS {SNL
%A1.:
%A2.SNL
ret}
;;
;;====================================================================
;;
MCDEF do OPT <WITH- N1 OPT , N1 OR NL ALL OR NL ALL AS {SNL
MCGO L2 IF T1 EN 1
MCSET T2 = T1
%L1.push %AT2.
MCSET T2 = T2 - 1
MCGO L1 UNLESS T2 EN 1
%L2.call %A1.
}
;;
;;====================================================================
;;
MCDEF {do} WITHS c OPT <WITH- N1 OPT , N1 OR NL ALL OR NL ALL
AS {SNL
MCGO L2 IF T1 EN 1
MCSET T2 = T1
%L1.push %AT2.
MCSET T2 = T2 - 1
MCGO L1 UNLESS T2 EN 1
call %A1.
MCSET T2 = T1 - 1
MCSET T2 = T2 * 4
add esp,%T2.d
MCGO L3
%L2.call %A1.
%L3.}
;;
;;====================================================================
;;
MCDEF let = NL AS {SNL
mov %A1.,%A2.
}
;;
;;====================================================================
;;
MCDEF loop NL repeat AS {SNL
mov ecx,%A1.
ZZ%T2.:
push ecx
%A2.SNL
pop ecx
dec ecx
cmp ecx,0
jne <ZZ%T2.}
;;
;;====================================================================
;;
MCDEF if OPT = OR < OR > ALL NL N1 OPT elseif OPT = OR < OR > ALL NL N1
OR else NL N1 OR endif ALL AS {SNL
MCSET T3 = 0
%L1.
cmp %AT3+1.,%AT3+2.
MCGO L2 IF %DT3+1. = =
MCGO L3 IF %DT3+1. = <
MCGO L4 IF %DT3+1. = >
%L2.jne >ZA%T3.%T2.
MCGO L5
%L3.jge >ZA%T3.%T2.
MCGO L5
%L4.jle >ZA%T3.%T2.
MCGO L5
%L5.%AT3+3.SNL
jmp >ZZ%T2.
ZA%T3.%T2.:SNL
MCSET T3 = T3 + 3
MCGO L10 IF %DT3. = endif
MCGO L9 IF %DT3. = else
MCGO L1 IF %DT3. = elseif
%L9.
%AT3+2.SNL
%L10.
ZZ%T2.:}
;;
;;====================================================================
;;
MCDEF deref -WITH> NL AS {SNL
mov %A2.,%A1.
mov %A2.,[%A2.]
}
;;
;;====================================================================
The hardest part for me is to get it to nest :dazzled:
Nice code im trying understand but still only know the basic of GoAsm.
Please try my test version and write some functions.
PS just uploaded new version,library, and example
Regards
Quote from: RedApple on August 31, 2006, 03:44:47 AM
still only know the basic of GoAsm.
I would recommend that you first learn more assembly before you try to translate
or compile to a assembly output.
I would follow these steps
1. Read the manual
2. Re-read the manual
3. Use the manual as a reference
4. Read the Intel manuals
5. Google assembly tutorials and browse through them - most will be for dos but still good information.
5. Start building small test programs
6. Concentrate on console only programs at first
7. Go through the Iczelion's Win32 tutorials
7. Work your way up from there
8. Then do the translator or compiler to assembly
Just my suggestion
And have fun coding! :bg
@1.
i have read lot of manuals :bg
@2.
Also done that :)
@3.
I am i am :D
@4.
I have read some about lot diffence ints but not from the intel manual
@5.
I love google and i praying to google - yes i have done
@5.
I am also doing that, only console becuase i feel its hard to make GUI programs - also in c/++ its hard.
@6.
I am said again.
@7.
I have, i've also used MASM32. but for me it seem like a high lvl language and not assembler and don't like the syntax too.
@7.
I am i am i am :D
@8.
its making assembly :D
Im working on a new version. So far i made If/elseif/else nested too. Im working on the =. But its even harder to make it nested and compatible to ascii and numbers. also made ; as newline(c style)
The problems is that i don't know the way i should handle types as float,integers,ascii, and make them reuse fixed strings etc.
But still the meaning why i use Librarys is for other ppl to make code that i will implant. Make your own library and help me improve. I wont take any credit for your work!
Example
function CopyFile(from,to)
; Made by John Smith - johnsmith@hotmail.com
invoke CopyFileA,from,to,1
endfunction
just a example!
I will currect the file to work in future version BUT I WILL NOT REMOVE THE COMMENT OR EDIT IT!
Please post examples.
Regards