simple.asm

URL: https://mirkwood.cs.edinboro.edu/~bennett/class/cmsc3100/spring2026/notes/flags/code/simple.asm
 
%include "CONSTANTS.h"

LOOP_ONE_LIMIT equ 10

section .data
     countFmt: db `i = %d\n`,0
     endl:  db `\n\n`,0

section .bss

section .text

global main
main:

    mov rax, 0
    add rax, -2
    inc rax

    inc rax

    inc rax

; a loop to demo labels

    mov r12, 0
loop1:
.top:
    cmp r12, LOOP_ONE_LIMIT
    jge .out

    mov rdi, countFmt
    mov rsi, r12
    call CallPrintf

    inc r12
    jmp .top 

.out:

    mov rdi, endl;
    call CallPrintf

; a second loop with the same labels
    mov r12, LOOP_ONE_LIMIT
loop2:
.top:
    cmp r12, 0 
    jz .out

    mov rdi, countFmt
    mov rsi, r12
    call CallPrintf

    dec r12
    jmp .top 

.out:
   
    jmp Exit