here's the code i used in MSAM32 ide
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
.data
a db 02h,02h,02h,02h,02h,02h,02h,02h,02h,02h
.code
start: mov ax,@data
mov ds,axa
mov cl,10
lea si,a
mov ax,0000h
again: add al,[si]
inc si
dec cl
jnz again
mov cl,0ah
div cl
mov ah,4ch
int 21h
end start
.end
whenever i click on assemble and link on ide i get error s
line 26:error A2155:cannot use 16-bit register with a 32-bit address
line 16:error A2004:symbol type conflict
you have to decide if you want to write a 16-bit program or a 32-bit program
they are very different
i would suggest 32-bit, because support for 16-bit programs is fading
and - what you learn in 32-bit will carry into the future
however, your instructor may not understand 32-bit code, so he wants to see 16-bit
figure out what "mode" he is in, then learn that model
your "preamble" is for a 32-bit program
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
the rest of the code you have posted is for 16-bit
that's why you are getting all the errors
this is a 16-bit small model EXE template
you can assemble it with newer versions of Masm
but, you must use an older 16-bit Link program
.MODEL Small
.STACK 4096
.DOSSEG
.386
OPTION CaseMap:None
;####################################################################################
.DATA
s$Msg db 'Hello World !',0Dh,0Ah,24h
;************************************************************************************
.DATA?
;####################################################################################
.CODE
;************************************************************************************
_main PROC FAR
mov dx,@data
mov ds,dx
mov dx,offset s$Msg
mov ah,9
int 21h
mov ax,4C00h
int 21h
_main ENDP
;####################################################################################
END _main
to build it
ml /c MyProg16.asm
link16 MyProg16.obj;
the semicolon at the end of the link16 line tells the linker to use default responses for the remaining parameters
this is a 32-bit console-mode template
i used the masm32rt.inc file, which adds all the preamble stuff
;###############################################################################################
INCLUDE \Masm32\Include\Masm32rt.inc
;###############################################################################################
.DATA
sMsg db 'Hello World !',13,10
;***********************************************************************************************
.DATA?
dwBytesWritten dd ?
;###############################################################################################
.CODE
;***********************************************************************************************
main PROC
INVOKE GetStdHandle,STD_OUTPUT_HANDLE
INVOKE WriteFile,eax,offset sMsg,sizeof sMsg,offset dwBytesWritten,0
INVOKE ExitProcess,0
main ENDP
;###############################################################################################
END main
to build it
ml /c /coff MyProgram32.asm
link /SUBSYSTEM:CONSOLE MyProgram32.obj
since i am using masm32 i will go for 32 bit but what to do about the rest code
i want to use the code but i need to change the preamble
any help will be appreciated
there are many console-mode code examples in the masm32\examples folder
also, the forum search tool is often very helpful
http://masm32.com/board/index.php?topic=1778.0 (http://masm32.com/board/index.php?topic=1778.0)
in the last post of that thread (page 3), i have an attachment