News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Newbie questions/observations

Started by Fugazi, February 11, 2005, 03:46:41 PM

Previous topic - Next topic

Fugazi

Hi ive just started out in asm in a rather hap hazard manner, testing things as i go along, as i think they should be and reajusting as needed , i think ive grasped the operand concept somewhat fromreading hutchs primer, and thought i would stupidly test  a one liner from it

; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««« *

    .486
    .model flat, stdcall
    option casemap :none   ; case sensitive

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    include \masm32\include\windows.inc
    include \masm32\include\masm32.inc
    include \masm32\include\kernel32.inc
    include \masm32\macros\macros.asm

    includelib \masm32\lib\masm32.lib
    includelib \masm32\lib\kernel32.lib

    .code

start:

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

  mov eax, 1
 


; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start


Now i understand that Mov is a Mnemonic, and eax & 1 are two operands ( i pasted the includes ect from another file as i presummed masm would want something their, assembled it down with out a problem , ran the program and bang

TEST caused an invalid page fault in
module TEST.EXE at 0167:00401005.
Registers:
EAX=00000001 CS=0167 EIP=00401005 EFLGS=00010a86
EBX=00530000 SS=016f ESP=0063fe3c EBP=0063ff78
ECX=8165d898 DS=016f ESI=8165d878 FS=4297
EDX=8165d8d8 ES=016f EDI=00000000 GS=0000
Bytes at CS:EIP:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Stack dump:
bff8b560 00000000 8165d878 00530000 74736554 45584500 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000


This didnt come as a shock i guess, i was sort of praying it would allow me to move 1 into eax then just exit but seemingly not, i know this is a realy dumb thing to ask. but would i need to clear eax before exiting the application? as i also tried adding a pop eax,1 after the mov presuming in my ignorance that it would clear eax and exit, but alas the same error when running. Any help would be good , im still trying to pick up the genral syntax rules. Alough it was nice to have something assemble without an error, even though it wont run  :cheekygreen:

Respectfully, Fugazi

hutch--

Fugazi,

You need to do just a little more to make the program run and exit cleanly, you can use the macro "exit" which is a wrapper for the API call,


invoke ExitProcess,eax


After the mov eax, 1

Have a potter through the tutorial in masm32 and you will see the basic architecture. As you try out new stuff, don't be afraid to ask questions as it will help to get you going.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Fugazi


pbrennick

Fugazi,
Be sure to check out the excellent macros that have been made available by Hutch.  It can make program development a breeze and a lot more fun.  I also like EasyCode created by Ramon Sala as an excellent IDE that makes programming a lot easier in the beginning.  Radasm is another good choice.  Try them all, keep the one you like, delete the rest.  We can support your efforts no matter what you choose.

Paul

Mark Jones

Quote from: Fugazi on February 11, 2005, 03:46:41 PM
TEST caused an invalid page fault in
module TEST.EXE at 0167:00401005.
Registers:
EAX=00000001 ...

Fugazi, you did move 1 into EAX. :-)

About 10 years ago I seem to recall an x86 tutor application which "showed" visually what each mnemonic did as it was processed. Anyone else ever see such an app?
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Fugazi

Thanks for the heads up on EasyCode Pbrennick, it looks good i'll be looking into using it along the way , i think my biggest hurdle will be remembering the layout of the app, and the opcodes. Cheers guys & Mark would such an app be of any use to me? i was pondering something similair that would visual show me what was in EAX , ESI ect ect i believe there is a tolol called emu8080 but its for purely DOS assembly,


Respectfully, Fugazi

OceanJeff32

Hey, Fugazi, what are some of your programming goals?  Ever use any other languages?

Just Curious,  I'm also a beginner to ASSEMBLY LANGUAGE and it's difficult to start and learn from the beginning, because the CPU architecture has changed so much from the beginning of it all.

Let me know please,

Thanks,

Jeff C
:clap:
Any good programmer knows, every large and/or small job, is equally large, to the programmer!

GregL

Quote... an x86 tutor application which "showed" visually what each mnemonic did as it was processed.
That would describe a debugger, like Visual Studio, WinDbg or OllyDbg. You can step through the program and watch the registers and variables as they change.


OceanJeff32

The Revolutionary Guide to Assembly Language has a tutorial like that, I bought the book a while back, but it did not come with the disk...so I never ran the tutorial.

Later,

Jeff C
:toothy
Any good programmer knows, every large and/or small job, is equally large, to the programmer!

Kestrel

    .code

start:

  mov eax, 1
  ret       ; <-- add this
 
end start

Randall Hyde

Quote from: Fugazi on February 11, 2005, 03:46:41 PM
Hi ive just started out in asm in a rather hap hazard manner, testing things as i go along, as i think they should be and reajusting as needed , i think ive grasped the operand concept somewhat fromreading hutchs primer, and thought i would stupidly test  a one liner from it


You might want to check out "The Art of Assembly Language" at http://webster.cs.ucr.edu.
Cheers,
Randy Hyde

Mark Jones

Quote from: Greg on February 14, 2005, 02:48:32 AM
Quote... an x86 tutor application which "showed" visually what each mnemonic did as it was processed.
That would describe a debugger, like Visual Studio, WinDbg or OllyDbg. You can step through the program and watch the registers and variables as they change.

Hi Greg. Yes it's helpful to parse existing code with a debugger, but I think it would be hard for a noobie to learn that way because they're watching "magic" happen. (Remember when it was all magic?) :bg A complex debugger like Ollydbg also might confuse a noob more than anything.

I seem to recall the app in question was very simple, probably for DOS or Win3.11. I want to say you could type in MOV EAX, [myVar] (or click an equivalent button of that) and it would show you the contents of that memory address moving into the EAX register. But this was a long time ago - or maybe it was some hellish nightmare, come back to haunt all of us years later? :eek (If so, sorry.)

In any case, making a little demo app such as that might be very helpful to a newcomer. It could also spark interest with others who would not have otherwise considered assembler. Call it the "5-minute visual assembler demo" or something.  Perhaps it could even have "levels" and be turned into a game: "Get the value from MyVar3 into DX using these buttons...":thumbu
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

doomsday

Quote from: Kestrel.code

start:

  mov eax, 1
  ret       ; <-- add this

end start

Does RETurning from the main function work in Windows apps?

regards,
-Brent