x86汇编 - 多模块编程(MASM / TASM) [英] x86 assembly - multimodule programming (MASM/TASM)

查看:679
本文介绍了x86汇编 - 多模块编程(MASM / TASM)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OK所以这里的code:

ok so here's the code:

assume cs:code, ds:data
data segment
  sname db 'Some Name','$'
  len equ $-sname
  ascii db 'a'-'A'

data ends
code segment
start:
  mov ax,data
  mov ds,ax

  cld
  lea si,sname

  do_this:
    lodsb

    cmp al,61h
    jae lowercase

    uppercase:
      cmp si,len
      je the_end
      jmp continue

    lowercase:
      mov bl,ascii
      sub ax,bx

      mov ds:[si-1],al
      cmp si,len
      je the_end

  continue:
  loop do_this

  the_end:
  mov ax,0000
  lea dx,sname
  mov ah,09h
  int 21h

  mov ax,4c00h
  int 21h

code ends
end start

基本上它只是将字符串'SNAME'变成大写的所有小写字母。
我的问题是,我怎么拆分此code到2个模块,其中一个将处理字符串印刷的一部分。具体来说,我想处理一个.ASM模块处理字符串转换为大写字母,以及一个:

Basically it just converts all lowercase letters of the string 'sname' into uppercase. My question is, how do i split this code into 2 modules, one of which will handle the string printing part. Specifically, i want an .asm module that handles the string conversion to uppercase, and one that handles :

  lea dx,sname
  mov ah,09h
  int 21h

我似乎无法找到这个任何好的教程,所以如果你可以点我朝着一些,这将是更AP preciated,如果没有,如何把2 .asm的模块组合在一起一个简单的例子(需要什么指令等),将是巨大的。

I can't seem to find any good tutorials on this so if you could point me towards some, it would be much appreciated, and if not, a simple example of how to put 2 .asm modules together ( what directives are required, etc ) , would be great.

推荐答案

好了,你只需将任何code和数据要移动到不同的汇编文件,并保持所有段的定义。然后你添加了一些声明与 EXTRN 公共

Well, you simply move whatever code and data you want to move to a different assembly file and keep all the segment definitions. And then you add a few declarations with extrn and public:

file1.asm:

file1.asm:

code segment

public convert
convert:
  ; code for the convert routine
  ret

code ends
end

file2.asm:

file2.asm:

code segment

extrn convert:near
start:
  ; some code
  call start
  ; some more code

code ends
end start

您可能需要正式定义子程序:

You might need to formally define subroutines:

convert proc
  ; code for the convert routine
  ret
convert endp

这篇关于x86汇编 - 多模块编程(MASM / TASM)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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