首页 \ 问答 \ 英特尔8086 DOS组件应使用什么代码骨架?(What code skeleton should I use for Intel 8086 DOS assembly?)

英特尔8086 DOS组件应使用什么代码骨架?(What code skeleton should I use for Intel 8086 DOS assembly?)

学习了英特尔8080架构后,我正在尝试学习英特尔8086以及这里的程序如何布局。 就目前而言,甚至在查看基本的例子以及更糟的是,我无法区分两种编写8086代码的差异,我曾经偶然发现过。 也就是说,有时我会看到:

.model small
.stack 100h
.code

start:

mov dl, ‘a’ ; store ascii code of ‘a’ in dl
mov ah, 2h ; ms-dos character output function
int 21h ; displays character in dl register
mov ax, 4c00h ; return to ms-dos
int 21h

end start

虽然我也发现:

Progr           segment
                assume  cs:Progr, ds:dataSeg, ss:stackSeg

start:          mov     ax,dataSeg
                mov     ds,ax
                mov     ax,stackSeg
                mov     ss,ax
                mov     sp,offset top


            mov     ah,4ch
            mov     al,0
            int     21h
Progr           ends

dataSeg            segment

dataSeg            ends

stackSeg          segment
                dw    100h dup(0)
top     Label word
stackSeg          ends

end start

很明显,我知道这两者做了很不同的事情,但让我困惑的是一般语法的差异。 在后者中,我们有一些“段假定”,而在前者中,它只是.model,.stack和.code(有时来自我发现的.data)。 有什么区别吗? 我可以选择哪一个更适合我? 前者看起来更容易理解和清晰,但我可以用它来代替后者吗?


Having learned Intel 8080 structure, I'm now trying to learn Intel 8086 and how the programs here are layed out. For now, it's quite intimidating even looking at the basic examples and what's worse, I can't get the difference between two ways of writing code for 8086 I've stumbled upon. Namely, sometimes i see:

.model small
.stack 100h
.code

start:

mov dl, ‘a’ ; store ascii code of ‘a’ in dl
mov ah, 2h ; ms-dos character output function
int 21h ; displays character in dl register
mov ax, 4c00h ; return to ms-dos
int 21h

end start

While I also found:

Progr           segment
                assume  cs:Progr, ds:dataSeg, ss:stackSeg

start:          mov     ax,dataSeg
                mov     ds,ax
                mov     ax,stackSeg
                mov     ss,ax
                mov     sp,offset top


            mov     ah,4ch
            mov     al,0
            int     21h
Progr           ends

dataSeg            segment

dataSeg            ends

stackSeg          segment
                dw    100h dup(0)
top     Label word
stackSeg          ends

end start

Obviously, I know that these two do very different things but what baffles me is how different the general syntax is. In the latter we have some "segment assume" while in the former it's just .model, .stack and .code (and sometimes .data, from what I found). Is there any difference? Can I just choose which one suits me better? The former looks a lot easier to understand and clearer but can I just use it instead of the latter?


原文:https://stackoverflow.com/questions/20265256
更新时间:2022-06-04 16:06

最满意答案

在Ruby中,引用一个局部变量和一个消息发送给隐含接收者而没有参数列表之间存在歧义。 这意味着

foo

可以是“取消引用局部变量”或“将消息发送给没有参数的self ”,即它可以等同于

binding.local_variable_get(:foo)

要么

self.foo()
# or
public_send(:foo)

这个歧义在解析时被解决。 当解析器遇到对foo的赋值时,它将从此处将foo视为局部变量,而不管赋值是否实际执行。 (这是解析器无法静态确定的,只要想一想if rand > 0.5 then foo = 42 end 。)

在编译语言中,这甚至不会编译。

编译语言没有这样的东西。 编译和解释是编译器或解释器(duh!)而不是语言的特征。 语言既不编译也不解释。 他们只是。

每种语言都可以通过编译器来实现,每种语言都可以通过解释器来实现。 大多数语言都有编译和解释实现(例如,C有GCC和Clang,它们是编译器,Cint和Cling是解释器,Haskell有GHC,它是编译器,Hugs是解释器)。

许多现代语言实现都在相同的实现中,或者处于不同的阶段(例如,YARV和MRuby将Ruby源代码编译为内部字节码,然后解释该字节码),或者在混合模式引擎中(例如HotSpot JVM都解释和编译JVM字节码,取决于哪个更有意义),或者两者兼有(例如Rubinius在第一阶段将Ruby源代码编译为Rubinius字节码,然后将该字节码编译为本地代码并解释它,具体取决于更有意义的内容)。

实际上, 所有现有的Ruby实现都已编译:YARV和MRuby编译为自己的内部字节码格式,Rubinius,MacRuby,MagLev和Topaz编译为自己的内部字节码格式,然后将其编译为本地代码,JRuby编译为JVM字节码JVM可能进一步编译或不编译),IronRuby编译为CIL字节码(VES可能进一步编译或不编译)。

Ruby以这种方式行事的事实是因为语言规范说明了这一点。 并不是因为Ruby被“解释”,因为事实上并非如此。 Ruby的唯一纯粹的解释实现是MRI和JRuby的早期版本,并且两者早已退役。


In Ruby, there is an ambiguity between referencing a local variable and a message send to the implicit receiver without an argument list. That means

foo

can either mean "dereference a local variable" or "send message foo to self without arguments", i.e. it could either be equivalent to

binding.local_variable_get(:foo)

or

self.foo()
# or
public_send(:foo)

