-2
.model small
.stack 100h
.data
Var db ‘100$’

.code
main proc

mov ax , @data
mov ds , ax 
mov bx , offset var


Mov ah, 3fh
Int21h
cmp [var], bl
Je l1
Jmp exit


exit:
mov ax, 4c00h
int 21h

main endp
end main
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • 1
    `Int21h` will define a label with that name; you probably meant `int 21h`, to run the machine instruction `int` with operand `21h`. Also, this isn't [webassembly] in JavaScript- don't add random tags. – Peter Cordes Jun 01 '21 at 21:00

1 Answers1

0
Mov ah, 3fh
Int21h

This code reads from a file, but none has been opened! This obviously must fail.

I suggest you use the DOS.BufferedInput function 0Ah. Read all about it here.

Afterwards you should use a loop to compare the individual characters of the inputted string with the string that you have in your var (4 characters).

Sep Roland
  • 33,889
  • 7
  • 43
  • 76
  • If OP wants to use [Int 21/AH=3Fh](http://www.ctyme.com/intr/rb-2783.htm) to get the **input string** they probably want to get it from **standard input** (keyboard) which is always opened. This requires `MOV BX,0`, `MOV CX,InputStringSize` and `MOV DX,offset InputString` before `INT 21h` . – vitsoft Jun 02 '21 at 10:33
  • @vitsoft [The post that I linked to in my answer](https://stackoverflow.com/questions/47379024/how-buffered-input-works) has a chapter about this DOS.ReadDevice function 3Fh. Nonetheless I would not advice newbie programmers to use it. They would better stick with the easier function 0Ah. – Sep Roland Jun 02 '21 at 15:03
  • 1
    Sure, your resorce is very informative and well elaborated. I always wonder why so many beginners start with obsolete 16bit assembly, mostly run in emulators. – vitsoft Jun 02 '21 at 19:31