The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: supercoollee on April 29, 2010, 04:51:46 PM

Title: can i go directly to low level programming? such as mov, cmp, jmp
Post by: supercoollee on April 29, 2010, 04:51:46 PM
i already know some opcodes and i can write instructions in existing EXE/DLLs (modifying them). now i want to create my own software from scratch, so i downloaded MASM32. but MASM32 looks like other programming languages to me - having to learn new syntax etc.
what i want to create is a simple 3D game with OpenGL graphics and sound. can i write the whole software in low level opcodes? such as these:

shl eax,02
lea eax,[eax+eax*8+00000d08]
mov ecx,[0053301c]
mov edx,[ecx+24]
mov edx,[edx+08]
add edx,eax
ret

i have written thousands lines of these codes, i like these type of codes. can i program in this way?
Title: Re: can i go directly to low level programming? such as mov, cmp, jmp
Post by: jj2007 on April 29, 2010, 05:24:35 PM
Absolutely, no problem. Yiou are not obliged to use print or invoke, just use the opcodes only if you prefer.
Title: Re: can i go directly to low level programming? such as mov, cmp, jmp
Post by: supercoollee on April 29, 2010, 05:32:12 PM
maybe you didn't get my meaning  :eek
what i mean is that, can i do programming only by writing low level codes, without learning something like this:

start:

    call main
    inkey
    exit

main proc

    cls
    print "Hello World",13,10

    ret

main endp

end start
Title: Re: can i go directly to low level programming? such as mov, cmp, jmp
Post by: Neil on April 29, 2010, 05:47:15 PM
All the code you posted is based on Macros, print, inkey, cls etc.
As jj2007 says you are not obliged to use these, they are just convenient shorthand forms of lower level code, look them up in macros.asm.
Title: Re: can i go directly to low level programming? such as mov, cmp, jmp
Post by: clive on April 29, 2010, 06:06:07 PM
You'll need to put you code into a suitable format, but you are not required to use MACRO's or High Level Language extensions.

        .386
        .MODEL Flat

        .DATA

        ; Your Data

        .CODE

start:

        ; Your Code

        END start
Title: Re: can i go directly to low level programming? such as mov, cmp, jmp
Post by: Slugsnack on April 29, 2010, 06:59:11 PM
sounds like you've been used to programming inline in ollydbg or something.. at least that is much how i started. things you will have to learn include labels, how to declare functions, etc. just try to do whatever you want then if you can't get it working come back and ask or check out the documentation
Title: Re: can i go directly to low level programming? such as mov, cmp, jmp
Post by: hutch-- on April 29, 2010, 09:52:21 PM
supercoollee,

MASM is a great tool for writing exactly the type of code you have in mind but the catch is you have you learn enough to do that. In 32 bit Windows you must interact with the operating system to get any data IO, display anything on the screen or write any form of interface. You will need to write all of your own runtime library if you don't want to use the existing MASM32 code and if you don't want to use the built in MASM pseudo high level constructions you will need to learn how to write all of your own compare/branch code.

Generally what most folks do is use the simplified high level stuff for code that does not matter in terms of speed and keep the pure mnemonic code for high speed routines where you can see the difference.
Title: Re: can i go directly to low level programming? such as mov, cmp, jmp
Post by: dedndave on April 30, 2010, 01:07:31 AM
i think he is talking about CALL MAIN   :bg
this program will do the same thing

        include \masm32\include\masm32rt.inc

        .code

start:  cls
        print   "Hello World",13,10
        inkey
        exit

        end     start

but, yes - you can go straight to low-level code, as well

        include \masm32\include\masm32rt.inc

        .code

start:  mov     eax,3
        mov     edx,5
        mul     edx
        print   uhex$(eax),13,10
        inkey
        exit

        end     start
Title: Re: can i go directly to low level programming? such as mov, cmp, jmp
Post by: Farabi on April 30, 2010, 01:41:48 AM
Quote from: supercoollee on April 29, 2010, 05:32:12 PM
maybe you didn't get my meaning  :eek
what i mean is that, can i do programming only by writing low level codes, without learning something like this:

start:

    call main
    inkey
    exit

