can i go directly to low level programming? such as mov, cmp, jmp

Started by supercoollee, April 29, 2010, 04:51:46 PM

Previous topic - Next topic

supercoollee

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?

jj2007

Absolutely, no problem. Yiou are not obliged to use print or invoke, just use the opcodes only if you prefer.

supercoollee

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

Neil

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.

clive

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
It could be a random act of randomness. Those happen a lot as well.

Slugsnack

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

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

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

Farabi

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.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

supercoollee

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?

dedndave

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

dedndave

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

supercoollee

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 ?

clive

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.
It could be a random act of randomness. Those happen a lot as well.

dedndave

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