PDA

View Full Version : Assembly- rol & ror


assembler-robot
08-24-2002, 07:56 AM
What's the difference between rol and ror? Are there specific times when I want to use one or the other? When I try it out

rol eax, 16

and

ror eax, 16

they both do the same thing, at least from what I can tell.

assembler-robot
08-24-2002, 09:04 AM
Nevermind, I feel stupid now. I figured it out. I was thinking that you had to rotate by 16, but you can shift by another number also.

assembler-robot
08-24-2002, 10:09 AM
Damn, got another problem. Whenever I include the files windows.inc, kernel32.inc, and kernel32.lib, I get the following:

error

\masm32\lib\kernel32.lib(1) : error A2008: syntax error : !

and a whole bunch of the like. My program consists of the following code:
____________________________________
.386
.model flat, stdcall
option casemap :none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\lib\kernel32.lib


.data

.code
start:

invoke ExitProcess, 0

end start
_____________________________________________

Any help will be appreciated, as I am just now starting to learn assembly language.

assembler-robot
08-24-2002, 10:11 AM
Now I feel completely retarded. I bash my head for an hour, and just when I ask for help, I find the answer. Please ignore the previous post

assembler-robot
08-24-2002, 01:13 PM
Alrighty, I've been trying to figure this out for an hour at least. I figure since I always find the answer AFTER I post for help, maybe I'll get lucky again. Anyway, can someone tell me what I'm doing wrong? I'm trying to create a generic window, and I get one error, which my assembler says is a syntax error for a mov command. it points to line 53 which is "invoke CreateWindowEx, NULL,\

Here's the code:


.386
.model flat,stdcall
option casemap :none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib

WinMain proto :DWORD,:DWORD,:DWORD,:DWORD

.data
ClassName db "WinClass_1",0
AppName db "A retarded Window",0

.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?

.code
start:

invoke GetModuleHandle, NULL
mov hInstance, eax


invoke GetCommandLine
mov CommandLine, eax

invoke WinMain, hInstance, NULL, CommandLine, SW_SHOWDEFAULT
invoke ExitProcess, eax

WinMain proc hInst:HINSTANCE, hPrevInst:HINSTANCE, CmdLine:LPSTR, CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hwnd:HWND

mov wc.cbSize, SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, OFFSET WndProc
mov wc.cbClsExtra, NULL
mov wc.cbWndExtra, NULL
push hInstance
pop wc.hInstance
mov wc.hbrBackground, COLOR_WINDOW+1
mov wc.lpszMenuName, NULL
mov wc.lpszClassName, OFFSET ClassName
invoke LoadIcon, NULL, IDI_APPLICATION
mov wc.hIcon, eax
mov wc.hIconSm, eax
invoke LoadCursor, NULL, IDC_ARROW
mov wc.hCursor, eax
invoke RegisterClassEx, addr wc
invoke CreateWindowEx, NULL,\
ADDR ClassName,\
ADDR AppName,\
WS_OVERLAPPEDWINDOW,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
NULL,\
NULL,\
hInst,\
NULL,\
mov hwnd, eax
invoke ShowWindow, hwnd, CmdShow
invoke UpdateWindow, hwnd

.WHILE TRUE
invoke GetMessage, ADDR msg, NULL,0,0
.BREAK .IF(!eax)
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.ENDW

mov eax, msg.wParam
ret
WinMain endp

WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.IF uMsg == WM_DESTROY
invoke PostQuitMessage, NULL
.ELSE
invoke DefWindowProc, hWnd, uMsg, wParam, lParam
ret
.ENDIF

xor eax, eax
ret
WndProc endp

end start

assembler-robot
08-24-2002, 02:49 PM
See, I am a moron. I can have an entire post with me asking questions and answering them an hour later. This time I accidentally added ',\' after the last NULL in CreateWindowEX, making the compiler think there was another attribute coming. DOH! Forgive my stupidity

sans-hubris
08-25-2002, 06:49 AM
I'm glad we could help! :D

Nafae would prefer that next time you just edit the original post rather than posting a response right after your own posts.

Thanks.

assembler-robot
08-25-2002, 08:06 AM
No prob. I'm new here, so I don't know all the rules. Don't think that one was in the FAQ though. You should add it

Halide
08-25-2002, 10:40 AM
Hey I used to know some x86 assembly... Not much of it though! :D

assembler-robot
08-25-2002, 11:46 AM
Assembly programming is the *user edit*! I've got further in two days than I got in C++ in a month. Sure, I've got a few things to learn before I can make real programs instead of these bulldoo-doo programs that I'm forced to go through before I can use my creativity. Which brings me to my next question.

How do I get the compiler to link my resource files? I defined a menu in a resource file, and now I can't get my assembly program to show the menu. There's something I'm missing. Anybody have any idea?


EDIT: Once again, ignore. I don't know what it is, but about an hour after I post these messages, I magically happen upon the answer. The problem is stupid tutorials. All the ones I try must be written by people that don't want me to learn the language. So I have to figure it out on my own. Needless to say, I'd like to find the semi-illiterate bastards who write these things. I can say bastard, can't I?