mov eax, edx
shl eax, 3 ; eax = XYabc 123000
xor edx, eax ; edx = XY 123123
shr eax, 6 ; eax = 0XYabc
xor edx, eax ; edx = XY 123abc
? (i am not sure how to find out the size...)
edit: shl and shr were around the wrong way
In this case have to be Md always 11, so that swapping bit fields is much more simple...
byte 0xD4, 1000y
xchg ah, al
byte 0xD5, 1000y
add al, 11000000y - 11000y
...should be an eight byte solution (no assembler here).
Sorry, abc123, but that solution does not work.
Please, see these example values:
mov eax, edx
[COLOR=blue]; EDX = 00011101010y[/COLOR]
shl eax, 3 ; eax = XYabc 123000
[COLOR=blue]; EAX = 11101010000y[/COLOR]
xor edx, eax ; edx = XY 123123
[COLOR=blue]; EDX = 11110111010y[/COLOR]
shr eax, 6 ; eax = 0XYabc
xor edx, eax ; edx = XY 123abc
[COLOR=red]; EDX = 11110100111y (bad result)[/COLOR]
[COLOR=green]; EDX = 11010101y (expected result)[/COLOR]
Hi,
BitRake,
You can save another byte :) :
BitRake,
You can save another byte :) :
; input al = ?? xyz abc can be written n = 64A + 8B + C
; output = ?? abc xyz can be written n' = 64A + 8C + B = n - 7(B-C)
mov dl, al ; dl = n
db 0D4h, 64 ; ah = 64A, al = 8B + C
db 0D4h, 8 ; ah = B, al = C
sub ah, al ; ah = B - C
mov al, dl ; al = 64A + 8B + C
db 0D5h, -7 ; al = n - 7*(B-C)
Dr. Manhattan, very cleaver solution!
Posted on 2003-08-16 12:11:31 by bitRAKE
Posted on 2003-08-16 12:11:31 by bitRAKE
Greetings bitRAKE and Dr.Manhattan and everyone, I managed to trim two more bytes:
;---------------------------
Input: al = 64A + 8B + C
Output: al = 64A + 8C + B
;---------------------------
mov dl, 8 ; al = 64A + 8B + C
db 0D4h, 64 ; ah = A, al = 8B + C, ax = 256A + 8B + C
shl ah, 1 ; ax = 512A + 8B + C
div dl ; ah = C, al = 64A + B
db 0D5h, 8 ; al = 64A + 8C + B
;---------------------------
;---------------------------
Input: al = 64A + 8B + C
Output: al = 64A + 8C + B
;---------------------------
mov dl, 8 ; al = 64A + 8B + C
db 0D4h, 64 ; ah = A, al = 8B + C, ax = 256A + 8B + C
shl ah, 1 ; ax = 512A + 8B + C
div dl ; ah = C, al = 64A + B
db 0D5h, 8 ; al = 64A + 8C + B
;---------------------------
Why do you use db? Isn't it possible to encode with instructions?
Hello comrade,
The generalized 'D4 ib' and 'D5 ib' versions of the AAM and AAD instructions don't have mnemonics according to the Intel x86 Processor Instruction Set Reference..
The generalized 'D4 ib' and 'D5 ib' versions of the AAM and AAD instructions don't have mnemonics according to the Intel x86 Processor Instruction Set Reference..
Why do you use db? Isn't it possible to encode with instructions?
Poimander, I just knew it was too big! :grin:
Wonder how small it can be?
Nice ! :)
The Svin certainly formulates interesting problems.