This ambiguity is resolved at parse time. When the parser encounters an assignment to foo, it will, from that point on, treat foo as a local variable, regardless of whether or not the assignment actually gets executed. (That's something the parser cannot determine statically, after all. Just think about if rand > 0.5 then foo = 42 end.)

In a compiled language this wouldn't even compile.

There is no such thing as a compiled language. Compilation and interpretation are traits of the compiler or interpreter (duh!) not the language. Languages are neither compiled nor interpreted. They just are.

Every language can be implemented with a compiler and every language can be implemented with an interpreter. Most languages have both compiled and interpreted implementations (e.g. C has GCC and Clang, which are compilers, and Cint and Cling, which are interpreters, Haskell has GHC, which is a compiler, and Hugs, which is an interpreter).

Many modern language implementations have both in the same implementation, either in different phases (e.g. YARV and MRuby compile Ruby sourcecode to internal bytecode, and then interpret that bytecode), or in a mixed-mode engine (e.g. the HotSpot JVM both interprets and compiles JVM bytecode, depending on which makes more sense), or both (e.g. Rubinius compiles Ruby sourcecode to Rubinius bytecode in the first phase, and then both compiles that bytecode to native code and interprets it, depending on what makes more sense).

In fact, all currently existing Ruby implementations are compiled: YARV and MRuby compile to their own internal bytecode formats, Rubinius, MacRuby, MagLev and Topaz compile to their own internal bytecode formats, then compile that to native code, JRuby compiles to JVM bytecode (which the JVM may or may not compile further), IronRuby compiles to CIL bytecode (which the VES may or may not compile further).

The fact that Ruby behaves this way is because the language specification says so. Not because Ruby is "interpreted", because, actually, it is not. The only purely interpreted implementation of Ruby was MRI and very early versions of JRuby, and both have long since been retired.

相关问答

更多
  • 在Ruby中,引用一个局部变量和一个消息发送给隐含接收者而没有参数列表之间存在歧义。 这意味着 foo 可以是“取消引用局部变量”或“将消息发送给没有参数的self ”,即它可以等同于 binding.local_variable_get(:foo) 要么 self.foo() # or public_send(:foo) 这个歧义在解析时被解决。 当解析器遇到对foo的赋值时,它将从此处将foo视为局部变量,而不管赋值是否实际执行。 (这是解析器无法静态确定的,只要想一想if rand > 0.5 ...
  • 首先,你puti并直接调用puti a_var来得到a_var = value of a_var 。 在puti的主体中,Ruby只能看到puti的形式参数名称,它不能推断出实际的参数名称。 在像C / C ++这样的其他语言中,你可以使用宏来实现你的puti 。 这是另一个故事。 但是,可以借助Continuation实现put :a_var 。 在另一个问题“ 你能在Ruby中调用者的上下文中评估代码吗? ”时, Sony Santos提供了一个caller_binding实现来获取调用者的绑定(类似于 ...
  • 有remove_class_variable , remove_instance_variable和remove_const方法,但是当前没有等效的局部变量。 There are remove_class_variable, remove_instance_variable and remove_const methods but there is currently no equivalent for local variables.
  • 在Matlab(或Octave)中,您可以使用脚本或函数 。 如果你创建了一个名为objfun脚本,你有你正在寻找的东西。 只需使用objfun调用它,它将使用工作区变量x 。 该脚本被保存为objfun.m 。 功能不同。 他们可以有参数,但是这些参数是局部变量(只在函数中可用)。 如果你定义了一个函数,你必须用参数来调用它。 In Matlab (or Octave) you can use scripts or functions. If you create script called objfun ...
  • 这里有两个不同的注意事项。 VAR 如果没有var ,变量将是全局变量,除非它已在更广泛的范围内声明。 (在严格模式下 ,这将是一个错误而不是全局)。 在循环之前 你可能有for (var name…但是这使得更难发现var语句。 Douglas Crockford(The Good Parts的作者,在这里非常相关)主张在函数顶部声明所有局部变量,这样你就有了一个地方可以找到你的范围。 There are two different things to pay attention to here. var ...
  • 你的意思是错误或警告? 据我所知,它不是“严重”,因为字节码变量是在函数的开头声明的,所以如果你定义它一次或多次也没关系...... You mean Errors or Warnings? As far as I know it's not "Serious" because in bytecode variable is declared at the beginning of the function so it doesn't matter if you define it once or more ...
  • 你只需要做 if(true) { var a:int = 1; }else { a= 2; } 你的错误将会消失 yup, all you need to do is if(true) { var a:int = 1; }else { a= 2; } and your error will be gone
  • 你好像混淆了两个概念。 一种是定义变量,另一种是定义Hash键。 由于哈希在某个时刻是变量,因此必须对其进行定义。 defined?(a) # => nil a = { } # => {} defined?(a) # => "local-variable" a.key?('one') # => false a['one'] = 'hello' # => 'hello' a.key?('one') # => true 有些东西可以是关键,同时也是nil ,这是有效的。 哈希没有定义或未定义的概念。 ...
  • 在C中, const int c; 表示在程序运行期间无法修改c 。 但是, c在编译期间不是常量,不能在常量表达式中使用。 例如程序: const int MAX = 10; int a[MAX]; 不编译,而: #define MAX 10 int a[MAX]; 确实。 在C ++中, const变量是真正的编译时常量,因此使用#define原因可能较少。 需要#define一个例子是你需要在#if指令中使用常量。 In C, const int c; means that c can't be ...
  • 这很简单 - 只是不要在第二个循环中声明它: public function twoLoops(){ for (var i:int = 0; i < 100; i++) { } for (i = 0; i < 100; i++) { // i is already declared once } } 这将没有错误 - 正如您的警告告诉您的那样,它已经定义,因此您可以再次使用它,将其重新设置为0以允许循环正确执行。 It's simple - just don't decl ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)