Thread: really weird behavior, 16 bit asm w/masm

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Join Date
    May 2005
    Posts
    1,042

    really weird behavior, 16 bit asm w/masm

    I haven't done much assembly with my new computer. A while ago, I had to repair some files in my system directory because it wasn't letting me even execute commands in a console window.

    Again, I'm having more weird behavior. I'm trying to execute a simple program that uses MS DOS interrupts to obtain the date using 2AH.

    Function 2ah is as follows:
    Returns the system date
    Parameters: NONE
    Returns:
    AL Day of week
    CX Year
    DH Month
    DL Day
    I Execute the following instructions (i.e just trying to properly call the DOS function, and see that the AH register contains reasonable results)

    Code:
    dosseg
    .model small
    .stack 100h
    .data
    
    	DAYLEN EQU 10
    	dow db 'Sunday,   '
    	    db 'Monday,   '
    	    db 'Tuesday,  '
    	    db 'Wednesday,'
    	    db 'Thursday, '
    	    db 'Friday,   '
    	    db 'Saturday, '
    	
    	dowlen db 7,7,8,10,9,7,9
    	
    	datestr db 30 dup('$') 
    .code
    main PROC ;everything near for now 
    	mov ax, @data ;don't to do need this in a86 typically
    	mov ds, ax	
    	
    	mov ah, 2ah
    	int 21h
    
    	mov ax, 4c00h;	Dos terminate program
    	int 21h
    main ENDP
    
    END main
    When I trace the program using debug, it gives me odd results:
    -t

    AX=0B9C BX=0000 CX=0089 DX=0000 SP=0100 BP=0000 SI=0000 DI=0000
    DS=0B8B ES=0B8B SS=0BA4 CS=0B9B IP=0013 NV UP EI PL NZ NA PO NC
    0B9B:0013 8ED8 MOV DS,AX
    -t

    AX=0B9C BX=0000 CX=0089 DX=0000 SP=0100 BP=0000 SI=0000 DI=0000
    DS=0B9C ES=0B8B SS=0BA4 CS=0B9B IP=0015 NV UP EI PL NZ NA PO NC
    0B9B:0015 B42A MOV AH,2A
    -t

    AX=2A9C BX=0000 CX=0089 DX=0000 SP=0100 BP=0000 SI=0000 DI=0000
    DS=0B9C ES=0B8B SS=0BA4 CS=0B9B IP=0017 NV UP EI PL NZ NA PO NC
    0B9B:0017 CD21 INT 21 2ah called here, AH should have value 3, i.e AX = 03xx, the next insruction listed should be mov ax, 4c00h
    -t

    AX=2A9C wtf BX=0000 CX=0089 DX=0000 SP=00FA BP=0000 SI=0000 DI=0000
    DS=0B9C ES=0B8B SS=0BA4 CS=00A7 IP=107C NV UP DI PL NZ NA PO NC
    00A7:107C 90 NOP wtf
    -
    Namely, the AH register never changes (AX high, the top two bytes, should be between 0 and 6), and right after it calls the first interrupt it goes directly to a bunch of NO operations, then never actually executes the last interrupt which should successfully ends the program.

    I hadn't touched anything assembly other than inline in visual studio on my new computer, but I'm quite certain i've gotten other simple programs I've written to work. I'm really just confused, but I'm hoping its just some type of noob error.

    I wasn't sure where to put this question.
    Last edited by BobMcGee123; 11-30-2005 at 01:07 PM.
    I'm not immature, I'm refined in the opposite direction.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Copy bit to bit
    By Coder2Die4 in forum C Programming
    Replies: 15
    Last Post: 06-26-2003, 09:58 AM
  2. binary numbers
    By watshamacalit in forum C Programming
    Replies: 4
    Last Post: 01-14-2003, 11:06 PM
  3. 16 bit or 32 bit
    By Juganoo in forum C Programming
    Replies: 9
    Last Post: 12-19-2002, 07:24 AM
  4. Inline asm - I love it!
    By wavering in forum C Programming
    Replies: 2
    Last Post: 01-08-2002, 02:19 PM
  5. Array of boolean
    By DMaxJ in forum C++ Programming
    Replies: 11
    Last Post: 10-25-2001, 11:45 PM