data segment
S db 20 dup('$')
T db 'true$'
F db 'false$'
A db 'Wabbit$'
ends
stack segment
dw 128 dup(0)
pile:
ends
code segment
start:
mov ax, data
mov ds, ax
mov es, ax
mov dx,offset S
mov ah,10
int 21h
mov cl,S[1]
mov ch,0
mov dx,offset S
add dx,2
mov ah,9
int 21h
mov sp,pile
mov si, 5
mov bp,sp
for1: mov al,A[si]
mov ah,0
push ax
dec si
cmp si,0
jge for1
mov bp,sp
add bp,12
mov si,2
for:
sub bp,2
mov bx,[bp]
mov ax,0
mov al,S[si]
mov ah,0
cmp bx,ax
jne exit
inc si
loop for
mov dx , offset T
mov ah,9
int 21h
jmp endd
exit:
mov dx,offset F
mov ah,9
int 21h
endd:
ends
end start
mov ax, 4c00h ; exit to operating system.
int 21h
ends
end start ; set entry point and stop the assembler.
That is my code.
This is the question:
Write an 8086 assembly program that takes from the user a string S of size 20 and determines whether the content of S is found on the top of a given stack of words (2 bytes) already defined and filled with the values shown below:
Example: let S1="Wabbit" entered by the user and the content of the stack is given above, the program will display "True" and S2="Exam", the program will display "False". Remember the content of stack is fixed always "Wabbit", however the content of S changes.
Also I have 'false', why?
I try to know the problem by running step by step so when I do pop first I have 74h the value of "W" but when I put the value of "W" from the string S it gives 57h. Why?