Assembly Language Example Programs

Only available on StudyMode
  • Topic: Trigraph, Gh, X86 assembly language
  • Pages : 30 (1874 words )
  • Download(s) : 681
  • Published : February 8, 2013
Open Document
Text Preview
(1)
.model small
.stack 100h
.data

dis1 db "Enter First Character:$"
dis2 db "Enter Second Character:$"
nme db "ASSEMBLY$"

.code
start:
mov ax, @data
mov ds, ax

mov ah, 9h
lea dx, dis1
int 21h

mov ah, 1h
int 21h

mov bl, al

mov ah, 2h
mov dl, 0ah
int 21h

mov dl, 0dh
int 21h

mov ah, 9h
lea dx, dis2
int 21h

mov ah, 1h
int 21h

mov bh, al

mov ah, 2h
mov dl, 0ah
int 21h

mov dl, 0dh
int 21h

mov ah, 2h
mov dl, bl
int 21h
int 21h
int 21h
int 21h
int 21h
int 21h
int 21h
int 21h
int 21h
int 21h

mov ah, 2h
mov dl, 0ah
int 21h

mov dl, 0dh
int 21h

mov dl, bl
int 21h

mov ah, 9h
lea dx, nme
int 21h

mov ah, 2h
mov dl, bh
int 21h

mov ah, 2h
mov dl, 0ah
int 21h

mov dl, 0dh
int 21h

mov ah, 2h
mov dl, bh
int 21h
int 21h
int 21h
int 21h
int 21h
int 21h
int 21h
int 21h
int 21h
int 21h

mov ah, 4ch
int 21h

end start

(2)
.model small
.stack 100h
.data

ch0 db "Corresponding Letter for Color$"
ch1 db 0ah, 0dh,"A. Blue$"
ch2 db 0ah, 0dh, "B. Yellow$"
ch3 db 0ah, 0dh, "C. Red$"
selection db 0ah, 0dh, "Enter Chosen Letter of Color: $"
void db "Invalid Selection of Choices!$"
nam db "ASSEMBLY$"

.code
start:
mov ax, @data
mov ds, ax

mov ah, 9h
lea dx, ch0
int 21h

lea dx, ch1
int 21h

lea dx, ch2
int 21h

lea dx, ch3
int 21h

lea dx, selection
int 21h

mov ah, 1h
int 21h

mov cl, al

cmp cl, 'a'
je blue

cmp cl, 'b'
je yellow

cmp cl, 'c'
je red

cmp cl, 'A'
je blue

cmp cl, 'B'
je yellow

cmp cl, 'C'
je red

mov ah, 2h
mov dl, 0ah
int 21h

mov dl, 0dh
int 21h

mov ah, 9h
lea dx, void
int 21h

jmp ext

blue:
mov ah, 2h
mov dl, 0ah
int 21h

mov dl, 0dh
int 21h

mov ah, 9h
mov bl, 1
mov cx, 8
int 10h

lea dx, nam
int 21h

jmp ext

yellow:
mov ah, 2h
mov dl, 0ah
int 21h

mov dl, 0dh
int 21h

mov ah, 9h
mov bl, 6
mov cx, 8
int 10h

lea dx, nam
int 21h

jmp ext

red:
mov ah, 2h
mov dl, 0ah
int 21h

mov dl, 0dh
int 21h

mov ah, 9h
mov bl, 4
mov cx, 8
int 10h

lea dx, nam
int 21h

jmp ext

ext:

mov ah, 4ch
int 21h

end start

3)
.model small
.stack 100h
.data
string db "JILLYN$"
string1 db "ELLA$"
string2 db "CHRISTIAN$"
string3 db "OLIVER$"
.code
.code
start:

mov ax,@data
mov ds,ax

mov ah,9h
mov bl,9
mov cx,6
int 10h

lea dx,string
int 21h

mov ah,2h
mov dl,0ah
int 21h

mov dl,0dh
int 21h

mov ah,9h
mov bl,5
mov cx,4
int 10h

lea dx,string1
int 21h

mov ah,2h
mov dl,0ah
int 21h

mov dl,0dh
int 21h

mov ah,9h
mov bl,4
mov cx,9
int 10h

lea dx,string2
int 21h

mov ah,2h
mov dl,0ah
int 21h

mov dl,0dh
int 21h

mov ah,9h
mov bl,6
mov cx,6
int 10h

lea dx,string3
int 21h

mov ah,4ch
int 21h

end start

(4)
.model small
.stack 100
.data
string db 0ah,0dh,"PRESS:$"
string1 db 0ah,0dh,"Assembly$"
string2 db 0ah,0dh,"Computer organization$"
string3 db 0ah,0dh,"Computer Organization and Assembly$"

.code
start:

mov ax,@data
mov ds, ax

mov ah, 9h
lea dx, string
int 21h

mov ah,1h
int 21h

mov bl,al

cmp al,'1'
je re

cmp al,'2'
je re1

cmp al,'3'
je re2

cmp al,'4'
je exit

re:
mov ah,9h
lea dx,string1
int 21h

mov ah, 9h
lea dx, string
int 21h
tracking img