sfl-examples/slide-examples/ex14.asm

35 lines
579 B
NASM
Raw Normal View History

2023-12-14 14:12:51 +01:00
bits 64
SECTION .data
; holds 64-bit addresses of all jump target
jumptable: dq switch.c1, switch.c2, switch.c3
SECTION .text
global _start
_start:
%include "header.asm.inc"
; switch example
mov rax, 1
switch:
cmp rax, 3
jg .def
jmp [jumptable + rax*8]
.def: mov rbx, 0 ; default case
jmp fin
.c1: mov rbx, 1 ; case 1
jmp fin
.c2: mov rbx, 2 ; case 2
jmp fin
.c3: mov rbx, 3 ; case 3
jmp fin
; end of switch
fin: nop
%include "sysexit.asm.inc"