There are three variable a = 4, b = 8, c = 12. Compare a and b, then
if A > B then D = A * B - C
If A = B, then compare B and C
- If B > C, do D = A + B - C
- if B = C, do D = A * B / C
- If B < C, do D = A + B / C
If A < B Then D = A * C - B
all result are printed with description sentences.
Code for Macro.ASM
INCLUDE PUSTAKA.MCR.MODEL SMALL.CODEORG 100hMulai : JMP ProsesKal0 DB 13,10,'PENYELESAIAN $'Kal1 DB 13,10,'A = $'Kal2 DB 13,10,'B = $'Kal3 DB 13,10,'C = $'Kal4 DB 13,10,'Karena A > B, maka A*B-C = $'Kal5 DB 13,10,'Karena A = B dan B > C, maka A+B-C = $'Kal6 DB 13,10,'Karena A = B dan B = C, maka A*B/C = $'Kal7 DB 13,10,'Karena A = B dan B < C, maka A+B/C = $'Kal8 DB 13,10,'Karena A < B, maka A*C-B = $'a Dw 4b Dw 8c Dw 12d Dw 0Proses:Cetak_Klm Kal0Cetak_Klm Kal1Cetak_Angka aCetak_Klm Kal2Cetak_Angka bCetak_Klm Kal3Cetak_Angka cMOV AX,aCMP AX,bja aBesarje asamajb aKecilaBesar :Cetak_Klm Kal4Perkalian a,bMOV d,AXPengurangan d,ctampilJMP KeluaraKecil :Cetak_Klm Kal8Perkalian a,bMOV d,AXPengurangan d,ctampilJMP Keluarasama :MOV AX,bCMP AX,cja bBesarje bsamajb bKecilbbesar :Cetak_Klm Kal5Perkalian a,bMOV d,AXPengurangan d,ctampilJMP Keluarbsama :Cetak_Klm Kal6Perkalian a,bMOV d,AXPembagian d,ctampilJMP Keluarbkecil :Cetak_Klm Kal7Pembagian b,cMOV d,AXPenjumlahan a,dtampilJMP KeluarKeluar :INT 20hEND Mulai
Code for Pustaka.MCR
Cetak_Kar Macro KarMOV AH,02MOV DL,KarINT 21HEndMCetak_Klm MACRO KlmLEA DX,KlmMOV AH,09INT 21hENDMCetak_Angka MACRO Angkamov ax,angkaTampilendmPerkalian MACRO a,bMOV AX,aMul bendmPenjumlahan MACRO a,bMOV AX,aADD AX,bendmPengurangan MACRO a,bMOV AX,aSUB AX,bendmPembagian MACRO a,bSUB DX,DXMOV AX,aDIV bendmTampil Macrolocal looping, cetakmov bx,10xor cx,cxlooping:xor dx,dxdiv bxpush dxinc cxcmp ax,0jne loopingcetak:pop dxadd dl,'0'mov ah,02hint 21hloop cetakendM
Sign up here with your email
ConversionConversion EmoticonEmoticon