Well I'm kinda a fan of visual basic 6.0, but the thing that kills me the most is its lack of speed :P, I do alot of helping game programmers and some things dealing with games was slowing them down so i told them i would write it in machine code and make it callable using CallWindowProc. I made a simple function in NASM that was callable that would return the first parameter! Then i tryed to write a function thats the equate to RGB() in VB. I ran into some trouble and figured this would be the best place to post :P
here are my notes
VB RGB(100, 150, 200) = 13145700 (Decimal)
1100 1000 | 1001 0110 | 0110 0100 (Binary)
200 150 100
B G R
Okay I assume that there is an empty byte before B or after R
so im assuming this is right but it gives incorrect results :[ please help me :[
%Define long1 ; Red
%Define long2 ; Green
%Define long3 ; Blue
%Define long4 ; Null
push ebp
mov ebp,esp
push ebx ; These 3 registers
push esi ; should be preserved
push edi ; in general. Though not essential
xor eax, eax ; zero eax
mov ax, long3
shl ax, 8
mov ah, long2
shl ah, 8
mov ah, long1
pop edi ; restore registers
pop esi
pop ebx
mov esp,ebp
pop ebp
ret 16
here are my notes
VB RGB(100, 150, 200) = 13145700 (Decimal)
1100 1000 | 1001 0110 | 0110 0100 (Binary)
200 150 100
B G R
Okay I assume that there is an empty byte before B or after R
so im assuming this is right but it gives incorrect results :[ please help me :[
%Define long1 ; Red
%Define long2 ; Green
%Define long3 ; Blue
%Define long4 ; Null
push ebp
mov ebp,esp
push ebx ; These 3 registers
push esi ; should be preserved
push edi ; in general. Though not essential
xor eax, eax ; zero eax
mov ax, long3
shl ax, 8
mov ah, long2
shl ah, 8
mov ah, long1
pop edi ; restore registers
pop esi
pop ebx
mov esp,ebp
pop ebp
ret 16
Hmm I replaced the code with this...
%Define long1 ; Red
%Define long2 ; Green
%Define long3 ; Blue
%Define long4 ; Null
push ebp
mov ebp,esp
push ebx ; These 3 registers
push esi ; should be preserved
push edi ; in general. Though not essential
xor eax, eax
mov ax, 200
mov ah, 150
mov al, 100
pop edi ; restore registers
pop esi
pop ebx
mov esp,ebp
pop ebp
ret 16
it seems its returning 150, 100 ( 38500 )
i guess its only returning 16 bits :\ but i need to return 32 bits :[
%Define long1 ; Red
%Define long2 ; Green
%Define long3 ; Blue
%Define long4 ; Null
push ebp
mov ebp,esp
push ebx ; These 3 registers
push esi ; should be preserved
push edi ; in general. Though not essential
xor eax, eax
mov ax, 200
mov ah, 150
mov al, 100
pop edi ; restore registers
pop esi
pop ebx
mov esp,ebp
pop ebp
ret 16
it seems its returning 150, 100 ( 38500 )
i guess its only returning 16 bits :\ but i need to return 32 bits :[
You have to put EAX to effect upper 16 bits.
xor eax, eax ; 00000000
mov al, long3 ; 000000aa
shl eax, 16 ; 00aa0000
mov ah, long2 ; 00aabb00
mov al, long1 ; 00aabbcc
You overwrite ax with ah and al in your code snippet.
xor eax, eax
mov ax, 200
shl eax,16
mov ah, 150
mov al, 100
shl moves ax in the high part of eax
xor eax, eax
mov ax, 200
shl eax,16
mov ah, 150
mov al, 100
shl moves ax in the high part of eax
Thanks for the help, as im not a great asm programmer and im good with vb I appreciate it alot and I will be posting more often for more help like this :)