why this code doesn't execute correctly ,any programtically error
and if i change the skeleton of segment declaration,define at end of code then same code works fine("code 2"0 and execute properly why?
plz see skeleton at end of this code

"code 1" complie without error but don't run properly
why any bug plz suggest

'/// CODE 1 START HERE ////////////////

.model small
.stack 64

  main proc far
      call getmode
      push ax  ;save cur mode
    mov al,04h  ;320x200x4 grp mode 40x25
  call setmode     
      mov ah,0bh ;request select palete or bkcolor or bordercolor
      mov bh,01h ;request select palete
      mov bl,01h ;pallete 0
      int 10h  ;call bios int srv
      mov ah,0bh ;request select pallete or bkcolor or bordercolor
      mov bh,00h ;request set bkcolor
      mov bl,00h ;color
      int 10h
  mov al,01h  ;color
  mov cx,04h  ;col
  mov dx,07h  ;row   
  call writepixel

  call getch
  pop ax    ;restore save mode
  call setmode
  mov al,00h  ;exit w'out err
  call exit
  main endp
  ;  al=exit code
  ;    00=no err
  ;    non-zero=err
  ; nothing
  exit proc near
  mov ah,4ch
  int 21h
  exit endp
  ; noting
  ;  al=cur mode
  ;  ah= no of scr col
  ;  bh=#page no
  getmode proc near
  mov ah,0fh  ;request cur mode
  int 10h
  getmode endp
  ;  al=mode
  ;  nothing
  setmode proc near
    mov ah,00h
    int 10h 
  setmode endp
  ;input: nothing
  ;  ah=scan code
  ;  al=ascii code
  getch proc near
    mov ah,00h
    int 16h
  getch endp
  ;  bl=color
  ;  cx=col
  ;  dx=row
  ;  nothing
  writepixel proc near
    mov ah,0Ch ;request for write pixel
    mov bh,00h ;page no
    int 10h  ;call bios int service
  writepixel endp

  end main

'/// CODE 1 END HERE ////////////////       

'/// CODE 2 START HERE ////////////////
if i changes the segment declaration and write the same above
code it  works fine ,what will be wrong in the "code 1" 

stack_seg segment para stack 'stack'
dw 64 dup(?)
stack_seg ends

code_seg segment para 'code'
  main proc far

    assume ss:stack_seg,cs:code_seg,ds:nothing,es:nothing
  ;coding here
  ; ......
  main endp
  ;procedures decl here
code_seg ends

  end main
'/// CODE 2 END HERE ////////////////
Posted on 2006-06-07 10:32:44 by sihotaamarpal
Once again... MASM/TASM are a one pass assemblers - you must have a declaration/definition of a procedure before you use it. (i.e. define your procedures before you use them or use a PROTO at the top)

Posted on 2006-06-07 12:12:40 by Ossa
hi again ossa
as i say if i use second segment declartion than again tasm use 1 pass
and in first declaration too then why problem arise in 1st code and in 2nd
code goes correctly

plz need that explaintion before going to proto
Posted on 2006-06-07 12:37:32 by sihotaamarpal
Hmm... I think I read your code wrong the first time around - i'll have a look into it when I get back, but I've got to go out right now, so I won't get back to you for a while - hopefully someone else will clear it up before then, but if not I'll grab a copy of TASM (not got a copy right atm) and check whats going on.

Posted on 2006-06-07 12:59:23 by Ossa
test the exe's of both codes u got the clue what i want to ask.grab the tasm and try.i hope u 2 face sam that prob i before
Posted on 2006-06-07 13:09:54 by sihotaamarpal
Once again... MASM/TASM

TASM supports multiple passes. This applies both to tasm and tasm32.
Posted on 2006-06-07 15:10:46 by ti_mo_n
hi ti_mo_n
  how ur answer is relate to my question i don't follow plz explain
mine question is what is bug in 1st code that it does'nt give result properly and and same code changing declaration in 2nd code execute
properly.i think both code assembles in one pass
Posted on 2006-06-07 21:50:54 by sihotaamarpal
I'm guessing your ASSUME directive is incorrect.

IIRC, .code is not a segment named 'code_seg', and .stack is not a segment called 'stack_seg'.

Take out the ASSUME. Or else, use the actual segment names generated by TASM.
Posted on 2006-06-08 01:20:32 by tenkey
i have take out the assume directive and runs same problem,now modify the code as define
Posted on 2006-06-08 10:18:56 by sihotaamarpal
i try the code in tasm ideal mode,it works fine
it is tasm bug to wrok in ideal mode and not work in non-ideal mode
Posted on 2006-06-08 11:47:48 by sihotaamarpal