switchTest.asm

URL: https://mirkwood.cs.edinboro.edu/~bennett/class/cmsc3100/spring2026/notes/files/code/switchTest.asm
 

%include "CONSTANTS.h"


section .data

     cases: dq SWITCH.A, SWITCH.B, SWITCH.C, SWITCH.D
     outLine: db `the value is %d\n`,0


section .bss

section .text

global main
main:
    ;mov rdi, format1
    ;mov rsi, -1
    ;call CallPrintf 

SWITCH:
    mov r12,0 
.top:

    mov rdx, 0
    mov rax, 8

    mul r12

    mov r10, [cases + rax]

    jmp r10

.A: 
    mov rsi, 10
    jmp .bottom

.B:  mov rsi, 100
    jmp .bottom

.C:  mov rsi, 1000
    jmp .bottom

.bottom:
    mov rdi, outLine
    call CallPrintf

    inc r12
    jmp .top

.D:

    jmp Exit