assembly - MASM32 error A2070: invalid instruction operands -


i have assembly32 code hanoi, can't compile it, error: hanoi.asm(9) : error a2070: invalid instruction operands use masm32.

the full code:

        .586 .model  flat public        _towers extern  _printf:near .code _towers:push  ebp         mov   ebp, esp         sub   esp, 4         cmp   [ebp+8], 1   ;error         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 l1:     mov   eax, 6         sub   eax, [ebp+12]         sub   eax, [ebp+16]         mov   [ebp-4], 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         mov   eax, [ebp+16]         push  eax         mov   eax, [ebp-4]         push  eax         mov   eax, [ebp+8]         dec   eax         push  eax         call  _towers         add   esp, 12 done:   mov   esp,ebp         pop   ebp         ret   0 .data format  db "move %d %d\n" end 

can please me, how can make work?

your code didn't work me, ran wrong algorithm, never found solution.

so, here hanoi towers solution works. it's made emu8086 (masm intel syntax), copy-paste , run :

.model small .stack 300h .data x dw 3 text db "move peg " d1 db ? text2 db " peg " d2 db ? newline db 0ah, 0dh, '$'  .code main proc      mov ax, @data     mov ds, ax      mov ax, 1     push ax     mov ax, 3     push ax     mov ax, 2     push ax     mov ax, x     push ax     call solve      mov ax, 4c00h     int 21h   main endp  solve proc    push bp    mov bp, sp    cmp word ptr ss:[bp+4], 0    je down     push word ptr ss:[bp+0ah]    push word ptr ss:[bp+6]    push word ptr ss:[bp+8]    mov ax, word ptr ss:[bp+4]    dec ax    push ax    call solve     push word ptr ss:[bp+0ah]    push word ptr ss:[bp+08]    call print     push word ptr ss:[bp+06h]    push word ptr ss:[bp+8]    push word ptr ss:[bp+0ah]    mov ax, word ptr ss:[bp+4]    dec ax    push ax    call solve     pop bp    ret 8 down:    pop bp    ret 8  solve endp  print proc    push bp    mov bp, sp    mov d1, '0'    mov al, byte ptr ss:[bp+06]    add d1, al    mov d2, '0'    mov al, byte ptr ss:[bp+4]    add d2, al    lea dx, text    mov ah, 09    int 21h    pop bp    ret 4  print endp end 

remember said initialization data? well, 1 has it! maybe that's why works.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -