印刷阵列 - 让陌生的输出(EMU8086) [英] Printing array -- getting strange output (emu8086)

查看:226
本文介绍了印刷阵列 - 让陌生的输出(EMU8086)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是有关打印汇编语言8086阵列。
我用'EMU8086计划。

My question is related to printing an array in assembly 8086 language. I use 'emu8086' program.

下面这段看似正常,我(我是初学者),但结果我得到的是:
*,P000的替代:12345

The following piece seems fine to me (I'm a beginner), yet the result I get is: *P000, instead of: 12345.

  Main:

A DB 1,2,3,4,5 //my array

SUB SI, SI    //SI stands for counter and index here
LEA BX, A  

loop3:
MOV DX, [BX + SI] 

ADD DX, 30h //converting digit into character
MOV Ah, 2h
int 21h    //displaying the character in console window

INC SI
CMP SI, 5
JNE loop3             

end Main 

你能不能,请解释一下什么是错我的功能?
谢谢你在前进!

Can you, please, explain what's wrong with my function ? Thank you in advance !

推荐答案

该计划,在这个问题,是不完整的。有两个重要的线丢失:

The program, in the question, is incomplete. There are two vital lines missing:

    MOV AX, @DATA
    MOV DS, AX

<一个href=\"http://stackoverflow.com/questions/5330306/when-will-the-$c$c-under-data-segment-execute-in-this-$c$c\">Here我发现这些的目的。

下面列出,使我改变计划的事。

Below are listed the things that made me change the program.


  1. 我发现了一个组装好关于这个主题,在此基础上,分步实施方案,我可以分析code的每一行,并明白其中的含义。我觉得这个程序说明了一切。

  1. I found a good assembly program on this topic, based on which, step by step, I could analyze each line of code, and understand the meaning. I think this program explains everything.

有一些事情,我发现:

每个寄存器都有自己的目的,

所以,我的计划现在看起来是这样的:

So my program now looks this way:

    .MODEL SMALL
    .STACK 100H

    .DATA
    A DW 1, 2, 3, 4 ; it's my array

    .CODE   

    MAIN PROC

        MOV AX, @DATA
        MOV DS, AX


        LEA SI, A   ;set SI as offset address of A (of my array)
        MOV BX, 4   ;store the number of digits in BX register
        MOV CX, BX  ;CX is used as a loop counter

        LOOP1:

            MOV DX, [SI] ; Line 1
            ADD DX, 30h  ;convert digit to char and store in DX

            ;Print character stored in DX 
            MOV AH, 2h
            INT 21h

            ;Store in DX the ASCII code for 'space' character 
            MOV DX, 20h
            ;Print ' ' = space 
            INT 21h 


            ADD SI, 2 ;SI = SI + 2

        LOOP LOOP1 ; jump to label 'LOOP1' while CX != 0

    MAIN ENDP


  • 的含义线路1 的我发现这里

  • 这里我发现用什么指令打印字符,所有的解释。

  • ASCII表是有益的。

  • 了解 LOOP 指令。

    • The meaning for Line 1 I found here.
    • Here I found what instructions to use for printing characters, with all the explanations.
    • The ASCII Table was helpful.
    • About LOOP instruction.
    • 这篇关于印刷阵列 - 让陌生的输出(EMU8086)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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