News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

My first program!

Started by felipe, April 26, 2017, 12:13:44 PM

Previous topic - Next topic

nidud

#15
deleted

felipe

Quote from: LordAdef on April 27, 2017, 04:54:08 AM
both below will work. You may have missed something else

push_parameters proc       
        push    0                   ; Style of message box.

        ;mov    ebx,offset head    ;<== this
        lea      ebx, head               ;<== or this

        push    ebx

        ;mov    ebx,offset inside
        lea      ebx, inside

        push    ebx
        push    0                   ; No window, no handle?
        call    MessageBoxA         ; Windows function.
        ret
push_parameters endp

No man. The assembly here in windows 8.1 with the masm32 sdk works fine,  but windows can't run the program.  :redface:

felipe

Quote from: nidud on April 27, 2017, 04:57:34 AM
LEA should work, but it may be simpler to just push the offset in this case.


include c:\masm32\include\masm32rt.inc

.data
head    byte    'The first',0
inside  byte    'Hello!',0

.code

main    proc
        call    push_parameters
        call    ExitProcess         ; Windows function.
main endp

push_parameters proc       
        push    0                   ; Style of message box.
        push    offset head
        push    offset inside
        push    0                   ; No window, no handle?
        call    MessageBoxA         ; Windows function.
        ret
push_parameters endp

end main


Yes i know that, you can push memory into the stack directly (the offset) in one of the unique cases of memory to memory operations. But i wasn't sure if the offeset was a directive or an instruction (intel). But i wanted to do more (and i like this way more) code with the intel mnemonics and not use to much the directives (just where it's necesary of course). I did it almost for playing and testing.

LordAdef

QuoteSo the correct instruction would be: (lea ebx, offset memory_location)?  :redface:

Ok, but you confuses us when you write the line above. If you buit it without errors, and it´s not running, the problem is somewhere else.

QuoteIt's the problem because i treated the instruction (lea) like in real mode?
Forget real mode, your asm scope is within the boundaries of protected mode. The problem is somewhere else.

Well, let´s wait for the gurus to come and help, and I hope I could´ve helped  somehow

felipe

Quote from: LordAdef on April 27, 2017, 05:14:13 AM


QuoteIt's the problem because i treated the instruction (lea) like in real mode?
Forget real mode, your asm scope is within the boundaries of protected mode. The problem is somewhere else.

Well, let´s wait for the gurus to come and help, and I hope I could´ve helped  somehow

Man thanks for your help, but i think that this have something to do with the problem... :eusa_snooty:

LordAdef


felipe

But maybe it's an stupid idea because if the data moves (in hands of the O.S.) then the instruction that has access to this dynamic data (lea) should work. In the other part this variables are statics, right? (at least in the way that in the source code they appear declared) So what is it?... ::)... :lol:

jj2007

Quote from: felipe on April 27, 2017, 04:43:51 AM
It was the same code of above man, but instead of the lines: (mov ebx,offset head) and (mov ebx,offset inside) was:
(lea ebx,head) and (lea ebx,inside).

Here is the testbed. Your code works fine with IF 0 and IF 1, and there is no reason why it shouldn't..386
.model flat,stdcall
option casemap:none

include \masm32\include\masm32rt.inc

.stack  4096

.data
head    byte    'The first',0
inside  byte    'Hello!',0

.code
start:
main    proc
        call    push_parameters
        call    ExitProcess         ; Windows function.
main   endp

push_parameters proc       
        push    0                   ; Style of message box.
        if 1
      lea ebx, head
      push    ebx
      lea ebx, inside
      push    ebx
        else
      mov     ebx,offset head
      push    ebx
      mov     ebx,offset inside
      push    ebx
        endif
        push    0                   ; No window, no handle?
        call    MessageBoxA         ; Windows function.
        ret
push_parameters endp
        end     start
       

felipe

You are right! It's really rare. I have tested using the lea again and it worked. Maybe it was a momentary problem in the O.S.? Like i sayed there wasn't errors in the assembly time nor in the linking. Well, i should study more, i don't want to confuse anybody nor myself   :lol:
Thanks all for your help, i appreciate.   :t

felipe

http://masm32.com/board/index.php?topic=1425.msg14577#msg14577

These is usefull for newbies who has similar confusions... ;)... :lol:

mineiro

hello sir felipe;
imagine that you have a table in front of you, you can deal with fields contents of that table or you can point to fields of that table.
This is how we can deal with memory by processor point of view, or we can point to an memory address or we can get contents of memory address.
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

felipe

Quote from: mineiro on April 27, 2017, 06:30:35 AM
hello sir felipe;
imagine that you have a table in front of you, you can deal with fields contents of that table or you can point to fields of that table.
This is how we can deal with memory by processor point of view, or we can point to an memory address or we can get contents of memory address.

I know, i know... :lol:

felipe

Quote from: LordAdef on April 27, 2017, 05:14:13 AM
QuoteSo the correct instruction would be: (lea ebx, offset memory_location)?  :redface:

Ok, but you confuses us when you write the line above. If you buit it without errors, and it´s not running, the problem is somewhere else.


I just want to say that i took that from:
Quote from: jj2007 on April 27, 2017, 03:21:14 AM
.data
text db "Hola hombre",0   ; display text
.code

start:                          ; start execution here
  mov eax, offset text
  lea edx, offset text
...


Both instructions do the same,

:lol:

jj2007

The correct syntax is indeed
lea edx, text
and not
lea edx, offset text

I have corrected my post accordingly. However, both instructions produce exactly the same code, and therefore we still have to find the true reason for "windows can't run the program". You cannot reproduce the problem, I suppose?

RuiLoureiro

Quote from: jj2007 on April 27, 2017, 08:50:39 AM
The correct syntax is indeed
lea edx, text
and not
lea edx, offset text

I have corrected my post accordingly. However, both instructions produce exactly the same code, and therefore we still have to find the true reason for "windows can't run the program". You cannot reproduce the problem, I suppose?
Jochen, as far as i know lea edx,text is the same as mov edx, offset text. lea is used when we have local variables.
See you  :t