; ifint.asm code ifint.c for nasm ; /* ifint.c an 'if' statement that will be coded for nasm */ ; #include ; int main() ; { ; int a=1; ; int b=2; ; int c=3; ; if(ac) ; printf("wrong on b > c \n"); ; else ; printf("false b > c \n"); ; return 0; ;} ; result of executing both "C" and assembly is: ; true a < b ; false b > c global main ; define for linker extern printf ; tell linker we need this C function section .data ; Data section, initialized variables a: dd 1 b: dd 2 c: dd 3 fmt1: db "true a < b ",10,0 fmt2: db "wrong on a < b ",10,0 fmt3: db "wrong on b > c ",10,0 fmt4: db "false b > c ",10,0 section .text main: mov eax,[a] cmp eax,[b] jge false1 ; choose jump to false part ; a < b sign is set push dword fmt1 ; printf("true a < b \n"); call printf add esp,4 jmp exit1 ; jump over false part false1: ; a < b is false push dword fmt2 ; printf("wrong on a < b \n"); call printf add esp,4 exit1: ; finished 'if' statement mov eax,[b] cmp eax,[c] jle false2 ; choose jump to false part ; b > c sign is not set push dword fmt3 ; printf("wrong on b > c \n"); call printf add esp,4 jmp exit2 ; jump over false part false2: ; a < b is false push dword fmt4 ; printf("false b > c \n"); call printf add esp,4 exit2: ; finished 'if' statement mov eax,0 ; normal, no error, return value ret ; return 0;