在装配奇怪的字符? [英] Weird characters in assembly?

查看:132
本文介绍了在装配奇怪的字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了下面code:

  .386
 .MODEL小
 .STACK 100H 。数据
    文字DB纸,0
 。code
  开始:  LEA DX,文字
  MOV啊,9H
  INT 21H  MOV啊,4路
  INT 21H  年底启动  结束

问题是,它显示了在中间右侧句子怪异字符,究竟是什么的问题?


解决方案

 ;您code
开始:
MOV AX,@data
MOV DS,AX
;你的code

我认为会解决你的问题。 DOS,加载一个.com文件时,设置 CS = DS = ES 。事实并非如此加载.exe格式时, CS 指向到code,当然,但 DS (和 ES ?)都指出你的PSP(程序段preFIX),这通常不是在您的数据存在...你必须设置 DS (和 ES 如果你打算使用它)自己。

为什么要学习16位汇编?是一个很好的问题。 为什么要学习汇编呢?是另外一个很好的问题。机会是你永远不会写什么严重的程度。但它可以让你学到什么在某种程度上的引擎盖下云的高级语言不会,16位可以让你了解分段内存模型。 32位code被分割了,但是同时段是不同,他们通常指向相同的内存,你通常可以忽略'时间 - 操作系统需要照顾所有你

此外,我们有些疯狂到认为这是有趣!

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 weird characters with the right sentence in the middle , what is exactly the problem ?

解决方案

; your code
start:
mov ax, @data
mov ds, ax
;your code

I think that'll solve your problem. Dos, when loading a .com file, sets cs = ds = es. Not so when loading an .exe format cs is pointed to your code, of course, but ds (and es?) are pointed to your PSP (Program Segment Prefix), which is typically not where your data lives... You have to set up ds (and es if you're going to use it) yourself.

"Why learn 16-bit assembly?" is a good question. "Why learn assembly at all?" is another good question. Chances are you'll never write anything "serious" with it. But it allows you to learn what goes on "under the hood" in a way that HLLs won't, and 16-bit allows you to understand the segmented memory model. 32-bit code is segmented, too, but while the segments are "different" they generally point to the same memory and you can generally ignore 'em - the OS takes care of all that for you.

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

这篇关于在装配奇怪的字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