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!!!
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
ASSUME DS:_DATA
(use the correct name for your data segment, of course)
MessageBox is not supported under DOS
here's a 32-bit program that uses MessageBox
;###############################################################################################
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
ah... that's masm32 (32-bit) program. and the "assume ds:data" is necessary? follow ;
.data
...
.code
above, the ".data" is declare a segment?or not?
Thanks for your reply. :biggrin:
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....
ASSUME DS:DGROUP
for 16-bit code, you can get DGROUP with @data (if you use the shortcuts)
mov ax,@data
mov ds,ax
Thanks!!!