Click to See Complete Forum and Search --> : MASM: EASY math
ashtr3jd
Nov 27th, 2001, 11:25 AM
i would like to do the following in win32asm:
(XTimes = 0, from the beginning)
XTimes = XTimes + 1
Thanks in advance, help is always appreciated!
Knight_Vision
Nov 27th, 2001, 12:32 PM
Looks to me that your wanting soemthing like this...
xtimes db 0
mov ax, 1
mov xtimes, ax
Hope this helps...
ashtr3jd
Nov 28th, 2001, 04:10 AM
mov ax, 1
mov xtimes, ax
the last line gives me an error:
A2070: invalid instruction operands
.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
Knight_Vision
Nov 28th, 2001, 11:36 AM
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.
ChimpFace9000
Nov 28th, 2001, 12:58 PM
The problem is that your trying to move a word into a byte.
Knight_Vision
Nov 29th, 2001, 10:26 AM
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.
ashtr3jd
Nov 29th, 2001, 01:33 PM
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
colio
Dec 6th, 2001, 12:53 PM
Hi.
It's simple.
to obtain
XTimes = XTimes + 1
colio
Dec 6th, 2001, 12:56 PM
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
Darkwraith
Aug 14th, 2003, 05:43 PM
Why just:
INC [xtimes]
MrDeX
Nov 17th, 2003, 09:38 AM
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.
Darkwraith
Nov 17th, 2003, 02:23 PM
However you might need to create your own (or find your own) depending on what assembler you use.
silk.odyssey
Dec 1st, 2003, 09:02 AM
The masm32 library has a dwtoa function to convert a doubleword to a string.
Darkwraith
Dec 8th, 2003, 05:06 PM
But will the masm32 libraries work with UNIX / Linux?
art_sands
Dec 8th, 2003, 09:48 PM
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
Darkwraith
Dec 9th, 2003, 02:03 PM
Depending on what you write, that is true. Interrupts (from what I dealt with) are not independent creatures.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.