; ASM implementation of an if() statement ; ; if (condition) then ; then_block ; ; include directives global asm_main %include "../lib/asm_io.inc" segment .data ; DX directives (read only, static data) segment .bss ; RESX directives (writable data) segment .text asm_main: ; entry point (called from driver.c) ; instructions enter 0,0 ; Initialize register EBP pusha ; Push register contents to the stack ; mov eax, 4096 ; put test data in EAX mov ecx, 96 ; put test data in ECX cmp eax, ecx ; compare jle end_if ; evaluate for <= ; then block sub eax, ecx ; 4096-96 end_if: call print_int ; Print 4096 is not modified call print_nl ; otherwise, print 4000 ; popa ; Restore register data from the stack mov eax, 0 ; flush EAX of data leave ; restore the stack ret ; Return from main back into C library wrapper