如何在Linux的nasm x86程序集中复制阵列,并移植16位DOS代码? [英] How can i copy an array in nasm x86 assembly for Linux, porting 16-bit DOS code?
本文介绍了如何在Linux的nasm x86程序集中复制阵列,并移植16位DOS代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须编写一个程序,使用x86汇编程序将一个数组复制到另一个数组中
I have to write a program which copy an array in other array, using x86 assembler
原始代码是用8086处理器的MSDOS TASM编写的,但是我想使用i386处理器将其移植到Linux NASM
The original code is written in MSDOS' TASM for 8086 processor, but I want port this to Linux NASM using i386 processor
TASM中的代码是这样的:
The code in TASM is this:
.MODEL SMALL
.DATA
TABLE_A DB 10, 5, 1
TABLE_B DB 0, 0, 0
.CODE
MOV AX, SEG TABLE_B
MOV DS, AX
MOV SI, 0
LOOP:
MOV AL, TABLE_A[SI]
MOV TABLE_B[SI], AL
INC SI
CMP SI, 2
JBE LOOP
MOV AH, 4Ch
INT 21h
END
我正在尝试用nasm重写它,但我无法坐在正确的数组位置,类似于TABLE_A [SI]指令
I'm trying to rewrite this in nasm, but I don't get to sit in the correct array position, similar to TABLE_A[SI] instruction
我该怎么办?
推荐答案
nasm中的最终代码是这个
The final code in nasm is this
section .text
global _start
cpu 386
_start:
MOV ESI, TABLE_A
MOV EDI, TABLE_B
MOV CX, 3
COPY_LOOP:
MOV AL, [ESI]
MOV [EDI], AL
INC SI
INC DI
LOOP COPY_LOOP
MOV AX,1
INT 80h
section .data
TABLE_A DB 10, 5, 1
TABLE_B DB 0, 0, 0
这篇关于如何在Linux的nasm x86程序集中复制阵列,并移植16位DOS代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文