main proc

    cls
    print "Hello World",13,10

    ret

main endp

end start


You only need invoke to use OpenGL, and the code above is a basic template you must use.
Here is an example using OpenGL

Invoke glVertex3f,CFLT(1.0),CFLT(1.0),CFLT(1.0)


Dead simple.
Title: Re: can i go directly to low level programming? such as mov, cmp, jmp
Post by: supercoollee on April 30, 2010, 03:46:19 AM
thanks all. i'll try to learn those.

firstly, do i have to put the masm32 folder in root directory? such as d:\masm32\ ?
currently i put it like this d:\tool\asm\
i opened hello.asm in tutorial folder, with QEDITOR.EXE. then run the menu "Console Assemble and Link" , there is no response.

can someone tell me which files should i read before i actually start programming?
Title: Re: can i go directly to low level programming? such as mov, cmp, jmp
Post by: dedndave on April 30, 2010, 03:54:35 AM
yes - it must be in the root
you could possibly make it work in a deeper folder, but not without a lot of effort
i used to have mine in C:\masm32 but i think i will use D:\masm32 from now on
if i have to rebuild the C drive - i won't have to mess with it
Title: Re: can i go directly to low level programming? such as mov, cmp, jmp
Post by: dedndave on April 30, 2010, 03:57:13 AM
Jochen made this page to help people get started...

http://www.webalice.it/jj2006/Masm32_Tips_Tricks_and_Traps.htm

then, Iczelion's tutorials can help you with 32-bit code

http://website.masm32.com/iczelion/iczelion.zip

there are also great resources in the masm32 folders:
examples, help, tutorials
Title: Re: can i go directly to low level programming? such as mov, cmp, jmp
Post by: supercoollee on April 30, 2010, 02:50:05 PM
i got one beginner question:
seems like all .ASM file has these form of contents:
=================
.386
.MODEL Flat
.DATA
; Your Data
.CODE
start:
  ; Your Code
END start
=================
what if a program contains many data? such as dozens of 3D models, or 10 minutes of WAV data.
these data should be stored outside the .ASM file right? or can a .ASM file size up to 100MB ?
Title: Re: can i go directly to low level programming? such as mov, cmp, jmp
Post by: clive on April 30, 2010, 03:02:51 PM
You'd typically link it in a separate object, or have it as a resource. There are tools to create objects from binary blobs of data.
Title: Re: can i go directly to low level programming? such as mov, cmp, jmp
Post by: dedndave on April 30, 2010, 05:51:10 PM
QuoteThere are tools to create objects from binary blobs of data.
i searched the forum for use of the highly technical term "blob"
i got 11 hits - one of them refered to food, though   :P
soon, we will need a wiki page for it
Title: Re: can i go directly to low level programming? such as mov, cmp, jmp
Post by: redskull on April 30, 2010, 06:01:43 PM
"Binary Large Object"

http://en.wikipedia.org/wiki/Blob_(computing)

and/or my mothers cooking.... :bg
Title: Re: can i go directly to low level programming? such as mov, cmp, jmp
Post by: dedndave on April 30, 2010, 06:07:51 PM
i'll be damned
i thought it was just lose use of old slang   :lol

if it ends with a ")", you have to surround it with url tags

http://en.wikipedia.org/wiki/Blob_(computing)

from now on, i will have to find some way to fit it into my code remarks
Title: Re: can i go directly to low level programming? such as mov, cmp, jmp
Post by: dedndave on April 30, 2010, 06:27:52 PM
i am trying to pick a new internet nickname - help me out
Blob Dole
Blob Hope
Sponge Blob Square Pants
Title: Re: can i go directly to low level programming? such as mov, cmp, jmp
Post by: clive on April 30, 2010, 06:43:53 PM
Sponge Blob Code Pants

Or perhaps we should call you Patrick, seeing as you must live under a rock or something<G>

http://en.wikipedia.org/wiki/Binary_blob

http://www.techterms.com/definition/blob
Title: Re: can i go directly to low level programming? such as mov, cmp, jmp
Post by: dedndave on April 30, 2010, 07:12:17 PM
 :bg
let's not forget hockey great - Blobby Hull