News:

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

I want to learn Assembly

Started by DreamChaser, December 03, 2007, 01:49:33 AM

Previous topic - Next topic

DreamChaser

Hi,

I was impressed by Jeremy on his GoAsm.
I further learned the tutorial by Bill Aitken. (Can't wait for more).
I just could not believe I could activate Window using Assembly language!

I want to learn more on using Easy Code to write simple yet efficient code.
Please help me to get more simple to hard example.

DC

Tight_Coder_Ex

Of the dozens of places you can find info here is just one of them http://www.movsd.com/icz.htm

jorgon

Hi Dream Chaser

Welcome to the forum, and to the refreshing world of programming Windows using assembler!

I have tried to put links to the GoAsm sample code all together here .

There may well be other published GoAsm source code around.  If so, I would like to add it to this list.

Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)

donkey

Hi DreamChaser,

Welcome to the wonderful world of GoAsm programming ! A link to my site is available on the page that Jeremy directed you to, I have mostly beginner to low level intermediate examples there (including some COM examples and libs), Wayne J Radburn's page has a great skeleton program that will help get you up and running quickly. I would suggest RadASM as your IDE (editor etc...) with the PSDK for Windows (PDSK Download). With GoAsm, RadASM and the PSDK you have just about everything you will need to begin and continue programming in GoAsm assembly. And ofcourse there are many talented people here to answer just about any questions you might have, just don't feel intimidated, every one was a beginner once and had to ask the easy questions at some point.

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

DreamChaser

Quote from: jorgon on December 03, 2007, 03:53:00 PM
Hi Dream Chaser

Welcome to the forum, and to the refreshing world of programming Windows using assembler!

I have tried to put links to the GoAsm sample code all together here .

There may well be other published GoAsm source code around.  If so, I would like to add it to this list.



Hi,

Thank you very much !
I am happy to get you all answered ^^

