People thinking before posting questions in software forums. Using CODE Tags.
What a dream!
Yeah, that is a nice dream, unobtainable, but a nice dream :idea:
People thinking before posting questions in software forums. Using CODE Tags.
What a dream!
Yeah, that is a nice dream, unobtainable, but a nice dream :idea:
try .model small
Have you tried?:
fmul st(2), st(0)
fdiv st(1), st(0)
There are no such registers st0, st1, or st2....
Try adding a 0 in front of your hex number. it cannot start with a letter
0FFFFFF88H
Yes, in MASM you can use the sizeof operator:
mov eax, SIZEOF arr
OR after you define arr, you can get the size using the $ char (I forgot what it is called)
.data
arr db 1,2,3
ARR_SIZE equ $ - arr
.code
mov eax, ARR_SIZE
Wich is more versatile than the sizeof operator. You cannot use the sizeof operator on an array of DWORDS because it will return 4 no matter how many elements you have... so you would use the $ after the array like so:
.data
sz1 BYTE "Hello", 0
sz2 BYTE "There", 0
sz3 BYTE "My Friend!", 0
SomeArray DWORD offset sz1
DWORD offset sz2
DWORD offset sz3
SOMEARRAY_SIZE equ ($ - SomeArray) / SIZEOF DWORD ; or use 4
Now, no matter how big your dword array is, it will give you the number of items..
Comes in handy when you are looping to load a combobox with strings or something :-)
? How did you get it working? What did you add/change to make it work? Please tell, so others have the same problem, they have a solution :)
so, you want help reversing something? Ha. That is a bunch of high level crap, it is easier to figure out C than C++ with all its constructors and classes...
Start small, if you are a windows guy, create say a simple calculator with the Windows API... Now try converting that to use the *NIX GUI stuff... XServer, GTK, widgets etc... of course you have to use a cross platform assembler to make life eaiser.. NASM and FASM are cross platform. Even DOS interrupts are different than *NIX system calls I think.
Or if your a *NIX guy do that the other way around...
To answer your question... technically yes you can run a windows app on *NIX and the other way around...
directly? No... you can't assemble a program for windows and copy it to *nix and have it work... both OS's have different formats for executables, different API's diff kernel functions etc...
Nirmeen, if we do your homework for you, what do you learn? Nothing at all!
You posted the formula:
Tc =(5/9)*(Tf-32)
Tc : Celsius
Tf : fahrenheit
So.... not the above formula but works..
Begin by subtracting 32 from the Fahrenheit number.
Divide the answer by 9.
Then multiply that answer by 5.
Now what Asm mnemonics are there to do that? (assuming x86) we have add, sub, mul, div right? So... how would you code that? Think about it...
If you wrote a program in Assembly, then when you pass your code through the assembler you get a "one to one" translation (what you wrote in Assembly is what will be in the exe file), now if on the other hand, you thought you wrote in Assembly and passed your code through a compiler, then yes you will have more code in the debugger/disassembler.
Also, if you link to static libs in your program than yes, you will seem to have more code then you explicitly wrote since that code is added during the assembly process. The assembler you used could also add padding to your sections, procs, etc for alignment purposes, replace some mnemonics for optimization, you might be seeing relocations not sure without seeing your disassembly... but in general, what you write in assembly is what you will see in the debugger... (Not sure about 16 bit asm)
That is easy, basic stuff... If I were taking a class, I would pay attention though... We don't write your code for you, what we WILL do is help you if you get stuck.. Write some code and we will help ya out.
byte == 8 bits
word == 2 bytes (16 bit)
dword == 4 bytes (2 words) (32 bit)
qword == 8 bytes (2 dwords or 4 words (64 bit))
in 32bit assembly the size of a pointer is a dword not a word, pointers are 32 bit. the sizes stay the same in a 32 bit system, 64 bit system, 128 bit system etc... in a 64 bit system, they have other sizes like dqword...
Your first post, new to assembly? If so, why don't you use invoke instead of push/call? It will save you many headaches... You don't gain anything using push/calls.
You do not need lines 12, 13, and 14 they are already defined in kernel32.inc
that being said, all you have to do is push STD_OUTPUT_HANDLE not mov to eax then push
push STD_OUTPUT_HANDLE
call GetStdHandle
that is the same as:
invoke GetStdHandle, STD_OUTPUT_HANDLE
MASM32 has many functions and macros that help coding... I don't write console apps, but I whipped this up... should get you started
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
include \masm32\include\masm32rt.inc
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
.data
prompt BYTE "Please Enter Your name: ", 0
prompt1 BYTE "Encrypted Name is: ",0
szNewLine BYTE 13, 10, 0
.data?
inp BYTE 100 DUP(?)
.code
start:
call main
exit
main proc uses esi
cls
print offset prompt
invoke memfill, offset inp, sizeof inp, NULL
invoke StdIn, offset inp, sizeof inp
invoke StripLF, offset inp
invoke szLen, offset inp
mov ecx, eax
xor esi, esi
L1:
xor inp[esi], 11101101b
inc esi
loop L1
invoke StdOut, offset prompt1
invoke StdOut, offset inp
print offset szNewLine
inkey
ret
main endp
end start
Don't know much about MIPS, but instead of using byte for variable size, could you use halfword?
A: .halfword '8C','9A','9B' .... etc
The MUST have books are from Intel and AMD, many years ago they actually shipped their manuals for free, now they are in PDF format.
http://search.intel.com/Default.aspx?q=software%20developers%20manual
http://search.amd.com/US/_layouts/search/Search.aspx?csquery=programmers%20manual&collection=all-us
I got the books by Intel and AMD when they were printed, and a few years ago I got them on CD they mailed for free, you will have to look around their sites to find out if they still do that.
No it really doesn't matter if you are using AMD or INTEL the main differance between the 2 is AMD uses 3DNOW and Intel uses MMX and a few other things a newbie doesn't need to worry about :)
1.
ProcName proc
; code here
ret
ProcName endp
2. Don't know 16bit asm, but this should work, dwMyVar is a DWORD in the uninitialized data section
mov dwMyVar, eax ; or mov dwMyVar, 1 etc
3. unsure in 16 bit
everything is a number to a processor (well actually true or false, open or closed) an opcode is an instruction that the processor understands. But we really don't use opcodes, we use mnumonics (groups of letters that a human can easily remember). It is much easier to remember CALL then the opcodes for call: 0FAB, OFBA, E8, FF.
It is unfortunate that INTEL and AMD don't print the manuals anymore, I got them free about 10 years ago... You can get the PDFs though... The AMD explains what an opcode is better then INTEL.
"An opcode specifies the operation that the instruction performs."
actually jb is the opposite of ja. ja and jg are basically the same, they will both jump if it second operand is > the first opcode... in your example it will jmp to start if eax is above or greater than ebx... ja and jg check differant flags, but do the same thing.
@josephbeluan
How would you write a "while Loop"? you need a counter, and an exit value... you can test the counter at the beginning of the loop or at the end of the loop.... inside the loop, increment your counter and then test where you want to... and jump if the counter is greater than the exit value...
Probably line 31? You are trying to move a DWORD into a BYTE... in MASM it would be:
mov al, BYTE PTR [ebx]
in this way the assembler knows we only want to move a byte from ebx to al.
Wait, HLA is backwards right? you are moving from al to ebx right? either way, BYTE PTR should be correct.
I am just starting asm in my cs class. What architecture is this?
It is INTEL/AMD x86
Well, your logic is a bit off... print is a MASM macro that prints text to the console, just change print to what you use... putch and putint
mov esi, 10 ; only want 10 numbers printed
xor ebx, ebx
FirstRow:
inc ebx
print str$(ebx), 32 ; print num + space
dec esi
test esi, esi ; is our counter at zero?
jnz FirstRow ; nope, print next number
print " ", 13, 10, 13, 10 ; done with first line
TheRest:
xor edi, edi
inc edi
NextRow:
mov esi, 11 ; we only want 11 columns and rows
mov ebx, edi
NextCol:
print str$(ebx), 32
dec esi
inc ebx
test esi, esi ; are we at end of column?
jnz NextCol ; nope, print next column
print " ", 13, 10
inc edi
mov ebx, edi
cmp edi, 11 ; are we at our last row?
jl NextRow ; nope, print next row
print " ", 13, 10 ; we made it here, we are done!
ret
The only place I see a floating point error (division by zero) is at your idiv... if eax or esi == 0 then you will get this... a cmp wouldn
t throw that error... if you want to put the accumulator back on the stack shouldn't
mov [esp+56],eax
be after popa? I could be wrong I am super tired...
if you are testing for 0 you can change cmp esi, 0 to test esi, esi (its smaller) :)
Why would you have to change your code to work with an IDE? An IDE is just a front end (with fancy features)for your assembler/linker/compier/whetevertool...You would just have to set the paths that the IDE passes to your assembler/linker/tool or am I misunderstanding your meaning of IDE?
What IDE are you using?
hmm, you don't pay attention in class and now you want us to write your code? nope won't do it.... you learn nothing.... show some effort for cryin out loud! write some code... and when you get stuck, we will help...
mov edi, offset Arr
mov ax, word ptr [edi +2 *0]
1st line you are moving the address of Arr into edi
2nd line you are moving the 1st value in the array to ax. since your array are WORDS we use +2 if they were DWORDS you would use + 4, the *0 is the first array element, * 1 is the second, * 2 is the 3rd etc...
I do not think Windows 7 will run dos/com files anymore... MS dropped support for those file types.. You will need to run under a virtual machine... If you are starting out, I suggest you learn 32 bit windows assembly (a lot easier than 16 bit code and dos/com) Starting out? I suggest something with auto text/highlighting like an IDE RadSM and WinASM both support MASM. First you need to dl the MASM32 package.. includes everything you need to assemble files:
http://masm32.com/
Next get either IDEs:
http://radasm.cherrytree.at/
or
http://www.winasm.net/free-downloads.html
Try them both and see which you like... both have dialog editors built in, code highlighting, block indent, auto-complete, etc... An IDE will make your life easier.
As for Virii, stay with trusted programming sites... you will get MANY false positives even with the MASM32 package and some files in the ide packages... welcome to the world of Assebly ;)
RadASM will also allow you to debug from the IDE. Speaking of debuggers.... they will make your life easier hunting bugs.. I rec Olly:
http://www.ollydbg.de/ go with the 1.x version as 2.x is not primetime yet
Sorry, done with thread now....
Start with something SIMPLE as in a calculator in Assembly and progress from there... learn all the basics then some more basics and THEN maybe you can write a small game in Assembly....
Really? This is a fake topic right? Pulling everyones leg right? Assembly is 1 step above machine code.. you use mnemonics for an opcode and that gets assembled to machine code... or you misunderstand what machine code is... Basically get a hex editor, study, study, and study some more the PE format... Get the manuals from Intel and AMD (I got the paperbacks free from both companies when they printed them back in '94) now write EVERYTHING in Hex, opcodes and intructions... or write em in binary...
The big problems I see right away are:
1. you are using 32 bit registers and using pusha, pusha saves the 16 bit registers.. you need to use pushad
2. your stack is really screwed up!! you are using pusha without using popa. for every pusha/d you need to use a corresponding popa/d. If not, you leave the stack unbalanced.
3. Why use pusha/d? It is a fairly slow instruction. You don't need to save ALL of the registers..
Fix the stack issue and we will go from there...
Yes, that is correct. IF the characters are between 41H and 5AH, then subtract 32 from the char code to make lower... If the characters are between 61H and 7AH then add 32 to make upper.
Sure!!! Why couldn't you? If you have the time and patients, then you can write anything in Assembler. I had this in my collection: the old Boulder Dash game... credit to the original author, source included..
That 16bit code in the .code section will/should work with any 16bit assembler that uses Intel syntax which NASM/NASMX uses... What you need to find out is the differences in sections between TASM and NASM, and the differences in the header of the asm files. FASM works on Linux, you might want to look into that, or use GAS or something similar (EWWWW AT&T syntax), either way (FASM or NASM) you will need some modifications.
Technically, Yes you can... Will most people tell you how, No...
Just either, write a PE file in Hex by hand, or just use the mnemonics as most normal people do... The only reason I see one would want to do that is virii coding.. Now, if you want a user to write mov, eax, 1 in an edit box and have the processor execute that, then you will have to write/use a scripting language or something...
Window program? You cannot write directly to a serial port AFAIK. You would need to write a driver to do it in RING 0 in order to use OUT in 32 bit windows. Otherwise you would have to use the Windows API CreateFile, here is some reading:
http://msdn.microsoft.com/en-us/library/ms810467.aspx
MOV is an instruction
an Operand is "what" to operate on, so in the below sample eax and ecx are the operands
mov eax, ecx
and the opcode for the above mov would be 8B and the whole opcode for mov eax, ecx would be 8BC1 (Helps to have the Intel and AMD manuals)
Mov is just a mnemonic for an opcode, yes an opcode is an instruction that tells the cpu what to do. Yes a combination of a valid opcode/mnemonic and valid operand(s) make up an instruction
RadASM, WinASM and a few others are only IDE's (Intergrated Development Enviroments) They provide text coloring, dialog editors, autocomplete, MDI, resource editors, and many more things to make coding easier. We use assemblers not compilers (sure I'll get flamed for that)... they don't assemble anything, they are the "front end" to the assemblers. You could use notepad to write your code, I prefer the syntax highlighting of the IDE's. They are a help to beginners. Next you need an assembler. MASM, TASM, NASM, FASM, HLA, JWASM and more.. these are capable of assembling windows programs. For a beginner, I would go with the MASM32 package, it contains all of the needed lib files, include files, samples (there are MANY samples on the net) and has a large community of users.. you can get it from:
http://masm32.com/
Start slow, it will come to you in time... don't try to write the next office replacement... start with a simple calculator, and go from there.. use 32 bit code instead of 16 bit... All my apps are written in assembly... Above all, have fun!
Trying to reverse something? Tsk tsk tsk... What is dword_000001? Initialized, uninitialized? Oh, dword_000001 is a compiler generated name...
This should work:
mov ecx, offset dword_000001
lea ecx, [ecx]
Well, you if you have 2 processors/cores and use CreateThread the OS decides which to use? Or you can look into SetProcessAffinityMask and SetThreadAffinityMask Windows API to delegate what processor/core you want to use
5CH == 92 base 10
so it would be call DWORD PTR [ecx + 92]
what is it from? A disassembly?
Also, since the address of xd is known at assembly time you can do:
invoke MessageBox, NULL, offset xd, offset xd, MB_OK
or
push MB_OK
push offset xd
push offset xd
push NULL
call MessageBox
Hmm, guess I am supposed to introduce myself?
Name is Gunner, have been writing windows programs in assembly for about 10 years.. Figured I would find a new forum to share my knowledge :-)
Been building computers and programming in general for over 25 years so maybe somewhere in my noisy head something might be of use to someone.
WinASM is not an assembler but an IDE for MASM (and FASM with a plugin). You will also need to dl the MASM32 package from Hutches site... www.masm32.com comes with samples too!