DEBUG
Enter: E address [list]
Used to enter data or instructions (as machine code) directly into Memory locations.
Example. First we'll change a single byte at location 0200 from whatever it was before to D2 :
-e 0200 d2
This next example shows that either single(') or double(") quote marks are acceptable for entering ASCII data. By allowing both forms, entry strings can be created to include either type of quote mark as data:
-e 200 'An "ASCII-Z string" is always followed by '
-e 22a "a zero-byte ('00h')." 0
Now we'll examine a string of 11 hex bytes you can enter into Memory at locations CS:0100 and following:
-e 100 B4 09 BA 0B 01 CD 21 B4 00 CD 21
To view the content of memmory location frome 2010 is
-e 2010 (enter key ) space space ......
------------------------x
Write an ALP to add two16 bit numbers.
Input:
n0 -->stored in 0200 ,n1---> 0201 and n2---> 0202,n3---. 0203
Output:
sum; n1n0+ n3n2---->AX
carry--->BX
a100
mov ax,[200]
mov bx,00
add ax,[202]
jnc 10d
inc bx
hlt
q
------------------------------ -x
Write an ALP to find factorial of a number
Input : Number --->AX
Output:
Factorial ---->AX
a100
MOV AX, 05
MOV CX, AX
DEC CX
JZ 10c
MUL CX
Jmp 105
HLT
q
------------------------------ --------x
an example of how to read the time from a computer's "real time clock" (RTC)
rtc available in port no.71. If port 70 is 04---> port 71 loaded Hrs, :70--. 02: 71---.>minuts: 70---> and 00--->seconds
output :
hr:min--->BX
sec ---->CH
a100
Mov al,04
Out 70,al
In al,71
Mov bh,al
Mov al,02
Out 70,al
In al,71
Mov bl,al
Mov al,00
Out 70,al
In al,71
Mov ch,al
Hlt
q
-------------------------x
Display strings in monitor using dos function 21h
a100
jmp 126 ; Jump over data that follows:
db 0d,0a,"This is my first DEBUG program!"
db 0d,0a,"$"; End of string marker above: "$"=24h
mov ah,9 ; Function 09 of Int 21h:
mov dx,102 ; DS:DX -> $-terminated string.
int 21 ; Write String to STD Output.
mov ah,0 ; Function 00 of Int 21h:
int 21 ; Terminate Program.
q
--------------------x
32-bit subtraction of 2 32 bit numbers X and Y that are stored in the
memory as
– X = (203)(:202)(:201)(:200)
– Y = (:303)(:302)(:301)(:300)
• The result X - Y to be stored where X is saved in the memory
a100e
MOV SI, 200
MOV DI, 300
MOV AX, [SI]
SUB AX, [DI]
MOV [SI], AX ;save the LS word of result
MOV AX, [SI] +2
SBB AX, [DI]+2
MOV [SI] +2, AX
hlt
q
---------------x
Write a program that calculates the average of five temperatures and writes
the result in AX
Data at 1030 -à 0d, f6,13,0e, ee : +13,-10,+19,+14,-18
a100
MOV CX,5 ;LOAD COUNTER
SUB BX,BX ;CLEAR BX, USED AS ACCUMULATOR
MOV SI,0130 ;load pointer
MOV AL,[SI] ;MOVE BYTE INTO AL
CBW ;SIGN EXTEND INTO AX
ADD BX,AX ;ADD TO BX
INC SI ; INCREMENT POINTER
DEC CX ;decrement counter
JNZ 0108 ;LOOP IF NOT FINISHED
MOV AL,5 ;MOVE COUNT TO AL
CBW ;SIGN EXTEND INTO AX
MOV CX,AX ;SAVE DENOMINATOR IN CX
MOV AX,BX ;MOVE SUM TO AX
CWD ;SIGN EXTEND THE SUM
IDIV CX ;FIND THE AVERAGE
Q
For entering data ,
e 1030 0d f6 13 0e ee
exercises
1) Write an ALP to add / two 64 bit numbers.
2) Write an ALP to check if the given number is even or odd.
3)Write an ALP to find the smallest of ‘N’ 8 bit numbers and display the result.
4) Write an ALP to sort the given set of 16 bit unsigned integers in ascending order
using bubble sort algorithm.
No comments:
Post a Comment