To be honest, I went through mostly the beginner and intermediate.
I know you put a lot of effort on it.
I still do not have much understanding  :(

May be I was pampered with all those good picture-guided training. :P
That is why I love Bill Aitken's tutorial.
I wish we could develop that.

I still remember the old days when I started my C language.
I have to write some very simple programs.
Step by step.
I am not demanding but If I learn more, I shall produce those learning material.

At this moment, I am not able to write a simple program to display on console like:

1
1 2
1 2 3
1 2 3 4
1 2 3
1 2
1

or Xmas tree (about to come ^^)

         1
        2 2
      3 3 3
    4 4 4 4
   5 5 5 5 5

I shall to learn and ask more question ^^

DC




DreamChaser

Quote from: donkey on December 03, 2007, 06:40:55 PM
Hi DreamChaser,

Welcome to the wonderful world of GoAsm programming ! A link to my site is available on the page that Jeremy directed you to, I have mostly beginner to low level intermediate examples there (including some COM examples and libs), Wayne J Radburn's page has a great skeleton program that will help get you up and running quickly. I would suggest RadASM as your IDE (editor etc...) with the PSDK for Windows (PDSK Download). With GoAsm, RadASM and the PSDK you have just about everything you will need to begin and continue programming in GoAsm assembly. And ofcourse there are many talented people here to answer just about any questions you might have, just don't feel intimidated, every one was a beginner once and had to ask the easy questions at some point.

Donkey

Ya.. I went through some of your examples (in fact I downloaded all ^^)
It was very nice. :clap:

I shall your suggestion and I am sure I have ton of questions.

I also want to contribute in some way.
I would say idiot-proof learning method of Assembly on GoASM^^

DC

DreamChaser

Hi,

I am lost.... :(
But I don't give up!

DC

donkey

The console app you want to write is a simple one...

.data
cbWritten DD 0
szL1 DB "1",13,10,"1 2",13,10,"1 2 3",13,10,"1 2 3 4",13,10,"1 2 3",13,10,"1 2",13,10,"1",13,10,0
.code
Start:
invoke GetStdHandle,-11 ; Get the STD_OUTPUT_HANDLE
mov ebx,eax ; Store handle in EBX
invoke lstrlenA,OFFSET szL1 ; Get the number of characters to write
invoke WriteFile,ebx,OFFSET szL1,eax,OFFSET cbWritten ,0 ; Write the line(s) EAX contains the number of chars to write
invoke Sleep,2000 ; Hold the console open for to seconds to see our work
invoke ExitProcess,0 ; Shut down the process


In order to write to the console in Windows you must obtain a STD_OUTPUT_HANDLE to the console (index = -11) and use WriteFile to write to it. Other than that 13,10 is a CR/LF and the rest is just formatting.

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

DreamChaser

Hi,

Thanks for the code.. ^^.

That is the most simply way to represent on screen display.
Let me slowly learn how to put in the condition and iteration like if... then... or For.... End For..

Thx again ^^

DC

donkey

Quote from: DreamChaser on December 10, 2007, 05:36:10 AM
Hi,

Thanks for the code.. ^^.

That is the most simply way to represent on screen display.
Let me slowly learn how to put in the condition and iteration like if... then... or For.... End For..

Thx again ^^

DC

No problem DreamChaser,

GoAsm has no high level constructs like IF/THEN or FOR/ENDFOR, you will have to code them yourself using TEST/CMP and Jcc

// FOR EBX = 0 to 9 ... ENDFOR
push ebx ; preserve the value of EBX
xor ebx,ebx ; Set EBX to zero
:
cmp ebx, 9 ; Test EBX for the top number
ja > ; Break if above
// *******************
// Do your stuff here
// *******************
inc EBX ; increment our counter
jmp < ; back to the top of the loop
:
pop ebx ; Restore the value of EBX


// FOR EBX = 9 to 0 ... ENDFOR
push ebx ; preserve the value of EBX
mov ebx, 9 ; Set EBX to the top number
:
test ebx,ebx ; Test EBX for zero
jz > ; Break if zero
// *******************
// Do your stuff here
// *******************
dec EBX ; decrement our counter
jmp < ; back to the top of the loop
:
pop ebx ; Restore the value of EBX



// IF EBX = 10 THEN ...
cmp ebx, 10
jne > ; Branch if not equal to 10
// *******************
// Do your stuff here
// *******************
:


// IF EBX <> 10 THEN ...
cmp ebx, 10
je > ; Branch if equal to 10
// *******************
// Do your stuff here
// *******************
:


Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

Hi DreamChaser

Here's another example of your project, it builds the strings in program and has a constant MAX_TREE that allows for 2-99 though only the least sig digit is displayed. The AAM in BuildTheString is a bit of a cheat to convert the numeric value to ASCII. As a bonus I included a small macro to calculate string length...

Build commands :
GoAsm.EXE "DreamChaser.asm"
GoLink.EXE /console "DreamChaser.obj"


MAX_TREE = 9 ; Range = 2 - 99

#DYNAMICLINKFILE Kernel32.dll

STRLEN(%1,%2) MACRO
push edi,ecx \
mov edi,offset %1 \
#IF ARGCOUNT > 1
mov ecx, %2 \
#ELSE
mov ecx,SIZEOF %1 \
#ENDIF
mov eax,0 \
repne scasb \
#IF ARGCOUNT > 1
mov eax, %2 \
#ELSE
mov eax,SIZEOF %1 \
#ENDIF
sub eax,ecx \
pop ecx,edi \
dec eax
ENDM

.data
buffer DB 256 DUP ?
hConsole DD 0
cbWritten DD 0

.code
START:

invoke GetStdHandle,-11
mov [hConsole],eax

xor ebx,ebx
inc ebx
:
invoke BuildTheString,offset buffer, ebx
STRLEN(buffer)
invoke WriteFile,[hConsole],OFFSET buffer,eax,OFFSET cbWritten ,0

inc ebx
cmp ebx,MAX_TREE
jle <

mov ebx,MAX_TREE-1
:
invoke BuildTheString,offset buffer, ebx
STRLEN(buffer)
invoke WriteFile,[hConsole],OFFSET buffer,eax,OFFSET cbWritten ,0

dec ebx
jnz <

invoke Sleep,2000
invoke ExitProcess,0

BuildTheString FRAME pBuffer,nMax
uses ebx
mov edx,[pBuffer]

xor ebx,ebx
inc ebx
:
// Append a space
mov B[edx], 32
// advance the pointer
inc edx

// Convert to ascii
mov eax,ebx
aam
add eax, 3030h
bswap eax
shr eax,16

// append the char to the string
mov B[edx],ah
// advance the pointer
inc edx
// Next number
inc ebx
cmp ebx,[nMax]
jle <
:
// Add CR/LF and NULL terminate the string
mov B[edx],13
mov B[edx+1],10
mov B[edx+2],0
mov eax, [pBuffer]
RET
ENDF
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

DreamChaser

Hi donkey,

Thx thx and thx!   :U
This is really eye opening!

Thx for the effort to show me the way.
I learn a lot from this example!

I am sure that I will continue to learn and ask more questions ^^.
I read the GoAsm Tutorial again :P

DC