Primitive CPU instructions
Primitive CPU Instructions
I am taking a computer architecture class in college. My graduation is pending that I pass this class. I have to develop a program consisting of primitive CPU instructions, such as NOT, AND, OR, XOR, ADD and shift.
My problem is that I don't understand what the procedure is asking to do. If I could just put the logic in plain words then Maybe I can develop the couple of lines of instructions to implement the procedure.....
integer i, a;
i = 0;
While (i<10) do
a = i*2;
i = i +1;
endwhile
Any help would be greatly appreciated, or any information on how I can obtain an understanding of the procedure as well
I am a desperate individual......
:confused:
Well, I don't like doing other people's homework, but...
Quote:
i = 0;
While (i<10) do
a = i*2;
i = i +1;
endwhile
This might do it:
Code:
; reset dx to 0 in 1 byte less than MOV dx,0
XOR dx,dx
; label
_loop:
; load 2 into ax
MOV ax,2
; multiply dx by 2, store in ax
MUL ax,dx
; add 1 to dx
INC dx
; compare to 10
CMP dx,10
; jump less than to the label
JB _loop
I haven't tested it and I am a little rusty with x86 ASM.