我是在编写汇编程序还是NASM? [英] Am I Writing Assembly Or NASM?

查看:90
本文介绍了我是在编写汇编程序还是NASM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我受够了.我一直在尝试掌握汇编语言已有一段时间,但是我觉得我正在针对我的编译器而不是一种语言进行编码.

I'm fed up with this. I've been trying to just get a grip on assembly for awhile, but I feel like I'm coding towards my compiler rather than a language.

我一直在使用本教程,到目前为止,给我地狱.我正在使用NASM,这可能是问题所在,但我认为它是最受欢迎的一种.我只是试图学习最一般的汇编形式,所以我决定学习x86.我一直遇到愚蠢的错误,例如无法增加变量.这是最新的一种:无法使用div.

I've been using this tutorial, and so far it's giving me hell. I'm using NASM, which may be the problem, but I figured it was the most popular one. I'm simply trying to learn the most general form of assembly, so I decided to learn x86. I keep running into stupid errors, like not being able to increment a variable. Here's the latest one: not being able to use div.

mov bx, 0;
mov cx, 0;
jmp start;
 start:
 inc cx;
 mov ax, cx;
 div 3; <-- invalid combination of opcode and operand
 cmp ah,0;
 jz totalvalue;
 mov ax, cx;
 div 5; <-- invalid combination of opcode and operand
 cmp ah, 0;
 jz totalvalue;
 cmp cx, 1000;
 jz end;

 totalvalue:
 add bx,cx;
 jmp start;

jmp end;
 end:
   mov ah,4ch;
   mov al,00;
   int 21h;

我应该更换编译器吗?似乎划分应该是标准的.我是否需要阅读两个教程(一个在NASM上,一个在x86上?).关于此问题有任何具体帮助吗?

Should I change compilers? It seems like division should be standard. Do I need to read two tutorials (one on NASM, and one on x86?). Any specific help on this problem?

推荐答案

与其他语言一样,关于汇编的事情之一是它部分地由汇编程序定义. "div 5"对我来说似乎很奇怪-但是我使用MASM学习了汇编语言,该语法具有不同的语法.根据本教程中的注释,看起来该教程使用的汇编程序为指令提供了一些隐式"操作数,而NASM没有,并且期望div指令采用Intel语法.

One of the things about assembly, like any other language, is that it is, in part, defined by the assembler. That "div 5" seems awfully strange to me - but I learned assembly using MASM, which has a different syntax. Based on the comments in the tutorial, it looks like the assembler used for that tutorial has some "implied" operands for the instruction, whereas NASM does not, and expects the Intel syntax for the div instruction.

恕我直言,使用NASM将为您提供最好的服务,但您可以获取特定于NASM或适用于纯"英特尔语法的教程.对于英特尔来说,组装艺术本书是一个很好的资源.语法.

IMHO, you'll be best served by using NASM, but getting a tutorial that's either NASM-specific, or geared to the 'pure' Intel syntax. The Art of Assembly book is a good resource for the Intel syntax.

(如果以上链接失败,请尝试,即上面链接的前进位置)

(edit: if the link above fails, try this, which is where the link above forwards)

这篇关于我是在编写汇编程序还是NASM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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