It
is a sequence of programs which are hand coded and entered byte by
byte.
Disadvantages
*complicated
& time consuming
*chances
of error being hand coded and entered byte by byte
*difficult
to debug
*not
easily understandable & non user friendly
Assembler
Converts
mnemonics to their equivalent object code
Assembly
level programming (ALP)
Convert
object code to executable programming using linkers and loader
program.
Advantages
- Not complicated as machine language
- Coding function is done by assembler
- Chances of error less due to mnemonics are used
- Debugging is easier
- More user friendly &easy understandable
- Memory control is in hands of users
- Results are user friendly
- High flexibility than the machine language
Writing a
program in an assembler
- Use text editor and type the program listing prepared
- Check for typing error
- Save the program
- Now we can use it for assembling
- Common text editors are Norton’s editor, Turbo C, EDLIN etc….
- Assemblers are MASM, TASM, DOS assembler etc……
Entering
the program
- You can use same hand coded program in the masm with the syntax modifications
- For every assembly language program, the extension .ASM must be there
- Firstly enter the file name
- Then enter the code
- Example:
Addition
of two bytes
Assume
cs: CODE, DS: DATA
Data
segment
Opr1 dw 1234 h
Opr2 dw 0002 h
Result dw 01h dup (?)
Data
Code
ends
Segment
Mov ax, data
Mov ds, ax
Mov
ax, opr1
Mov
bx, opr2
Clc
Add
ax, bx
Mov
di, offset result
Mov
[di], ax
Mov
ah, 4ch
Int
21h
Code
Ends
End
start
Assembling
a program
- Above given code is saved and assembled by an assembler
- We have to give a valid file name. we it should give file name extension it automatically convert it
- When we enter it automatically convert it into a object code
- After generating the .LST ,.CRF,.OBJ
- Use it in linker
- After it produce an .EXE file
Debugging
- After creating the .EXE file we use DEBUG.COM for to debug and trouble-shooting
Programming
examples
Pgm1:
Write
a program for the addition of a series of 8-bit numbers. The series
contains 100 numbers
Assume
cs: CODE, DS: DATA
Data
segment
NUMLIST
52H, 23H,-
count
equ 100d
result
dw 01h dup (?)
data
ends
code
segment
org
200h
start: mov
ax, DATA
mov
ds, ax
mov
CX, COUNT
xor
ax, ax
xor
br, br
mov
si, offset numlist
again: mov
bl, [si]
add
ax, bx
inc
si
dec
cx
jnz
again
mov
di, offset result
mov
[di], ax
int
21h
code
ends
end
start
Pgm2:
Program
to find out the number of even and odd numbers from a given series of
16-bit hexadecimal numbers
Assume
cs: CODE, DS: DATA
Data
segment
list
dw 2357h, oa579h, 0c322h, 0c91eh, 0c000h, 0957h
count
equ 006h
data
ends
code
segment
start:
xor bx, bx
xor
dx, dx
mov
ax, data
mov
ds, ax
mov
cl, count
mov
si, offset list
again: mov
ax, [si]
ror
ax, 01
jc
odd
inc
bx
jmp
next
odd: inc
dx
next: add
si, 02
dec
cl
jnz
again
mov
ah, 4ch
INT
21H
code
ends
end
start
Pgm3
Write
a program to find out the number positive or negative
Assume
cs: CODE, DS: DATA
Data
segment
list
dw 2579h, 0a500h, 0c009h, 0159h, ob900h
count
equ 05h
data
ends
code
segment
start: xor
bx, bx
xor
dx, dx
mov
ax, data
mov
ds, ax
mov
cl, count
mov
si, offset list
again:
mov ax, [si]
shl
ax, 01
jc
neg
inc
bx
jmp
next
neg:
inc dx
next: add
si, 02
dec
cl
jnz
again
mov
ah, 4ch
int
21h
code
ends
end
start
Pgm4
Write
a program to perform a one byte BCD addition
Assume
cs: CODE, DS: DATA
Data
segment
opr1
equ 92h
opr2
equ 52h
result
db 02 dup (00)
data
ends
code
segment
start: mov
ax, data
mov
ds, ax
mov
bl, opr1
xor
al, al
mov
al, opr2
add
al, bl
daa
mov
result, al
jnc
msbo
inc
[result+1]
msbo: mov
ah, 4ch
int
21h
code
ends
end
start
0 comments:
Post a Comment