News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

running masm 16 bit on XP

Started by mach, October 24, 2005, 09:35:23 PM

Previous topic - Next topic

mach

Hi I'm just started to learn assembler in college, I got a hold of the masm version the college use , it for 16 bit. In seems to run ok on XP,comipe and link ok, but when I run it the crash cmd.Can any tell me why??

RedXVII

It might be a good idea to give more details, like the example you are trying to compile - and with what build commands.

Im sure no-one can go - oh thats clearly a 90334 bug in which you need to turn your pc upside down when compiling.  :lol

EDIT:

^^ on reflection i hope english is your native language - otherwise you might take the joke seriousley. That would have me pissing with laughter for hours

:U

mach

English,is my second language ,Irish is my first. Any way here is the code



.model small
.stack 100H
.data


.code
.startup
call input

input:push ax
      push bx
      push cx
     
mov dl,10
mov ah,02h
int 10

mov bx, 1
mov cx,0


back1:mov ah, 8
      int 021h
      mov dl,al
     
      cmp dl,13
      jnz nxt
     
      cmp dl,48
      jc back1
      cmp dl,57
      jnc back1
     
      mov ah,02h
      int 021h
     
      sub al,48
      mov ah,0
     
      push ax
     
      mov ax,10
      add cx,ax
      jmp back1
     
      nxt:mov dx,cx
          pop cx
          pop bx
          pop ax
         
          ret





.exit
End



I'm using ml file.asm

MichaelW

mach,

I'm not sure what you are trying to do in your code, but I see two problems. The first is that you have an unbalanced push in the input routine, and this is causing the return instruction to use the value pushed by the first push instruction as a return address, instead of the proper return address that was pushed by the call instruction. The second is that you are not properly terminating the program after the call to the input routine returns. Assuming the first problem had been fixed, this would cause the routine to execute again, and since there was no intervening call instruction to push a valid return address, the return instruction would use whatever junk value was at the top of the stack.

I think some time learning how the stack and the call and return instructions work would be well spent.
eschew obfuscation

hd

.startup
call input
.exit

input:push ax
      push bx
...
could solve your problem