Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

Digital circuits are made from analog parts. -- Don Vonada


programming / comp.lang.asm.x86 / Re: newbie question about program

SubjectAuthor
* newbie question about programG G
`* Re: newbie question about programMelzzzzz
 `- Re: newbie question about programG G

1
Subject: newbie question about program
From: G G
Newsgroups: comp.lang.asm.x86
Organization: A noiseless patient Spider
Date: Thu, 13 Jun 2019 22:10 UTC
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: gdot...@nospicedham.gmail.com (G G)
Newsgroups: comp.lang.asm.x86
Subject: newbie question about program
Date: Thu, 13 Jun 2019 15:10:08 -0700 (PDT)
Organization: A noiseless patient Spider
Lines: 62
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <47ecdd8c-a134-4aad-9210-37ad07af656d@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Thu, 13 Jun 2019 22:10:08 +0000
Injection-Info: h2725194.stratoserver.net; posting-host="e854b2336821c85bae84d96352d24df9";
logging-data="9643"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+uLjRmpxXmx9k/V6xVssahvGHMlup5e9o="
User-Agent: G2/1.0
Cancel-Lock: sha1:hlogG+KkF6FhZ5igEMQE0QWM59k=
View all headers
;  Windows 64-bit Assembly Language Programming
;  Quick Start: Intel X86-64, SSE, AVX



includelib kernel32.lib ; Windows kernel interface
GetStdHandle proto ; Function to retrieve I/O handle
WriteConsoleA proto ; Function that writes to command window
Console equ -11 ; Device code for console text output.
ExitProcess proto

.code
mainCRTStartup proc

sub RSP,40 ; Reserve "shadow space" on stack.

; Obtain "handle" for console display monitor I/O streams

mov RCX,Console ; Console standard output handle
call GetStdHandle ; Returns handle in register RAX
mov stdout,RAX ; Save handle for text display.

; Display the "Hello World" message.

mov RCX,stdout ; Handle to standard output device
lea RDX,hwm ; Pointer to message (byte array).
mov R8,lengthof hwm ; Number of characters to display
lea R9,nbwr ; Number of bytes actually written.
call WriteConsoleA ; Write text string to window.

add RSP,40 ; Replace "shadow space" on stack
mov RCX,0 ; Set exit status code to zero.
call ExitProcess ; Return control to Windows.

mainCRTStartup endp

.data
hwm byte "Hello World"
stdout qword ? ; Handle to standard output device
nbwr qword ? ; Number of bytes actually written

end


----------------------------------
questions:

sub RSP,40

RSP is a stack pointer, pointing to an address, sub subtracts 40 from the address
is that 40 bytes? so the stack pointer is pointing  40 bytes lower?

lea R9,nbwr

where does nbwr gets its value?

add RSP,40

moves the pointer, the stack pointer back to its original location?





Subject: Re: newbie question about program
From: Melzzzzz
Newsgroups: comp.lang.asm.x86
Organization: usenet-news.net
Date: Thu, 13 Jun 2019 23:29 UTC
References: 1
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Melzz...@nospicedham.zzzzz.com (Melzzzzz)
Newsgroups: comp.lang.asm.x86
Subject: Re: newbie question about program
Date: Thu, 13 Jun 2019 23:29:14 GMT
Organization: usenet-news.net
Lines: 79
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <e%AME.10589$Lu7.2835@fx13.am4>
References: <47ecdd8c-a134-4aad-9210-37ad07af656d@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: h2725194.stratoserver.net; posting-host="e854b2336821c85bae84d96352d24df9";
logging-data="10821"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19JvSs6x1Dza44MoWOkAFYlcEp7pzt6MY8="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:yY5COvbPBotYCKg+Vzomelkm6+s=
View all headers
On 2019-06-13, G G <gdotone@nospicedham.gmail.com> wrote:
;  Windows 64-bit Assembly Language Programming
;  Quick Start: Intel X86-64, SSE, AVX



includelib kernel32.lib ; Windows kernel interface
GetStdHandle proto ; Function to retrieve I/O handle
WriteConsoleA proto ; Function that writes to command window
Console equ -11 ; Device code for console text output.
ExitProcess proto

.code
mainCRTStartup proc

sub RSP,40 ; Reserve "shadow space" on stack.

; Obtain "handle" for console display monitor I/O streams

mov RCX,Console ; Console standard output handle
call GetStdHandle ; Returns handle in register RAX
mov stdout,RAX ; Save handle for text display.

; Display the "Hello World" message.

