-
December 19th, 2005, 11:10 AM
#1
Check this little assingment of arithmatic operation...
The assignment is:
"Consider the following pseudo-code and write the corresponding assembly code for it.
Note: There is more credit for a shorter code.
Code:
if (al>bl) AND (bl>cl){
CX=1
}
and I've write the code:
Code:
[org 0x0100]
mov al, 7
mov bl, 3
mov cl, 5
cmp al, bl
ja L1
jmp done
L1: cmp bl, cl
jb done
mov cx, 1
done: mov 0x4c00
int 0x21
Now please do it more shorter if possible, I'll much thankful to you.
Mood.
-
December 20th, 2005, 04:12 AM
#2
Re: Check this little assingment of arithmatic operation...
There isn't a lot of sense in reducing the number of instructions, since small size doesn't necessarily equal fastest code. Speed is kind of the point with asm nowadays, unless we're talking about extremely memory-limited microcontrollers (but these don't use the x86 instruction set).
That said, the comparison stage could be a bit shorter:
Code:
cmp bl,al
jae done
cmp cl,bl
jae done
mov cx,1
done:
A couple of issues with your original code: Shouldn't it be "jbe done" instead of "jb done"? And what's "mov 0x4c00"? Missing an operand?
-
December 20th, 2005, 11:17 AM
#3
Re: Check this little assingment of arithmatic operation...
Dear Synthetic Being!
Thanx a lot for shortening the code. The speed isn't issue here in shortening the code, it is just an assignment. The "move cx, 04c00" command is to end the programm.
Thanx once again.
Mood.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|