num dw dup 5(?)
This is a peculiar syntax. Does this assemble at all?
The usual way to write this is num dw 5 dup (?)
, so putting the repetition count before the dup
operator.
About the problem with printing the user's number for which you say in a comment:
Thanks I've added the $ and it's printing now
I seriously doubt that what gets printed is the inputted number and nothing else, because you're using both DOS function 09h and DOS function 0Ah wrongly!
The DOS.BufferedInput function 0Ah expects to get from you a pointer in DS:DX
that points at a structure with a clearly defined layout.
The 1st byte must specify how big is the storage space that starts with the 3rd byte.
The 2nd byte is for DOS to inform you about how many bytes were inputted.
For more on this DOS function, read How buffered input works.
Next is an example that will allow inputting 5 characters. Why, will you ask, do I have to write 6 then? Well, DOS always appends a carriage return byte (13) to the inputted characters. Your count in the 1st byte must allow for this.
num db 6, 0, 6 dup (0)
Since the actual characters start at num + 2
, that will be the address that you need to pass to the DOS.PrintString function 09h.
byte 24h not found after 2000 bytes.
And then there's the small matter of $-terminating the characters. Simply replace the carriage return byte (13) by a $ character. The ASCII code for the $ character is 24h (36).
xor bx, bx
mov bl, [num+1] ; The count obtained from DOS
mov BYTE PTR [num+2+bx], '$'
mov dx, OFFSET num+2
mov ah, 09h
int 21h
before
num 6, 0, 0, 0, 0, 0, 0, 0,
input
2019
after
'2' '0' '1' '9' CR
num 6, 4, 50, 48, 49, 57, 13, 0
printing
'2' '0' '1' '9' '$'
num 6, 4, 50, 48, 49, 57, 36, 0
^
DX