Hello, welcome
When you turn your computer on, processor is set to work on 'real' mode, this means 16 bits, the one that ms-dos works by default. So, we can code to change processor mode to work on 'protected' mode, this means 32 bits (windows and linux) and we can change to 'long' mode, this means 64 bits (windows and linux). I'm not talking that ms-dos can't work with 32 or 64 bits, yes, it can, of course, if hardwired. Some processor instructions need priviledge to be used on 32 bits per example while on ms-dos not. An example is 'in' and 'out' instructions. You also have other modes like 'virtual', ..., but not the subject.
Your code use 'int 21h', this means that you need create a program to work on ms-dos because ms-dos offers to us programmers these routines (think like library or dll on windows side). Again, you have used on your program the function (routine) 4ch, this is an end routine or on other words, end my program and give control back to O.S.
By this, you need create an .exe file instead of .com file because .com program use int 20h as an end function.
Said this, and going back to past, a .com program is by default done to little programs, by default a mix of data and code. We have 16 bits of address space, this means that our program can have a size of 65535 bytes, or 64k. When we need more space to our program, we need more memory addresses. On that time each 'segment' can hold 64k bytes, so we need more segments inside our program if our program grow and switch between these segments to access data or code. On 32 bits each segment can hold 4gb (flat model), so we can forget about segments and offsets if our program size is below 4gb.
When ms-dos loaded a .com program it created on memory a PSP. This PSP need a size of 100h bytes on memory loaded before our program.( you can use org 100h, or stack 100h, ... ).
Your example have code and data segment, you can choose to mix both into only one segment and create a .com file (change ms-dos 'end' function properly). You can create an .exe file and set segments by using some registers segment (.model directive).
Have a lot of examples on old board and inside this new board on ms-dos section, enjoy.