Skip to main content

A palindrome checker in 16-bit DOS assembly

A good morning to start off is to get this simple program working. This is an improvement of the previous palindrome checker posted. What can we benefit from this anyway? :)



; palindrome checker

start:
mov ah, 0ah
lea dx, strptr
int 21h

lea di, string
lea si, strlen
mov cl, [si]
xor ch, ch
mov bx, cx
lea si, string
shr cl, 1

check:
mov dl, [si]
mov dh, [di+bx-1]
cmp dl, dh
jne notpal
inc si
dec di

loop check

cmp dl, dh
je pal

notpal:
mov ah, 09h
lea dx, msg2
int 21h
int 20h

pal:
mov ah, 09h
lea dx, msg1
int 21h
int 20h

strptr label byte
maxlen db 49
strlen db ?
string db 50 dup ('$')
msg1 db '',10,'string is a palindrome!$'
msg2 db '',10,'string is not a palindrome!$'

“If God’s people which are called by His name, will humble themselves and pray, and seek His face, and turn from their wicked ways; then He will hear from heaven, and will forgive their sins, and will heal their land.” - 2 Chron 7:14

Comments

Popular posts from this blog

Architecture Complexity

Here are the items to consider: Coding to an interface Service Oriented Architecture Automated Testing Domain Driven Design Custom Data Access Layer Layered architecture Complexity is relatively equal the number of lines of code. Note that complexity is not bad. It must be justified.

Importance of daily meetings

Why are daily meetings important? Yes I know what you are thinking, to check if the schedule is on target, to spot showstoppers, roadblocks and whatnots. But aside from those, there are things that make daily meetings rewarding. Let’s face it, some people (including me) find it hard oftentimes to achieve a certain level of focus at work especially when multitasking is inevitable. Meetings will remind us of our commitments infront of our peers. Since most of us will be ashamed of not making any progress, it will trigger ourselves to do something about it. In my opinion, having daily meetings typically before the shift starts will help a lot of peers suffering from bad habits - procrastination. It is one way of invigorating those who have not found their way out yet. “Keep each other in the zone, what are teammates for?”