Strange characters in the assembly?

I wrote the following code:

.386 .model small .stack 100h .data text db "Paper",0 .code start : lea dx , text mov ah , 9h int 21h mov ah , 4ch int 21h end start end 

the problem is that it shows strange characters with the correct sentence in the middle, what exactly is the problem?

+4
source share
1 answer
 ; your code start: mov ax, @data mov ds, ax ;your code 

I think this will solve your problem. Dos, when loading a .com file, sets cs = ds = es . Not so, when loading the .exe cs format is indicated on your code, of course, but ds (and es ?) Are indicated on your PSP (program segment prefix), which is usually not located where your data lives ... You must configure ds (and es if you are going to use it).

"Why study the 16-bit build?" this is a good question. "Why study at a meeting at all?" this is another good question. Most likely, you will never write anything “serious” with him. But this allows you to find out what is happening “under the hood” in such a way that the HLL will not, and 16-bit allows you to understand the segmented memory model. 32-bit code is also segmented, but while the segments are “different,” they usually point to the same memory, and you can generally ignore “em” - the OS takes care of all this for you.

Also, some of us are crazy enough to think it's fun!

+3
source

Source: https://habr.com/ru/post/1486500/


All Articles