Professional Documents
Culture Documents
MOV BX,AX ; This copies the contents of the AX register into the BX register.
MOV CH,DH ; This copies the top byte of the DX register into the top byte of the CX register.
MOV BH,DL ; This copies the bottom byte of the DX register into the top byte of BX.
MOV AH,12 ; This puts the value 12 decimal into the top half of the AX register.
MOV AH,0Ch ; This does the same as the above except that the number is given in hexadecimal.
; Hexadecimal numbers MUST begin with a digit and end with a "h".
MOV DL,"*" ; This puts the character "*" into DL (lower half of DX).
MOV DL,42 ; This does the same thing, as characters are stored as numbers. ( ASCII char 42 = "*" )
mov ah, 1 ;read character from standard input, with echo, result is stored in AL.
mov ah, 2 ; write character to standard output; DL = character to write
int 21h ; if there is no character in the keyboard buffer, the function waits until any key is pressed.
mov ah, 0ah ; input of a string to DS:DX, fist byte is buffer size, second byte is number of chars actually read
move ah, 0Ch ;flush keyboard buffer and read standard input.
mov ah,00
int 16h ;wait for keypress
Logic instructions
LOGIC tujuan, source
AND ax, dx ; ax AND dx hasil disimpan di ax
OR ax, bx ; ax OR bx hasil disimpan di ax
XOR bx, ax ; bx XOR ax hasil disimpan dib bx
Arithmetic instructions
ADD tujuan, source ADD ax, bx ; ax + bx simpan di ax
SUB tujuan, source SUB ax, bx ; ax – bx simpan di ax
ADD cx,num ;add num value to cx value
SUB num,5 ;subtract 5 from variable num
DIV source DIV SI ; div ax dengan nilai SI
div bl ;bagi ax dengan nilai di bl. Hasilnya simpan di al, sisanya di ah
div ch ;al = ax / ch, ah = ax % ch (% = modulus operator in C++ or "mod" in Pascal)
div 7 ;al = ax / 7, ah = ax % 7
IMUL ax,10 ; kalikan ax dengan 10 simpan di ax
mul bl ;multiply bl * al giving result in ax.
mul b[bx] ;ax = value-pointed-to-by-bx * al
Loop Instruction
LOOP label ; kurangi nilai cx dengan 1 jika belum 0 jalankan lagi perintah2 dari label
Jump Instruction
JMP label ; lompat ke label
JE label ; jump if equal / lompat ke label jika sama
JNE label ; jump if not equal / lompat ke label jika tidak sama
JG label ; jump if greater
JL label ; jump if lower
JGE label ; jump if greater or equal / JNL label ; jump if not lower
JNZ label ; jump if not Zero / lompat ke label jika tidak kosong
1. ADD2BIL
; === Makro ===
%macro printstr 1 ; cetak tulisan ke layar org 100h
jmp %%cetak
%%str db 13,10,%1,'$'
start:
%%cetak:
mov dx, %%str printstr 'Menambahkan 2 buah bilangan
mov ah, 9 bulat'
int 21h ; int 21h = readln Tampilkan
printstr '(Maksimum hasilnya 65535)' langsung ke
%endmacro
printstr '---------------------------------' layar
%macro printvar 1 ; cetak variable ke layar printstr ' '
mov dx, %1
Baca inputan
mov ah, 9 printstr 'Tulis Bilangan 1: ' keyboard
int 21h
%endmacro
readstr sbil1 masukkan ke
variable sbil1
%macro readstr 1 ; baca inputan keyboard printstr 'Tulis Bilangan 2: '
masukkan ke
mov byte [%1], 10 readstr sbil2 variable sbil2
mov dx, %1
mov ah, 0Ah
int 21h str2bin sbil1, nbil1 Ubah ke
str2bin sbil2, nbil2 binner
%endmacro
2. TAMBAH
; ==== makro === org 100h
start:
%macro printstr 1
jmp %%cetak printstr 'Menambahkan 2 buah bilangan bulat'
%%str db 13,10,%1,'$' jmp %%cetak
%%cetak:
%%str db 13,10,%1,'$'
mov dx, %%str
mov ah, 9
int 21h %%cetak:
%endmacro mov dx, %%str
mov ah, 9
%macro printvar 1 int 21h
mov dx, %1
printstr '(Maksimum hasilnya 65535)'
mov ah, 9
int 21h jmp %%cetak
%endmacro %%str db 13,10,%1,'$'