Author Topic: HELP: I am a newbie - About call  (Read 1538 times)

n0noper

  • Regular Member
  • *
  • Posts: 5
HELP: I am a newbie - About call
« on: October 20, 2015, 01:04:38 AM »
Hello, everyone.
I am a newbie, and my English is ... sorry, you got it!

code ↓
push 0
push offset szCap
push offset szText
push 0
call dword ptr [offset MessageBox]

disassembly:
...
push 0
push cs     ;Here, WHY???
call <Jmp.MessageBoxA>

;--------------------------
Why the "push cs"???
Thanks!!!

dedndave

  • Member
  • *****
  • Posts: 8751
  • Still using Abacus 2.0
    • DednDave
Re: HELP: I am a newbie - About call
« Reply #1 on: October 20, 2015, 02:39:26 AM »
that's in there because you didn't use the ASSUME directive
it thinks the only segment with the string in it is the code segment
if you tell it to assume, it won't insert that push
Code: [Select]
        ASSUME  DS:_DATA(use the correct name for your data segment, of course)

dedndave

  • Member
  • *****
  • Posts: 8751
  • Still using Abacus 2.0
    • DednDave
Re: HELP: I am a newbie - About call
« Reply #2 on: October 20, 2015, 02:43:38 AM »
MessageBox is not supported under DOS

here's a 32-bit program that uses MessageBox
Code: [Select]
;###############################################################################################

        INCLUDE    \Masm32\Include\Masm32rt.inc

;###############################################################################################

        .DATA

szCaption db 'Hello',0
szMessage db 'World',0

;***********************************************************************************************

     ;   .DATA?

;###############################################################################################

        .CODE

;***********************************************************************************************

main    PROC

        INVOKE  MessageBox,NULL,offset szMessage,offset szCaption,MB_OK
        INVOKE  ExitProcess,0

main    ENDP

;###############################################################################################

        END     main

assemble it as a windows app if you don't want to see a console window

n0noper

  • Regular Member
  • *
  • Posts: 5
Re: HELP: I am a newbie - About call
« Reply #3 on: October 21, 2015, 01:00:54 AM »
ah... that's masm32 (32-bit) program. and the "assume ds:data" is necessary? follow ;
Code: [Select]
.data
...
.code
above, the ".data"  is declare a segment?or not?

Thanks for your reply. :biggrin:

dedndave

  • Member
  • *****
  • Posts: 8751
  • Still using Abacus 2.0
    • DednDave
Re: HELP: I am a newbie - About call
« Reply #4 on: October 21, 2015, 01:20:42 AM »
if you use the .DATA (etc) shortcuts, you don't have to use ASSUME - it's taken care of

but, if you use SEGMENT and ENDS to open and close segments, you may have to
along with that is the GROUP directive, that tells the assembler how to combine segments
normally, the data segments are all combined as DGROUP, and....
Code: [Select]
        ASSUME  DS:DGROUP
for 16-bit code, you can get DGROUP with @data (if you use the shortcuts)
Code: [Select]
        mov     ax,@data
        mov     ds,ax

n0noper

  • Regular Member
  • *
  • Posts: 5
Re: HELP: I am a newbie - About call
« Reply #5 on: October 23, 2015, 02:43:47 AM »
Thanks!!!