You are on page 1of 11

Nama : Jordy Aprillianza Budiang

NIM : D411 14 308

Mata Kuliah : Sistem Mikroprosesor dan Antarmuka

Tugas 2!

1. Perangkat Lunak apa saja yang diperlukan untuk pemrograman Assembly?
Jawab:
Software untuk pemrograman Assembly:
 Atmel Studio 6
 AVRDude
 Turbo Assembler
 Visual Studio

2. Definisi Assembly Language.
Jawab:
Bahasa Assembly adalah sebuah program yang terdiri dari instruksi-instruksi yang
menggantikan kode-kode biner dari bahasa mesin dengan “mnemonik” yang
mudah diingat. Misalnya sebuah instruksi penambahan dalam bahasa mesin
dengan kode “10110011” yang dalam bahasa assembly dapat dibuat dalam
instruksi mnemonik ADD, sehingga mudah diingat dibandingkan dengan angka 0
dan 1, dalam setiap instruksi membutuhkan suatu operand baik berupa data
langsung maupun suatu lokasi memori yang menyimpan data yang bersangkutan.
Bahasa Assembly adalah bahasa komputer yang kedudukannya di antara
bahasa mesin dan bahasa level tinggi misalnya bahasa C, C++, Pascal, Turbo
Basic, Java, dan sebagainya.
3. Contoh-contoh program Assembly.
Jawab:

 Variasi LED Berjalan
; VARIASI LED BERJALAN
;=====================================
#include <sfr51.inc>
ORG 00H
mov A, #00000001b

TUNDA2 DJNZ R0.header ORG 0000H MULAI : MOV P2.#FFH .Mengulang ke MULAI DELAY : MOV R0. 9 ulang: int 21h loop ulang int 20h end mulai  Alarm Alarm .tunda waktu SJMP MULAI .tunda waktu MOV P2.DELAY2 DJNZ R0.#100 DELAY1 : MOV R1. A ACALL TUNDA SJMP MULAI TUNDA: MOV R0. #001h TUNDA1: MOV R1. #0FFH TUNDA3: NOP DJNZ R2.model small .02h mov dl.#00H .isi 00 heksadesimal ke port 2 ACALL DELAY . 'A' mov cx.isi FF heksadesimal ke port 2 ACALL DELAY .$ DJNZ R1.code org 100h mulai: mov ah. A MOV P0. #0FFH TUNDA2: MOV R2. MULAI: RR A MOV P2.#0 DJNZ R2.DELAY1 RET END  Program Perulangan (Loop) .#0FFH DELAY2 : MOV R2. TUNDA3 DJNZ R1. TUNDA1 RET END  Menyalakan LED #include .

1 second or 18 ticks hour dw 0 . Memory-resident program to intercept the timer interrupt and display the . start-up code jumpval dd 0 . alarm length (loop count) may be from 1-FFFF dhours dw 0 . '-' = off. interrupt address segaddr equ 62h*4 . color attribute assume cs:cseg. alarm beep counter .number of seconds (5) atone db 5 . program signature state db 0 . x is '-' to turn the display off.may be from 1 to 255 . minute conversion factor * 16 whozat equ 1234h .ss:nothing. turn the clock on intaddr equ 1ch*4 .es:nothing jmp p150 .the . address of prior interrupt signature dw whozat .cseg segment para public 'code' org 100h alarm proc far . where hh:mm is the alarm time and .ds:cseg. . system time in the upper right-hand corner of the display. hour of the day atime dw 0ffffh . segment address of first copy mfactor equ 17478 . all else = on wait dw 18 . minutes past midnite for alarm acount dw 0 . the lower the frequency aleng dw 8080h . higher the number. signature color equ 14h . alarm tone . This program is run as 'ALARM hh:mm x'. Any other value of x or no value will . wait time . display hours .

db ':' dmins dw 0 . display seconds db '-' ampm db 0 . save other registers push cx push dx push es push si push di push bp mov ax.ax mov al. end of stack holdsp dw 0 .18 . reset wait time mov wait.ax . save stack mov holdss. zero? jz p010 .ax . original ss p000: . disable interrupts mov ax. allow interrupts push bx .wait . point to internal stack mov sp.ss . 'A' or 'P' for am or pm db 'm' tstack db 16 dup('stack ') . are we disabled? .offset estack sti . yes .1 second has elapsed mov wait. not this time jmp p080 .state .ax mov holdsp. display minutes db ':' dsecs dw 0 . make ds=cs mov ax. original sp holdss dw 0 . temporary stack estack db 0 .sp mov ax.ds mov ss. interrupt code push ax . return p010: cli . save registers push ds pushf push cs pop ds . check wait time dec ax .

12 . save remainder mov bx.set pm sub ax. compute hours xor dx. get beep count dec ax .acount . yes . get time of day mov ax.0 . remainder in dx cmp ax.ax p018: pop ax p020: mov dsecs.cl . multiply by 16 mov bx.atime . yes . zero it div bx .12 . low part mov dx.dx . compute minutes div bx .cl . read time int 1ah .ax mov cl. no jmp p070 p015: mov ah. midnight? jnz p030 .0 . now in upper mov cl. down by 1 mov acount.60 .mfactor . multiply by 16 mov bx. hours in ax.4 shl ax.12 . yes jmp p040a . no .bx .keep alarm on mov ax.dx .beep the speaker twice push ax mov ax. is it zero? jnz p018 .ax . cmp al. isolate top 4 bits of ax add dx. before noon? jb p040a . minutes in ax.0 . no call p100 . save beep count cmp ax.dx .12 shr bx.4 shl dx.dx . noon . convert the rest .cl . turn off alarm mov atime. no mov ax.set am jz p040p .cx . minutes in dx mov dmins. set am p030: cmp ax. high part mov cl.0ffffh . save minutes cmp ax.'-' jnz p015 . time to sound the alarm? jnz p020 .

