Some basic questions on first asm program

Started by sysop1911, August 01, 2010, 07:11:36 PM

Previous topic - Next topic

sysop1911

Here is my program:

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

_TEXT segment word public 'CODE' ;assigns label "code" to _TEXT segment
assume cs:_TEXT,ds:_DATA,ss:_STACK ;'assume' tells assembler what segments these registers are pointing to

addem proc far
mov ax,_DATA ;moves segment address of _DATA to the ax register
mov ds,ax
mov ax,a
add ax,b ;adds b to a, which is already stored in register ax
linmov c,ax ;saves result of a+b into c
mov ax,4c00h ;returns program back to DOS
int 21h
addem endp
_TEXT ends

_DATA segment word public 'DATA'
a dw 3 ;tells assember to make room for 16-bit word with value of 3 and variable name 'a'
b dw 4
c dw ? ;no initial set value
_DATA ends

_STACK segment para stack 'STACK' ;STACK is generally used to hold transient data for both the CPU and the program
db 128 dup (?) ;directs assembler to leave room for 128 bytes of unknown valuml
_STACK ends
end addem

-------------------------------------------------------------------------------------------------------------------------------------------------------------

Here are the errors I get when I assemble this program:

C:\masm32\projects\first.asm(5) : error A2008: syntax error : c
C:\masm32\projects\first.asm(16) : error A2008: syntax error : c
C:\masm32\projects\first.asm(12) : error A2004: symbol type conflict
C:\masm32\projects\first.asm(26) : warning A4023: with /coff switch, leading underscore required for start address : addem
Volume in drive C has no label.


What is wrong with 'c'?  I'm using MASM32.  Thanks.

Added code tags.

ecube

that's 16bit ASM, honestly there's really no reason to code in 16bit now adays, I highly doubt you can do much anyway, and masm32 doesn't work with 16bit asm, theres a older version that does though.  you should play with 32bit/64bit it's much more enjoyable because you have access to the winapi, and other stuff. Download the latest masm32(masm10 i think) and play with the examples in the examples folder.

MichaelW

For ML, 'c' is a reserved word used to specify the C calling convention for procedure definitions, prototypes, etc. The version of ML included with the MASM32 project can assemble your source, and it can be linked with the included 16-bit linker. Example batch file:

\masm32\bin\ml /c test.asm
pause
\masm32\bin\link16 test.obj;
pause
test
pause

eschew obfuscation

sysop1911

Ok, thanks.  I didn't realize I was programing in 16-bit asm, although it should not surprise me since the book I'm using is from the early 90s.  Can someone point to a 32-bit asm guide online somewhere?  Thanks.

Sysop1911

dedndave

in the upper right corner of this page.....

Forum Links and Website

look on that page for Iczelion's tutorials
also - in the masm32 package - the help, examples, and tutorial folders have a lot of good stuff