Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

HELP PLS

feironfeiron Posts: 1Member
can you help me with this program ?
it dont work correct,
output must be number of words which numbers of operatrs (+-*/)=2*(numbers of small characters)
[code].MODEL small
.STACK 100h
.DATA
oz DB "Zadaj retazec:",10,13,"$"
retazec DB "Zadaj retazec : $"
male_znaky DB 0
operatory DB 0
vyhovujuce_slova DB 0
text DB 10,13,"Pocet slov : $"
.CODE


start:

mov ax, @data
mov ds, ax
mov dx,OFFSET oz
int 21h
lea dx, retazec ; nacitanie retazca
mov ah, 0Ah
int 21h

lea bx, retazec
xor cx, cx
mov cl, [bx+1]
mov si, bx
add si, 2

main_loop:

cmp WORD PTR [si], 20h ; medzera = nove slovo
je kontrola

cmp WORD PTR [si], 61h ; kontrola, ci sa jedna o male pismeno
jl operator
cmp WORD PTR [si], 7Ah
jg operator

inc male_znaky
jmp dalsi_znak

operator:

cmp WORD PTR [si], 2Ah ; kontrola, ci sa jedna o operator
jl dalsi_znak
cmp WORD PTR [si], 2Fh
jg dalsi_znak

inc operatory
jmp dalsi_znak

kontrola: ; vyhovuje podmienka (operatory = 2 * male_znaky) ?

call skontroluj


dalsi_znak:

inc si
loop main_loop

call skontroluj

koniec:

mov ah,09h
mov dx,offset text
int 21h
mov ah,vyhovujuce_slova
mov ax, 4C00h
int 21h





skontroluj PROC

mov al, male_znaky
mov ah, 2
mul ah
cmp al, operatory
jne zmaz

inc vyhovujuce_slova

zmaz:

mov male_znaky, 0
mov operatory, 0

ret 0

skontroluj ENDP




END start[/code]

Comments

  • SimplicusSimplicus Posts: 2Member
    Hello,

    First problem is that the first call to int 21h is made with the function number set to the high byte of AX (the address of the data segment.) you must set AH to 09h if you want to display a string.

    in the second call to int 21h, you have ah set to 0Ah; this is the function for string input, but the string 'retazec,' which this call references, is not set up as a string buffer for the 0Ah function. int 21h, function 0Ah expects a buffer: the first byte of which must be the length of the buffer, the second byte of which will be stuffed by teh interrupt with the number of bytes read (minus the final carriage return char.)

    I am having trouble understanding exactly what it is that your program is supposed to be doing, but I think if you do some more reseach into the interrupt functions, you will make better progress.

    Don't worry, Assembly language is tought at the beginning; just stick with it.

    Simplicus.
Sign In or Register to comment.