CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2009
    Posts
    13

    printing a character

    here is my code
    .model small
    .stack
    include stdlib.a
    includelib stdlib.lib

    .data

    word TYPEDEF byte
    dseg segment para public 'data'

    j word 0FF00h
    k word 0FFF0h
    l word ?
    dseg ends
    .code

    main proc
    mov ax, dseg
    mov ds, ax
    mov es, ax

    mov ax, j
    putc

    main endp
    end main




    its giving me the error : OPERAND TYPES DO NOT MATCH

    is it my TYPEDEF? whatS the problem?
    Last edited by access1011; April 15th, 2009 at 02:44 PM.

  2. #2
    Join Date
    Apr 2003
    Posts
    1,755

    Re: printing a character

    First, word and byte are both reserved words (data types) in assembly and you should not redefine them. You're lucky? you did not get an error in your typedef.

    Second, byte accepts values of up to 0FFh only. Again, you're lucky? if you did not get any error in your j and k declarations

    The "OPERAND TYPES DO NOT MATCH" is in "mov ax, j". j is a byte (1 byte) and you are trying to copy it to a WORD register (2 bytes) and so the assembler is complains about type mismatch.

    Edit: you should use "CALL" in using a function (e.g. call putc). Also, you have to be careful in passing parameter as well as the calling convention used by the function (e.g. _cdecl, _stdcall, _pascal, etc.) to avoid stack corruption.
    Last edited by rxbagain; April 15th, 2009 at 04:44 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured