Skip to content

Instantly share code, notes, and snippets.

@PhilipPurwoko
Last active October 6, 2021 14:46
Show Gist options
  • Save PhilipPurwoko/cb736c473b112efc257307ffe1bab82f to your computer and use it in GitHub Desktop.
Save PhilipPurwoko/cb736c473b112efc257307ffe1bab82f to your computer and use it in GitHub Desktop.
Assembly Language
section .data
pesanSiang: db 'Selamat Siang',10
pesanSiangLen: equ $-pesanSiang
pesanPagi: db 'Selamat Pagi',10
pesanPagiLen: equ $-pesanPagi
section .text
global _start
_start:
mov ecx, 6 ; Jam sekarang
mov eax, 1
cmp ecx, 10 ; Compare dengan jam 10
jge siang ; Jika >= 10
jl pagi ; Jika kurang dari 10
jmp exit
pagi:
; print pesanPagi
mov eax,4
mov ebx,1
mov ecx,pesanPagi
mov edx,pesanPagiLen
jmp exit
siang:
; print pesanSiang
mov eax,4
mov ebx,1
mov ecx,pesanSiang
mov edx,pesanSiangLen
jmp exit
exit:
int 0x80
mov eax,1
mov ebx,0
int 0x80
section .data
hello: db 'Hello world!',10
helloLen: equ $-hello
section .text
global _start
_start:
; print Hello world
mov eax,4
mov ebx,1
mov ecx,hello
mov edx,helloLen
; Exit program
int 0x80
mov eax,1
mov ebx,0
int 0x80
section .data
pesan: db 'Iterasi',10
pesanLen: equ $-pesan
section .text
global _start
_start:
mov ebx, 1
mov ecx, 6
iterasi:
add ebx, ebx
dec ecx
cmp ecx, 0
jnz iterasi
mov eax,4
mov ebx,1
mov ecx,pesan
mov edx,pesanLen
int 0x80
mov eax,1
mov ebx,0
int 0x80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment