Sie sind auf Seite 1von 5

.

model small
.data
src db 15h,16h,17h,18h,19h
count db 05h

.code
mov ax,@data ;initialize data segment
mov ds,ax
mov es,ax ;initialize extra segment

lea si,src ;si to point source block


mov cl,count ;initialize counter

mov dh,cl ;initialize counter


dec cl ;decreament counter
up1: inc si ;making si to point to last number in block
dec cl
jnz up1

mov bl,count ;loading bl with count


sub bl,03h ;subtract overlapping bytes
mov di,si ;making di point to exceeding bytes from
up2: inc di ;last number in source block
dec bl
jnz up2

mov cl,count ;initialize counter


mov ch,00h ;making cx as counter by loading 00h in ch
std
rep movsb ;string
;transfering data in reverse order

inc di ;making di point to initial number in transfered


block

up4: mov bl,[di] ;moving content of address stored in di


mov ch,02h ;count of digits to be displayed
mov cl,04h ;count of digits to be rolled
up5: rol bl,cl ;roll bl so that MSB comes to LSB
mov dl,bl ;load dl with data to be displayed
and dl,0fh ;ANDing to get only LSB
cmp dl,09h ;check if digit is 0-9 or letter A-F
jbe down ;if letter add 37h else only 30h
add dl,07h
down: add dl,30h
mov ah,02h ;Funcion 02 under INT 21H
int 21h
dec ch ;jump if displaying digits in number is not overed
jnz up5

mov dl,' ' ;Displaying void space


mov ah,02h ;Funcion 02 under INT 21H
int 21h
inc di ;incrementing di
dec dh ;decrementing dh
jnz up4 ;jump if all numbers in destinatio block not
displayed

mov ah,4ch ;normal termination to DOS prompt


int 21h

end

str copy
DATA SEGMENT
STR1 DB "ENTER YOUR STRING HERE ->$"
STR2 DB "YOUR STRING IS ->$"
STR3 DB "COPIED STRING IS ->$"
INSTR1 DB 20 DUP("$")
CSTR DB 20 DUP("$")
NEWLINE DB 10,13,"$"
N DB ?
S DB ?

DATA ENDS

CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:

MOV AX,DATA
MOV DS,AX

LEA SI,INSTR1

;GET STRING
MOV AH,09H
LEA DX,STR1
INT 21H

MOV AH,0AH
MOV DX,SI
INT 21H

MOV AH,09H
LEA DX,NEWLINE
INT 21H

;PRINT THE STRING

MOV AH,09H
LEA DX,STR2
INT 21H

MOV AH,09H
LEA DX,INSTR1+2
INT 21H

MOV AH,09H
LEA DX,NEWLINE
INT 21H

;PRINT THE COPIED STRING

MOV AH,09H
LEA DX,STR3
INT 21H

MOV CL,INSTR1+1
ADD CL,1
ADD SI,2

LEA DI,CSTR

L1:
MOV BL,BYTE PTR[SI]
MOV BYTE PTR[DI],BL

INC SI
INC DI
CMP BYTE PTR[SI],"$"
JNE L1

MOV AH,09H
LEA DX,NEWLINE
INT 21H

MOV AH,09H
LEA DX,CSTR
INT 21H

MOV AH,09H
LEA DX,NEWLINE
INT 21H

MOV AH,4CH
INT 21H

CODE ENDS
END START

palindrome
DATA SEGMENT

BLOCK1 DB 'MALAYALAM'
MSG1 DB "IT IS PALINDROME $"
MSG2 DB "IT IS NOT PALINDROME $"
PAL DB 00H

DATA ENDS
PRINT MACRO MSG

MOV AH,09H
LEA DX,MSG
INT 21H
INT 3H

ENDM

EXTRA SEGMENT

BLOCK2 DB 9 DUP(?)
EXTRA ENDS

CODE SEGMENT
ASSUME CS:CODE,DS:DATA,ES:EXTRA
START: MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
LEA SI,BLOCK1
LEA DI,BLOCK2+8
MOV CX,00009H
BACK: CLD
LODSB
STD
STOSB
LOOP BACK
LEA SI,BLOCK1
LEA DI,BLOCK2
MOV CX,0009H
CLD
REPZ CMPSB
JNZ SKIP
PRINT MSG1
SKIP: PRINT MSG2
CODE ENDS
END START

pg 83 1.

DATA SEGMENT
A DW 1,2,3,4,5,6,7,8,9,10
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA SI,A
MOV DX,0000
MOV BL,02
MOV CL,10
L1:MOV AX,WORD PTR[SI]
DIV BL
CMP AH,00
JNZ L2
INC DH
JMP L3
L2:INC DL
L3:
ADD SI,2
DEC CL
CMP CL,00
JNZ L1
MOV AH,4CH
INT 21H
CODE ENDS
END START