0% found this document useful (0 votes)
65 views7 pages

Application 3: Palindrome: Date of Performance: Date of Submission: Leader: Members

The program checks if a predefined string is a palindrome by copying the characters from the string to a second string in reverse order. It uses registers to store the string pointers and characters. It copies the characters, increments and decrements the pointers, and compares the original and reversed characters using CMP. If all characters match, it sets DX to 255, otherwise it sets DX to 0 before exiting. This determines if the original string is a palindrome by the value left in DX.

Uploaded by

John Rex Torres
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views7 pages

Application 3: Palindrome: Date of Performance: Date of Submission: Leader: Members

The program checks if a predefined string is a palindrome by copying the characters from the string to a second string in reverse order. It uses registers to store the string pointers and characters. It copies the characters, increments and decrements the pointers, and compares the original and reversed characters using CMP. If all characters match, it sets DX to 255, otherwise it sets DX to 0 before exiting. This determines if the original string is a palindrome by the value left in DX.

Uploaded by

John Rex Torres
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

APPLICATION 3: PALINDROME

RATING:

Date of Performance: OCTOBER 11, 2019

Date of Submission: OCTOBER 14, 2019

Leader: UGANIZA, JOHN DAVE


Members: CUSIPAG, KIMNER FERRER
BRONIO, LHYKA MAE
TOMAS, YANESSA ZAIRAH
ROXAS, CHRISTIAN
MANANGAN, FERNANDO JR.

ENGR. BERNARD BISUECOS


Instructor
SPECIFIC OBJECTIVES:

 To check whether the predefined string is a palindrome or not


 To understand how arrays are being accessed by the registers
 To know how jump and cmp commands are used in the program

DATA, RESULTS AND ANALYSIS

PROCEDURE:

Enter the program given


DATA SEGMENT
STR1 DB 'C','I','V','I','C'
STR2 DB 20 DUP (?)
DATA ENDS

CODE SEGMENT
START:
ASSUME CS: CODE, DS: DATA
MOV AX,DATA
MOV DS, AX
MOV AX, 00
MOV CL, 5
MOV CH, 5
LEA SI, STR1
ADD SI, 4
LEA DI, STR2
NEXT: MOV AL, [SI]
MOV [DI], AL
MOV BL, [DI]
INC DI
DEC SI
DEC CL
JNZ NEXT
MOV SI, 0
MOV DI, 5
BOT1: MOV AL, [SI]
MOV BL, [DI]
CMP AL, BL
JNE BOT2
INC SI
INC DI
DEC CH
JNZ BOT1
MOV DL, 255
JMP EXT
BOT2: MOV DL, 00
EXT: INT 3H
CODE ENDS
END START
Use (F7) to trace and execute every instruction:

