汇编语言代码 [英] Code of assembly language
本文介绍了汇编语言代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨..我刚刚开始学习汇编..我编写了代码以相反的顺序打印数字..但我想知道我们应该如何在地址中增加我已将每个数字存储在变量(DB)中,并且我从其地址进行调用...这是代码
Hi.. i have just started studying assembly.. i have written a code to print the numbers in reverse order.. but i want to know that how should we made increment in the address as i have stored every number in a variable (DB) and i m calling from its address... this is the code
title Printing numbers in reverse order.
.model small
.stack 100h
.data
num DB 0,1,2,3,4,5,6,7,8,9
result DB ?
.code
main proc
mov ax,@data
mov ds,ax
mov bx,offset result
mov al,num+9
add al,30h
mov [bx],al
mov al,num+8
add al,30h
mov [bx+1],al
mov al,num+7
add al,30h
mov [bx+2],al
mov al,num+6
add al,30h
mov [bx+3],al
mov al,num+5
add al,30h
mov [bx+4],al
mov al,num+4
add al,30h
mov [bx+5],al
mov al,num+3
add al,30h
mov [bx+6],al
mov al,num+2
add al,30h
mov[bx+7],al
mov al,num+1
add al,30h
mov [bx+8],al
mov al,num
add al,30h
mov [bx+9],al
mov cx,10
mov ah,2
mov dl,[bx] //What is the mistake i am incrementing
bx by 1 so y it's not taking the next
address to print
show: int 21h
inc bx
loop show
mov ah,4ch
int 21h
main endp
end main
推荐答案
您将标签放置在错误的位置,需要使用以下内容:
You have the label in the wrong place, you need something like:
show:
mov dl,[bx] //What is the mistake i am incrementing
// bx by 1 so y it''s not taking the next
// address to print
int 21h
inc bx
loop show
您还可以通过
将数字首先存储为字符
You could also store your numbers as characters in the first place by
num DB ''0'',''1'',''2'' ...
好吧....但是我将每个值都以相反的顺序存储在var结果中,现在我想显示var结果的每个值.我该怎么办.. ??
因为var结果的地址保存在bx中,所以我在增加bx,以便每次它都向我显示下一个值..还有其他方法可以做同样的事情吗?
如果是这样,则将var结果地址设为0001,则将值保存为
0001 ---------- 9
0002 ---------- 8
0003 ---------- 7
0004 ---------- 6
0005 ---------- 5
0006 ---------- 4
0007 ---------- 3
0008 ---------- 2
0009 ---------- 1
0010 ---------- 0
当我将bx递增1时,则y不在0002并打印8. 这里有什么错误.. ??
Okay thanks.... But i have stored every value in var result in reverse order, and now i want to show every value of var result. what should i do for this.. ??
as the address of var result is save in bx so i am incrementing bx so that it shows me the next value every time .. is there any other method to do the same thing..??
if it is like this that the var result address is let suppose 0001 then the values are saved like this
0001----------9
0002----------8
0003----------7
0004----------6
0005----------5
0006----------4
0007----------3
0008----------2
0009----------1
0010----------0
when i m incrementing bx by 1 then y it is not coming at 0002 and print 8.. ???
what is the mistake here..??
这篇关于汇编语言代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文