VOGONS


First post, by pardream

User metadata
Rank Newbie
Rank
Newbie

everyone, I'm studying to write asm program.
The test program below:
;calculate xxx*16+yyy->zzz
dseg segment
xxx dw 1234h
yyy dw 5678h
zzz dd ?
dseg ends
;
cseg segment
assume cs:cseg, ds:dseg
start:
mov ax, dseg
mov ds,ax
mov ax,xxx
mov dx,ax
mov cl,4
shl ax,cl
mov cl,12
shr dx,clb
mov ah,4ch
int 21h
cseg ends
end start

very simple program, compiler and link it with tasm/tlink OK, but when I run it,
I found the first 2 byte in data segment was replaced by 013b, I wonder why this happened.
Can anybody answer it?

Email:fogflower@gmail.com

Reply 1 of 3, by pardream

User metadata
Rank Newbie
Rank
Newbie

btw, I run the program in dosbox. the same program run ok in dos.

Reply 2 of 3, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

This is not really related to DOSBox...

The problem is most likely that you are not defining a stack location for an .EXE memory model. With no location defined, stack operation (including stuff caused by interrupts) can clobber your code and data segments in ways that are hard to predict. You should either set up the stack, or compile and link for .COM (tiny) memory model.

sseg segment stack 'stack'
db 254 dup (?)
sseg ends

That's just an example of how you might set up the stack location in your code. The linker should also stop displaying its warning about "no stack" when it's done correctly.

Reply 3 of 3, by pardream

User metadata
Rank Newbie
Rank
Newbie

thank ripsaw8080!
thanks a lot!
It's ok now.