I'm trying to run the code presented in tanenbaum computer architecture 6th book. I typed exactly the same code as the book. here is the code:
.686
.MODEL FLAT
PUBLIC _towers
EXTERN _printf:NEAR
.CODE
_towers:
push ebp
mov ebp, esp
cmp [ebp + 8], 1
jne L1
mov eax, [ebp + 16]
push eax
mov eax, [ebp + 12]
push eax
push OFFSET FLAT:format
call _printf
add esp, 12
jmp Done
mov eax, 6
jmp Done
L1:
mov eax, 6
sub eax, [ebp + 12]
sub eax, [ebp + 16]
mov [ebp + 20], eax
push eax
mov eax, [ebp + 12]
push eax
mov eax, [ebp + 8]
dec eax
push eax
call _towers
add esp, 12
mov eax, [ebp + 16]
push eax
mov eax, [ebp + 12]
push eax
push 1
call _towers
add esp, 12
call _towers
add esp, 12
mov eax, [ebp + 12]
push eax
mov eax, [ebp + 20]
push eax
mov eax, [ebp + 8]
dec eax
push eax
call _towers
add esp, 12
Done:
leave
ret 0
.data
format db "Move disk from %d to %d\n"
END
But it has some errors:
Hanoi.asm:2: error: attempt to define a local label before any non-local labels
Hanoi.asm:3: error: attempt to define a local label before any non-local labels
Hanoi.asm:3: error: parser: instruction expected
Hanoi.asm:4: error: parser: instruction expected
Hanoi.asm:5: error: no special symbol features supported here
Hanoi.asm:16: error: comma, colon, decorator or end of line expected after operand
I'm totally new to this language. I'm using NASM as the assembler on x86_68 linux ubuntu like:
nasm -f elf64 -o Hanoi.o Hanoi.asm