i would like to do the following in win32asm:
(XTimes = 0, from the beginning)
XTimes = XTimes + 1
Thanks in advance, help is always appreciated!
Printable View
i would like to do the following in win32asm:
(XTimes = 0, from the beginning)
XTimes = XTimes + 1
Thanks in advance, help is always appreciated!
Looks to me that your wanting soemthing like this...
xtimes db 0
mov ax, 1
mov xtimes, ax
Hope this helps...
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
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.
The problem is that your trying to move a word into a byte.
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.
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
Hi.
It's simple.
to obtain
XTimes = XTimes + 1
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
Why just:
Code:INC [xtimes]
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.
However you might need to create your own (or find your own) depending on what assembler you use.
The masm32 library has a dwtoa function to convert a doubleword to a string.
But will the masm32 libraries work with UNIX / Linux?
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
Depending on what you write, that is true. Interrupts (from what I dealt with) are not independent creatures.