You are on page 1of 2

1.

compare two value and display character


include "emu8086.inc"
org 100h
mov al, 25 ; set al to 25.
mov bl, 10 ; set bl to 10. Output: n will be displayed on the
cmp al, bl ; compare al - bl. screen
je equal ; jump if al = bl (zf = 1).
putc 'n' ; if it gets here, then al <> bl,
jmp stop ; so print 'n', and jump to stop.
equal: ; if gets here,
putc 'y' ; then al = bl, so print 'y'.
stop:
ret
2. function of jump
org 100h
mov ax, 5 ; set ax to 5.
mov bx, 2 ; set bx to 2.
jmp calc ; go to 'calc'. The output is on AX(Al=07)
back: jmp stop ; go to 'stop'.
calc:
add ax, bx ; add bx to ax.
jmp back ; go 'back'.
stop:
ret

3. function of call
org 100h
call m1
mov ax, 2 output: the value of AX(Al=02)
ret ; return to operating system. the value of BX(Bl=05)
m1 proc
mov bx, 5
ret ; return to caller.
m1 endp
end
4. to display a single character use int 21h/ah/2h
org 100h
mov dl, 'b' ; move 'b' into dl register The output is b will be displayed on
mov ah, 2h ; function to print a character the screen
int 21h ; dos interrupt
endp

5. org 100h ; code starts at offset 100h


mov dx, offset message ; offset of message string terminating with $
mov ah, 09h ; function to display a string
int 21h ; dos interrupt The output is Hello world will be
endp displayed on the screen
message db "hello world $"
6. A program to find factorial

org 100h
mov ax, 05h
mov cx, ax The output is on AX(Al=78)
dec cx
back: mul cx
dec cx
jnz back
; results stored in ax
ret
7. org 100h
mov al, 1
mov bl, 2
call m2
call m2
call m2
call m2 The output is on AX(Al=10)
ret ; return to operating system.
m2 proc
mul bl ; ax = al * bl.
ret ; return to caller.
m2 endp
end
8. program to demonstrate rotate instruction

org 100h
stc ; set carry (cf=1).
mov al, 1ch Output: the value of AX(Al=1E)
; al = 00011100b
rcr al, 1
; al = 10001110b,
cf=0.
ret
9. org 100h
mov cx, 5
mov ax, cx Output: the value of AX(Al=0F)
dec cx
calc:add ax,cx
dec cx
jnz calc
ret

You might also like