Created
April 29, 2021 01:19
-
-
Save febnug/996f60258ae5a6e0419984d7d7a7ba7e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; -- program input 2 digit angka lalu dijumlahkan -- | |
; | |
; catatan: | |
; | |
; program ini langsung input 2 digit angka, karena bukan "buffered input" | |
; dan gak ada kondisi untuk input "0dh" (enter) | |
; | |
; compile pake nasm : nasm add.asm -o add.com | |
; | |
; ----------------------------------------------------------------------- | |
; | |
; -- Febri | |
org 0x100 | |
global start | |
section .data | |
msg1 db "input 1 : $" | |
msg2 db "input 2 : $" | |
msg3 db "hasil penjumlahan : $" | |
section .text | |
start: | |
mov ah, 09h | |
mov dx, msg1 | |
int 21h | |
mov ah, 01h | |
int 21h | |
sub al, "0" | |
mov bl, al | |
int 21h | |
sub al, "0" | |
xchg al, bl | |
mov ah, 10 | |
mul ah | |
add al, bl | |
push ax | |
mov ah, 0eh | |
mov al, 13 | |
int 10h | |
mov al, 10 | |
int 10h | |
mov ah, 09h | |
mov dx, msg2 | |
int 21h | |
mov ah, 01h | |
int 21h | |
sub al, "0" | |
mov bl, al | |
int 21h | |
sub al, "0" | |
xchg al, bl | |
mov ah, 10 | |
mul ah | |
add al, bl | |
mov bl, al | |
push bx | |
pop bx | |
pop ax | |
add ax, bx | |
push ax | |
mov ah, 0eh | |
mov al, 13 | |
int 10h | |
mov al, 10 | |
int 10h | |
mov ah, 09h | |
mov dx, msg3 | |
int 21h | |
pop ax | |
mov bx, 10 | |
xor cx, cx | |
divisor: | |
xor dx, dx | |
div bx | |
push dx | |
inc cx | |
cmp ax, 0 | |
jnz divisor | |
cetak_angka: | |
pop dx | |
add dl, "0" | |
mov ah, 02h | |
int 21h | |
loop cetak_angka | |
mov ax, 4c00h | |
int 21h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment