I have this code for ASM that is supposed to replicate the scanf(); function.
But I have a feeling that there is something wrong with the code. Here is the code:
  _scanf:
  MOV DS, 0
  JMP .continue
  RET
.continue
  MOV AH, 00h
  INT 0x16
  CMP AH, 0Dh
  JE .backspace
  CMP AL, 0x0D
  JE .done
  CMP AL, 0x0A
  JE .done
  MOV CX, 1
  MOV BH, 0
  MOV AH, 09h
  INT 0x10
  MOV AH, 03h
  INT 0x10
  ADD DL, 1
  MOV AH, 02h
  INT 0x10
  MOV WORD [DX+DS], AL
  ADD DS, 1
  JMP .continue
.done:
  RET
.backspace:
  MOV WORD [DX+DS], 0x00
  MOV AH, 03h
  INT 0x10
  SUB DL, 1
  MOV AH, 02h
  INT 0x10
  MOV BH, 0
  MOV AL, 0x00
  MOV CX, 1
  MOV AH, 09h
  INT 0x10
  JMP .continue
Is this valid code? Or is the [DX+DS] opcode an invalid segment override?
Using compiler NASM with 16-bit code.
 
    