I've been working on this code for an assignment, can't seem to get the output right. Can anyone please help me out?
NOTE: The program is compiled in MASM
- I'm only allowed to use reg-mem and reg-reg architecture commands.
- Only use MOV, ADD, DEC, JMP, or Jcc instructions.
- Only use the four main registers, i.e., EAX, EBX, ECX, and EDX, along with ESI register and their sub registers for arithmetical/logical operation.
- Other then the string memory variables no other memory variable is allowed.
Following is the code:
INCLUDE Irvine32.inc
.data
string1 byte "Enter number to generate Fibonacci series: ",0
string2 byte "Fibonacci is ",0
.code
main PROC
call DumpRegs;
mov edx,offset string1;
call writestring;
call ReadInt;
mov ecx,eax;
mov eax,1;
call DumpRegs;
dec ecx;
mov esi,eax;
JMP Jumpzero;
mov edx, offset string2;
call writeint ; Display the contents of eax register on the output device
Jumpzero:
add eax,esi;
call DumpRegs;
inc esi;
dec ecx
jnz Jumpzero
exit
MAIN ENDP
END main
dec cx
jnz Jumpzero
, aren't you usingloop Jumpzero
? – Powerslave