Re: C# programmer wants to learn assembly?? plz help



Herbert Kleebauer wrote:

....
Using Frank's example:
(which I think isn't correct, because -11 is not the handle
for stdout).

I'm quite sure you're right, but -11 "works for me", and I wanted to post something I'd tested (in the bad old days, when I was a microserf). "Corrected" - but untested! - code would look like...

==============================================================

; nasm -f obj hwcons.asm
; alink -oPE -subsys console hwcons.obj

extern WriteFile
import WriteFile kernel32.dll

extern ExitProcess
import ExitProcess kernel32.dll

extern GetStdHandle
import GetStdHandle kernel32.dll ;(I assume kernel32.dll ???)

section _TEXT use32 class=CODE
..start


push -11
call [GetStdHandle]
; returns the "real" stdout handle in eax

push dword 0
push dword num_chars
push dword MSGLEN
push dword msg
push dword -11

push eax ; instead of -11

call [WriteFile]

push dword 0
call [ExitProcess]

section _DATA use32 class=DATA
num_chars dd 0
msg db 'Hello, Console.', 13, 10
MSGLEN equ $ - msg

==============================================================

then this is the flight with the auto pilot. You have to
do work, but because the auto pilot (assembler/linker) hides
most, you will learn nearly nothing.

Your refusal to use a linker puts you uncomfortably close to the RasAsm camp. At least, *I* wouldn't be comfortable there!

Gideon, if you want to try Herbert's code:

ftp://137.193.64.130/pub/assembler/windela.zip

Filename has to end in ".mac"...

Best,
Frank
.



Relevant Pages