mov RCX,stdout ; Handle to standard output device
lea RDX,hwm ; Pointer to message (byte array).
mov R8,lengthof hwm ; Number of characters to display
lea R9,nbwr ; Number of bytes actually written.
call WriteConsoleA ; Write text string to window.

add RSP,40 ; Replace "shadow space" on stack
mov RCX,0 ; Set exit status code to zero.
call ExitProcess ; Return control to Windows.

mainCRTStartup endp

.data
hwm byte "Hello World"
stdout qword ? ; Handle to standard output device
nbwr qword ? ; Number of bytes actually written

end


----------------------------------
questions:

sub RSP,40

RSP is a stack pointer, pointing to an address, sub subtracts 40 from the address
is that 40 bytes? so the stack pointer is pointing  40 bytes lower?

Yes.


lea R9,nbwr

where does nbwr gets its value?

In function WriteConsoleA


add RSP,40

moves the pointer, the stack pointer back to its original location?

yes.





--
press any key to continue or any other to quit...
U ničemu ja ne uživam kao u svom statusu INVALIDA -- Zli Zec
Na divljem zapadu i nije bilo tako puno nasilja, upravo zato jer su svi
bili naoruzani. -- Mladen Gogala



Subject: Re: newbie question about program
From: G G
Newsgroups: comp.lang.asm.x86
Organization: A noiseless patient Spider
Date: Fri, 14 Jun 2019 01:50 UTC
References: 1 2
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: gdot...@nospicedham.gmail.com (G G)
Newsgroups: comp.lang.asm.x86
Subject: Re: newbie question about program
Date: Thu, 13 Jun 2019 18:50:24 -0700 (PDT)
Organization: A noiseless patient Spider
Lines: 88
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <70556206-4416-4d6e-be42-87e4913723ea@googlegroups.com>
References: <47ecdd8c-a134-4aad-9210-37ad07af656d@googlegroups.com> <e%AME.10589$Lu7.2835@fx13.am4>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Date: Fri, 14 Jun 2019 01:50:24 +0000
Injection-Info: h2725194.stratoserver.net; posting-host="c1183534aacfd4a6a36226096521d5bf";
logging-data="12972"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX189/q2htOZ6IYeI6MVM5RLrQEiNXzB2vQw="
User-Agent: G2/1.0
Cancel-Lock: sha1:sABUolERjcPJpMy4GPxKJ+0KqWk=
View all headers
On Thursday, June 13, 2019 at 7:45:03 PM UTC-4, Melzzzzz wrote:
On 2019-06-13, G G <gdotone@nospicedham.gmail.com> wrote:
;  Windows 64-bit Assembly Language Programming
;  Quick Start: Intel X86-64, SSE, AVX



includelib kernel32.lib ; Windows kernel interface
GetStdHandle proto ; Function to retrieve I/O handle
WriteConsoleA proto ; Function that writes to command window
Console equ -11 ; Device code for console text output.
ExitProcess proto

.code
mainCRTStartup proc

sub RSP,40 ; Reserve "shadow space" on stack.

; Obtain "handle" for console display monitor I/O streams

mov RCX,Console ; Console standard output handle
call GetStdHandle ; Returns handle in register RAX
mov stdout,RAX ; Save handle for text display.

; Display the "Hello World" message.

mov RCX,stdout ; Handle to standard output device
lea RDX,hwm ; Pointer to message (byte array).
mov R8,lengthof hwm ; Number of characters to display
lea R9,nbwr ; Number of bytes actually written.
call WriteConsoleA ; Write text string to window.

add RSP,40 ; Replace "shadow space" on stack
mov RCX,0 ; Set exit status code to zero.
call ExitProcess ; Return control to Windows.

mainCRTStartup endp

.data
hwm byte "Hello World"
stdout qword ? ; Handle to standard output device
nbwr qword ? ; Number of bytes actually written

end


----------------------------------
questions:

sub RSP,40

RSP is a stack pointer, pointing to an address, sub subtracts 40 from the address
is that 40 bytes? so the stack pointer is pointing  40 bytes lower?

Yes.


lea R9,nbwr

where does nbwr gets its value?

In function WriteConsoleA


add RSP,40

moves the pointer, the stack pointer back to its original location?

yes.





--
press any key to continue or any other to quit...
U ničemu ja ne uživam kao u svom statusu INVALIDA -- Zli Zec
Na divljem zapadu i nije bilo tako puno nasilja, upravo zato jer su svi
bili naoruzani. -- Mladen Gogala



thanks, don't go to far i've got 10 more chapters to go.

thanks again.



1
rocksolid light 0.7.2
clearneti2ptor