color screen address p061: mov dx.ax mov ax. top of the hour? jz p060 . beep the speaker once p060: add ax.30h .ax call p120 . check monitor type mov es. get minutes aam add ax.ax mov ax.ax xor ax.hour .bl aam .ax .al mov dsecs. seconds in ax aam add ax.'a' p040x: mov ampm.30h .es:[410h] .6 .dx mov bx.mfactor div bx .0b000h . assume mono jz p061 . point to 6845 base port add dx.3030h xchg ah.dmins . its mono mov ax.'p' jmp p040x p040a: mov bl.0b800h .al mov dhours.60 mul bx mov bx. color? mov ax.ax mov ax. point to status port . get seconds (remainder) xor dx.es:[463h] .p040p: mov bl. fix up hour cmp ax. convert hours to ascii xchg ah.al mov dmins.dsecs . isolate monitor type cmp al. convert to ascii xchg ah. no mov hour.3030h . get config byte and al.3030h .

restore registers pop di pop si pop es pop dx pop cx pop bx cli .dx . color in bh mov si. move color & character again sti . point to time mov di.138 .color .wait cli . get crt status test al.1 . done? p070: pop bp .offset dhours .20000 p105: loop p105 . is it low? jnz p063 . no interrupts mov ax. no . point to next character loop p062 . point to monitor mov bh. beep the speaker twice call p120 push cx mov cx.ax .11 .[si] . row 1. allow interrupts p080: popf pop ds pop ax jmp cs:[jumpval] p100 proc near . col 69 cld mov cx.bx .dx . loop count p062: mov bl. get crt status test al.ax mov sp. no . wait around . is it high? jz p064 .holdss mov ss.holdsp sti .wait mov ax. interrupts back on inc si . mov es.1 . get next character p063: in al. move color & character stosw . no interrupts p064: in al.

ax . segment 0 mov di.ax . turn speaker off pop cx pop ax ret p120 endp p150: .182 out 43h. get alarm tone out 42h. restore original port value out 61h.install it call p200 . get loop count p125: loop p125 .0 mov es.segaddr+2 .atone .al . pop cx call p120 push cx mov cx.offset copyr call p220 . save port value or al. wait around pop cx call p120 ret p100 endp p120 proc near . beep the speaker once push ax push cx mov al. this program's prior location mov ax. terminate . turn speaker on mov cx. start of transient code mov dx.es:[di] . is it this program? cmp cx. no . point to prior program segment mov di.20000 p106: loop p106 .61h push ax . get prior code segment mov es.es:[di] .3 out 61h. high part in al. setup for sound mov al. set state & alarm int 20h .whozat jnz p160 .al .0 out 42h.offset signature mov cx.al . print copyright mov ax.al . low part mov al.aleng .al . wait around pop ax .

get it cmp bl.es:[di+2] .offset jumpval mov di.offset msg3 .[si] . turn clock off push dx mov dx.ax . init hours mov bh. is it a minus? jnz p204 . no mov es:[state]. point to timer interrupt mov bx.0 mov di. it's zero p203: inc si .'-' . last byte of resident portion inc dx int 27h .0 . and cs mov bx. terminate p200 proc near .0ffffh .ax . set int 62h mov si. set interrupts push ds pop es call p200 .ax . get timer ip mov ax.0 mov es. point to command line mov ax. clear interrupts mov es:[di].bh . and cs mov [si].es:[di] .p160: mov di.0 mov ch. get length jcxz p210 . save prior ip mov [si+2]. turn clock on mov cl. set state & alarm mov si. point to int 62h mov ax. print msg call p220 pop dx jmp p206 .[si] . point to next char mov bl.segaddr+2 .intaddr .ax sti .bx .bx . segment 0 mov ax. : counter mov es:[state]. get current ds mov es:[di].offset p150 .ds . set state & alarm mov dx.bl .ds cli .offset p000 mov ax.80h .0 mov dh. set new timer interrupt mov es:[di+2].

24*60 jb p209 .2 .0ffffh . save hours mov ax. too high . and add latest digit pop dx pop cx p206: loop p203 .di .'0' jb p206 . second colon? jz p206 . add hours cmp ax. any time to set? jz p210 . print set msg call p220 p210: ret .'9' ja p206 .p204: cmp dh.offset msg2 .10 mul cx . no add ax. yes .can be a problem sub bl. seen 2nd colon? jz p206 .ignore seconds push cx push dx mov cx. yes .ignore seconds cmp bl.ax .':' . multiply current ax by 60 pop dx pop cx mov di. too low cmp bl.5 mov es:[acount].ax .0 jmp p206 p205: cmp bl. done yet? cmp di. save minutes past midnight mov ax.bx . ok mov dx. convert it to binary push cx push dx mov cx.ax .2 .'0' .60 mul cx . set alarm count mov dx.offset msg1 . multiply current value by 10 add ax. no inc dh cmp dh. print error message call p220 jmp p210 p209: mov es:[atime]. colon? jnz p205 .

13.13.must be from 00:00 to 23:59'.9 int 21h pop ax ret p220 endp copyr db 'Alarm .'$' msg2 db 'Resetting alarm time'.10.'$' msg3 db 'Turning clock display off'. print message push ax mov ah.10.'$' alarm endp cseg ends end alarm .10.13.10.'$' msg1 db 'Invalid time .p200 endp p220 proc near .Clock'.13.