Senin, 25 Mei 2009

Program Bahasa Assembly_Kipas

SCRIPT PROGRAM:
ORG 100H
BIL1 DB 2, 10, 4, 30
KAL0 DB 13,10,'KIPAS BERHENTI (25 < TOTAL DATA >= 50)$'
KAL1 DB 13,10,'KIPAS 1 NYALA (TOTAL DATA >= 25)$'
KAL2 DB 13,10,'KIPAS 2 NYALA (TOTAL DATA >= 30)$'
KAL3 DB 13,10,'KIPAS 3 NYALA (TOTAL DATA >= 35)$'
KAL4 DB 13,10,'KIPAS 4 NYALA (TOTAL DATA >= 40)$'
KAL5 DB 13,10,'KIPAS 5 NYALA (TOTAL DATA >= 45)$'
MULAI : XOR AX, AX
MOV CX, 3H
MOV DI, 100H
AMBIL : MOV AL, [DI]
ULANG : INC DI
MOV BL, [DI]
ADD AL, BL
LOOP ULANG
MOV AH,0H
MOV SI, AX
CMP SI, 31H
JGE CTK_KAL0
CMP SI, 19H
JGE CTK_KAL1
JL CTK_KAL0
HABIS : INT 20H
CTK_KAL0 PROC
LEA DX, KAL0
MOV AH, 09H
INT 21H
JMP HABIS
CTK_KAL0 ENDP
CTK_KAL1 PROC
LEA DX, KAL1
MOV AH, 09H
INT 21H
CMP SI, 1EH
JGE CTK_KAL2
JMP HABIS
CTK_KAL1 ENDP
CTK_KAL2 PROC
LEA DX, KAL2
MOV AH, 09H
INT 21H
CMP SI, 23H
JGE CTK_KAL3
JMP HABIS
CTK_KAL2 ENDP
CTK_KAL3 PROC
LEA DX, KAL3
MOV AH, 09H
INT 21H
CMP SI, 28H
JGE CTK_KAL4
JMP HABIS
CTK_KAL3 ENDP
CTK_KAL4 PROC
LEA DX, KAL4
MOV AH, 09H
INT 21H
CMP SI, 2DH
JGE CTK_KAL5
JMP HABIS
CTK_KAL4 ENDP
CTK_KAL5 PROC
LEA DX, KAL5
MOV AH, 09H
INT 21H
JMP HABIS
CTK_KAL5 ENDP

HASIL PROGRAM :
Data : 2, 10, 4, 30
Total Data = 46 (KIPAS 1-5 MENYALA)

0 komentar:

Posting Komentar