examples for Assembly Language Step By Step + MASM

Started by argol, August 23, 2007, 04:23:45 PM

Previous topic - Next topic

argol

it is possible to compile and run examples form this book
i am new to assembler


MyStack SEGMENT STACK
DB 64 DUP('STACK!!!')

MYStack ENDS



MyData SEGMENT
Eat1 BD "Eat at Joe's...$"
CRLF BD ODH,oAH,'$'
MyData ENDS



MyProg SEGMENT
   assume CS:MyProg,DS:MyData
Main PROC
Start:
mov AX,MyData
mov DS,AX 
lea DX,Eat1
mov AH,09H
int 21H

lea DX,CRLF
mov AH,09H
int 21H

mov AH,4CH
mov AL,0
int 21H

Main ENDP
MyProg ENDS




END Start


ERRORS

eat.asm(27) : error A2008: syntax error : Eat1
eat.asm(28) : error A2008: syntax error : CRLF
eat.asm(45) : error A2006: undefined symbol : Eat1
eat.asm(49) : error A2006: undefined symbol : CRLF
eat.asm(65) : error A2006: undefined symbol : Start

MichaelW

Probably, depending on the book. Beyond the obvious, and suspiciously deliberate looking, errors with BD instead of DB and the letters "O" and "o" instead of zero, the only problem I see in the code is that the start label is defined in a procedure, so it is not visible outside the procedure.
eschew obfuscation

argol

so how it make to be visible?
if i left only "END" at the end  in 16-bit linker i have warning

LINK : warning L4038: program has no starting address


MichaelW

As I stated, the problem with the start label is that it is defined in the procedure, and labels in a procedure are by default local to the procedure, so the start label is not "visible" outside the procedure. When MASM tries to assemble the end statement it looks for a start label that is visible from the end statement, and fails to find one. There are multiple methods of correcting the problem, but probably the simplest and most straightforward would be to move the label up, placing it immediately above the procedure. Other possibilities would be to eliminate the proc and endp statements, since in this code the procedure serves no useful purpose, or place two colons after the start label to make it visible outside the procedure (e.g. start::)
eschew obfuscation

zooba

Or change the last line to END Main.

Cheers,

Zooba :U