Results 1 to 16 of 16

Thread: MASM: EASY math

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2001
    Posts
    9

    MASM: EASY math

    i would like to do the following in win32asm:

    (XTimes = 0, from the beginning)
    XTimes = XTimes + 1

    Thanks in advance, help is always appreciated!
    Last edited by ashtr3jd; Nov 28th, 2001 at 05:11 AM.

  2. #2
    Knight_Vision
    Guest
    Looks to me that your wanting soemthing like this...

    xtimes db 0

    mov ax, 1

    mov xtimes, ax

    Hope this helps...

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2001
    Posts
    9

    error :(

    mov ax, 1

    mov xtimes, ax

    the last line gives me an error:
    A2070: invalid instruction operands

    Code:
    .386
    .model flat, stdcall  ; 32 bit memory model
    option casemap :none  ; case sensitive
    
    include \MASM32\INCLUDE\windows.inc
    include \MASM32\INCLUDE\kernel32.inc
    include \MASM32\INCLUDE\shell32.inc
    include \MASM32\INCLUDE\masm32.inc
    include \masm32\include\user32.inc
    
    includelib \masm32\lib\user32.lib
    includelib \MASM32\LIB\kernel32.lib
    includelib \MASM32\LIB\shell32.lib
    includelib \MASM32\LIB\masm32.lib
    
    .data 
    MsgCaption      db "test",0
    xtimes db 0
    
    .code 
    
    start:
    
    mov ax, 1 
    
    mov xtimes, ax
    
    invoke MessageBox, NULL, ADDR xtimes, ADDR MsgCaption, MB_OK
    
    end start

  4. #4
    Knight_Vision
    Guest
    Ahh bloody hell. I forgot you were using MASM. Yea, there is something you are supposed to do to the Variable first. I forgot what it is. I'll have to look it up.

    In NASM all you had to do is what I shown you. Well accept add the brackets around the variable.

    mov [xtimes],ax

    I figured you knew this. For masm you may have to write it out something like this...

    mov [xtimes offset],ax

    I know it's probably wrong, but i'm trying this out of memory.. Like I said I would have to look it up.

  5. #5
    ChimpFace9000
    Guest
    The problem is that your trying to move a word into a byte.

  6. #6
    Knight_Vision
    Guest
    Dohh! I didn't catch that.. LOL Yea, chimpface is correct... It's desginated as a byte instead of a word, but AX is a 16 bit string or two bytes (Word).

    So it wouldn't work. Just change it from db to dw.

  7. #7

    Thread Starter
    New Member
    Join Date
    Nov 2001
    Posts
    9

    :(

    xtimes dw 0
    mov [xtimes],ax
    mov [xtimes offset],ax

    won't compile, gives an error

    xtimes dw 0
    mov ax,1
    mov xtimes,ax

    gives me weird character

    /me bows to Knight_Vision & ChimpFace9000 and begs

  8. #8
    New Member
    Join Date
    Dec 2001
    Posts
    2
    Hi.

    It's simple.

    to obtain
    XTimes = XTimes + 1

  9. #9
    New Member
    Join Date
    Dec 2001
    Posts
    2
    Hi.

    It's simple.

    to obtain
    vb version -> XTimes = XTimes + 1
    asm version -> inc byte ptr [xTimes]


    This code asume xTime db 0


    Regards

    colio

  10. #10
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    Why just:
    Code:
    INC [xtimes]
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

  11. #11
    New Member
    Join Date
    Sep 2003
    Location
    Berkhamsted, England
    Posts
    4
    You have problem also with how you output the variable. You can't just output the contents of the register, you need to convert the number to a null terminated ASCII string first. I can't remember what the function is to do that but there's something in the MASM32 libraries which make it easy.

  12. #12
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    However you might need to create your own (or find your own) depending on what assembler you use.
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

  13. #13
    New Member
    Join Date
    Dec 2003
    Posts
    12
    The masm32 library has a dwtoa function to convert a doubleword to a string.
    silk.odyssey

  14. #14
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    But will the masm32 libraries work with UNIX / Linux?
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

  15. #15
    Junior Member
    Join Date
    Nov 2003
    Posts
    24
    You've got the source and you've got FASM. I don't think anything should stop you from converting code to FASM and then using it in Linux. Assembly language is not machine-independent (though I've found certain cornered places where people have claimed to have achieved that), but it sure is platform-independent.

    Regards,
    Art

  16. #16
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    Depending on what you write, that is true. Interrupts (from what I dealt with) are not independent creatures.
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

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