INSTRUCTIONS AX BX CX DX SI DI
ITERATION 1
MOV AX,00 0000 0000 0000 0000 0000 0000
MOV CL, 5 0000 0000 0005 0000 0000 0000
MOV CH, 5 0000 0000 0505 0000 0000 0000
LEA SI, STR1 0000 0000 0505 0000 0000 0000
ADD SI, 4 0000 0000 0505 0000 0004 0000
LEA DI, STR2 0000 0000 0505 0000 0004 0005
MOV AL, [SI] 0043 0000 0505 0000 0004 0005
MOV [DI], AL 0043 0000 0505 0000 0004 0005
MOV BL, [DI] 0043 0043 0505 0000 0004 0005
INC DI 0043 0043 0505 0000 0004 0006
DEC SI 0043 0043 0505 0000 0003 0006
DEC CL 0043 0043 0504 0000 0003 0006
JNZ NEXT 0043 0043 0504 0000 0003 0006
ITERATION 2 AX BX CX DX SI DI
MOV AL, [SI] 0049 0043 0504 0000 0003 0006
MOV [DI], AL 0049 0043 0504 0000 0003 0006
MOV BL, [DI] 0049 0049 0504 0000 0003 0006
INC DI 0049 0049 0504 0000 0003 0007
DEC SI 0049 0049 0504 0000 0002 0007
DEC CL 0049 0049 0503 0000 0002 0007
JNZ NEXT 0049 0049 0503 0000 0002 0007
ITERATION 3 AX BX CX DX SI DI
MOV AL, [SI] 0056 0049 0503 0000 0002 0007
MOV [DI], AL 0056 0049 0503 0000 0002 0007
MOV BL, [DI] 0056 0056 0503 0000 0002 0007
INC DI 0056 0056 0503 0000 0002 0008
DEC SI 0056 0056 0503 0000 0001 0008
DEC CL 0056 0056 0502 0000 0001 0008
JNZ NEXT 0056 0056 0502 0000 0001 0008
ITERATION 4 AX BX CX DX SI DI
MOV AL, [SI] 0049 0056 0502 0000 0001 0008
MOV [DI], AL 0049 0056 0502 0000 0001 0008
MOV BL, [DI] 0049 0049 0502 0000 0001 0008
INC DI 0049 0049 0502 0000 0001 0009
DEC SI 0049 0049 0502 0000 0000 0009
DEC CL 0049 0049 0501 0000 0000 0009
JNZ NEXT 0049 0049 0501 0000 0000 0009
ITERATION 5 AX BX CX DX SI DI
MOV AL, [SI] 0043 0049 0501 0000 0000 0009
MOV [DI], AL 0043 0049 0501 0000 0000 0009
MOV BL, [DI] 0043 0043 0501 0000 0000 0009
INC DI 0043 0043 0501 0000 0000 000A
DEC SI 0043 0043 0501 0000 FFFF 000A
DEC CL 0043 0043 0500 0000 FFFF 000A
JNZ NEXT 0043 0043 0500 0000 FFFF 000A
MOV SI, 0 0043 0043 0500 0000 0000 000A
MOV DI, 5 0043 0043 0500 0000 0000 0005
ITERATION 6 AX BX CX DX SI DI
MOV AL, [SI] 0043 0043 0500 0000 0000 0005
MOV BL, [DI] 0043 0043 0500 0000 0000 0005
CMP AL, BL 0043 0043 0500 0000 0000 0005
JNE BOT2 0043 0043 0500 0000 0000 0005
INC SI 0043 0043 0500 0000 0001 0005
INC DI 0043 0043 0500 0000 0001 0006
DEC CH 0043 0043 0400 0000 0001 0006
JNZ BOT1 0043 0043 0400 0000 0001 0006
ITERATION 7 AX BX CX DX SI DI
MOV AL, [SI] 0049 0043 0400 0000 0001 0006
MOV BL, [DI] 0049 0049 0400 0000 0001 0006
CMP AL, BL 0049 0049 0400 0000 0001 0006
JNE BOT2 0049 0049 0400 0000 0001 0006
INC SI 0049 0049 0400 0000 0002 0006
INC DI 0049 0049 0400 0000 0002 0007
DEC CH 0049 0049 0300 0000 0002 0007
JNZ BOT1 0049 0049 0300 0000 0002 0007
ITERATION 8 AX BX CX DX SI DI
MOV AL, [SI] 0056 0049 0300 0000 0002 0007
MOV BL, [DI] 0056 0056 0300 0000 0002 0007
CMP AL, BL 0056 0056 0300 0000 0002 0007
JNE BOT2 0056 0056 0300 0000 0002 0007
INC SI 0056 0056 0300 0000 0003 0007
INC DI 0056 0056 0300 0000 0003 0008
DEC CH 0056 0056 0200 0000 0003 0008
JNZ BOT1 0056 0056 0200 0000 0003 0008
ITERATION 9 AX BX CX DX SI DI
MOV AL, [SI] 0049 0056 0200 0000 0003 0008
MOV BL, [DI] 0049 0049 0200 0000 0003 0008
CMP AL, BL 0049 0049 0200 0000 0003 0008
JNE BOT2 0049 0049 0200 0000 0003 0008
INC SI 0049 0049 0200 0000 0004 0008
INC DI 0049 0049 0200 0000 0004 0009
DEC CH 0049 0049 0100 0000 0004 0009
JNZ BOT1 0049 0049 0100 0000 0004 0009
ITERATION 10 AX BX CX DX SI DI
MOV AL, [SI] 0043 0049 0100 0000 0004 0009
MOV BL, [DI] 0043 0043 0100 0000 0004 0009
CMP AL, BL 0043 0043 0100 0000 0004 0009
JNE BOT2 0043 0043 0100 0000 0004 0009
INC SI 0043 0043 0100 0000 0005 0009
INC DI 0043 0043 0100 0000 0005 000A
DEC CH 0043 0043 0000 0000 0005 000A
JNZ BOT1 0043 0043 0000 0000 0005 000A
MOV DL, 255 0043 0043 0000 00FF 0005 000A
JMP EXT 0043 0043 0000 00FF 0005 000A
SUMMARY

The program is about determining if the predefined string is a palindrome or not.


The goal of this program is to contain FFH if the string is a palindrome otherwise, 00H. In
this program, the predefined string is loaded to the SI register. Since the predefined string
has five characters, the pointer of the SI will start at 4. After setting the pointer, the values
will be copied from top to bottom and will be stored in the DI register from bottom to top.

After copying the values, the cmp command will be used to check if the string is a
palindrome. The pointer of the SI register will be set to zero and the pointer of the DI
register will be set to 5. The values will be compared, and if true, both registers will
increment by 1 until 4 otherwise, it will stop and will copy 00H in the register instead.

CONCLUSION

You might also like