; ASM implementation of a do-while loop ; ; do { ; body ; } while (condition) ; ; 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 ecx, 100 ; set test value ; start of do loop do: ;body of loop sub ecx, 10 ; will set a ZF at 0 dump_regs 0 ; view flags jnz do ; continue loop if ZF is NOT set ; 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