Ich habe meinen Kopf über eine Stunde gegen die Wand geschlagen und ich kann nicht verstehen, warum das unten nicht funktioniert. Wenn ich b: db 1
-b: db 0
dann sollte es 10 drucken zu ändern, sonst sollte es 0. Stattdessen drucken, druckt das Programm immer 10.Simple Assembly Ausgabe
Ich habe ein Projekt geschrieben, die Montage und das ist einer der Unit-Test schreibt, scheitert und ich verstehe es einfach nicht. Es muss etwas Einfaches sein.
extern printf, exit
section .bss
section .data
b: db 1
x: dd 5
y: dd 5
z: dd 0
int_pattern: db "%i", 10, 0
global main
section .text
main:
mov eax, dword [b]
cmp eax, dword 0
je condition_end4
; add x and y
; store into z
mov eax, dword [rel x]
add eax, dword [rel y]
mov [rel z], eax
condition_end4:
; rsi = &z
; rdi = &int_pattern
mov rsi, qword [z]
mov rdi, int_pattern
; not using vector registers
xor rax, rax
; printf(int_pattern, z);
call printf
Ich benutze Debian Linux mit NASM. Auch Montage/Verknüpfung mit
nasm -f elf64 -o test.o test.asm
gcc test.o -o test.bin
wenn b
0 ist, zeigt GDB, dass die cmp
ständig entsticht ZF so ich ratlos bin hier.
Danke!