boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 相对于machine code, assembly到底有啥改进?
相关主题
还有人用汇编语言写程序么
世界上第一个编译器是怎么产生的?
C -> assembly
不明白为啥全都冲着WEB义无反顾的扎进去
vim跟emacs比起来
大牛讲讲JIT和AOT的比较吧
汇编的mov指令
谁还记得这个
Call assembly in c++ under linux
[合集] who can help me with this assembly code?
相关话题的讨论汇总
话题: assembly话题: machine话题: code话题: language话题: machines
进入Programming版参与讨论
1 (共1页)
j*****I
发帖数: 2626
1
assembler好像就是一对一的把assembly language翻译成machine code. 如果是酱紫的话,相
对于machine code,assembly language能解决的问题就是相同的architecture的机器,但是指
令代码不一样的情况。这样的情形有点无聊啊。
是不是我对这个machine architecture理解的还是不够?
j*****k
发帖数: 1198
2
更容易懂吧

的话,相
,但是指

【在 j*****I 的大作中提到】
: assembler好像就是一对一的把assembly language翻译成machine code. 如果是酱紫的话,相
: 对于machine code,assembly language能解决的问题就是相同的architecture的机器,但是指
: 令代码不一样的情况。这样的情形有点无聊啊。
: 是不是我对这个machine architecture理解的还是不够?

j*****I
发帖数: 2626
3
软工的教科书上说了,assembly language相对于machine code,减少了machine
dependence. 比如说相同的architecture,不同的machine,可以run同样的assembly
program. 可是同样的assembly program,按照我的理解,就是instruction set,
register,addressing什么的都定了。如果这样的话,除了易读性,我看不出软工教科
书上提到的
好处。

【在 j*****k 的大作中提到】
: 更容易懂吧
:
: 的话,相
: ,但是指

b******n
发帖数: 592
4
no, assembly is still machine dependent. it is purely for readability.
assembly to machine code is almost one to one. if you consider different
addressing can be treat as same instruction..

【在 j*****I 的大作中提到】
: 软工的教科书上说了,assembly language相对于machine code,减少了machine
: dependence. 比如说相同的architecture,不同的machine,可以run同样的assembly
: program. 可是同样的assembly program,按照我的理解,就是instruction set,
: register,addressing什么的都定了。如果这样的话,除了易读性,我看不出软工教科
: 书上提到的
: 好处。

p***o
发帖数: 1252
5
Don't take the book too seriously. It's just a book on software engineering.

【在 j*****I 的大作中提到】
: 软工的教科书上说了,assembly language相对于machine code,减少了machine
: dependence. 比如说相同的architecture,不同的machine,可以run同样的assembly
: program. 可是同样的assembly program,按照我的理解,就是instruction set,
: register,addressing什么的都定了。如果这样的话,除了易读性,我看不出软工教科
: 书上提到的
: 好处。

X****r
发帖数: 3557
6
Don't simply take the words from any book. Other than translating
mnemonics to opcodes, Assembler helps resolving symbols (ever
calculated jump offset manually?) and provides macros, making writing
code much much easier.

【在 j*****I 的大作中提到】
: 软工的教科书上说了,assembly language相对于machine code,减少了machine
: dependence. 比如说相同的architecture,不同的machine,可以run同样的assembly
: program. 可是同样的assembly program,按照我的理解,就是instruction set,
: register,addressing什么的都定了。如果这样的话,除了易读性,我看不出软工教科
: 书上提到的
: 好处。

j*****I
发帖数: 2626
7
我就把我看得贴在这八。
The late 1940s and the late 1950s saw the introduction of the first
general-purpose electronic computers for defense purposes. These
machines could run code that addressed any problem, not just a single
predetermined task. The downside was that the code executed on those
computers was in a machine-specific "language" with the program coupled
to the hardware itself. Code developeed for one machine could not run on
another. Initially this was not a cause for concern since there were
only a handful of computers in the world anyway. As machines become more
prolific, in the early 1960s the emergence of assembly language
decoupled the code from specific machines, and enabled code to run on
multiple machines.
However, the code was now coupled to the machine architecture. Code
written for an 8-bit machine could not run on a 16-bit machine, let
alone withstand differences in the registers or available memory and
memory layout. As a result, the cost of owning and maintaining a program
began to escalate. This coincided more or less with the widespread
adoption of computers in the civilian and government sectors, where the
more limited resources and budgets necessitated a better solution.
最让我不明白的一句就是,"in the early 1960s the emergence of assembly
language decoupled the code from specific machines, and enabled code to
run on multiple machines. " 这里说的意思应该是,有那么一些机器,用同一份
machine
code不行,但是用同一份assembly program就可以。我就纳闷,这些个机器到底是怎么
个差别,
这种差别使得他们不能用同一份 machine code,但是可以用同一份assembly code?

【在 X****r 的大作中提到】
: Don't simply take the words from any book. Other than translating
: mnemonics to opcodes, Assembler helps resolving symbols (ever
: calculated jump offset manually?) and provides macros, making writing
: code much much easier.

j*****I
发帖数: 2626
8
CS版有人这么回了,有点意思。
===========
机器码那是百分百的machine dependent, 汇编语言
是有一定的移植性的。比如8086的汇编你完全
可以做很小的修改移植到z80或者其他机器上去。
至少模块功能可以完全一致。
===========

【在 X****r 的大作中提到】
: Don't simply take the words from any book. Other than translating
: mnemonics to opcodes, Assembler helps resolving symbols (ever
: calculated jump offset manually?) and provides macros, making writing
: code much much easier.

p***o
发帖数: 1252
9
So they mean ISA when mentioning assembly language.

【在 j*****I 的大作中提到】
: 我就把我看得贴在这八。
: The late 1940s and the late 1950s saw the introduction of the first
: general-purpose electronic computers for defense purposes. These
: machines could run code that addressed any problem, not just a single
: predetermined task. The downside was that the code executed on those
: computers was in a machine-specific "language" with the program coupled
: to the hardware itself. Code developeed for one machine could not run on
: another. Initially this was not a cause for concern since there were
: only a handful of computers in the world anyway. As machines become more
: prolific, in the early 1960s the emergence of assembly language

a****l
发帖数: 8211
10
我觉得文章的意思是说:最早的机器是自己有自己的语言的,每台机器的语言都是不一
样的,是machine code,所以完全不能通用。当时的语言是直接和机器的硬件相关的。
当时世界上只有少数几台机器,所以不是个问题。后来机器多了,所以需要一个通用的
编程接口,所以发明了汇编语言,所以不同的机器可以用相同的程序。有了汇编,就是
有了一个虚拟的硬件接口,程序之需要操作这个接口了,然后由硬件(cpu)把这个虚
拟的口的操作实现在具体的硬件上。比如说,程序说要给Register0写入1,在pentium
上和p4上都是一个程序,但是具体到cpu就要把这个要求变为把xxx线变高电平把xxx线
变低电平,然后某个flip-flop的状态就变成了低或者高电平,然后这个0就写在了硬件
上了。显然,pentium上的这个flipflop和p4上的flip-flop是不一样的,所以实际的操
作是不同的,但是汇编就把这个区别屏蔽掉了。

【在 j*****I 的大作中提到】
: 我就把我看得贴在这八。
: The late 1940s and the late 1950s saw the introduction of the first
: general-purpose electronic computers for defense purposes. These
: machines could run code that addressed any problem, not just a single
: predetermined task. The downside was that the code executed on those
: computers was in a machine-specific "language" with the program coupled
: to the hardware itself. Code developeed for one machine could not run on
: another. Initially this was not a cause for concern since there were
: only a handful of computers in the world anyway. As machines become more
: prolific, in the early 1960s the emergence of assembly language

相关主题
不明白为啥全都冲着WEB义无反顾的扎进去
vim跟emacs比起来
大牛讲讲JIT和AOT的比较吧
汇编的mov指令
进入Programming版参与讨论
j********e
发帖数: 124
11
Has anybody thought of relocatable code, Assembly uses symbols for
addresses, machine code can never do that.
Assembly code talks about segments.
Q****r
发帖数: 7340
12
这个就要depend要修改多少了
不同的machine,汇编语言都有相似性,如果都是RISC或者都是CISC,从这个角度上来
看,可以移植,比如相加都是ADD,存放数据到寄存器都是MOV。
但是,assembly对machine的寄存器的操作,还有中断的操作,machine与machine之间
就不同了,
同样是51系列,8051的和8051F020,差别就大得去了,前者ROM RAM都很小,后者RAM大
多了,同时
加入在线flash,前者只有5个中断,后者22个中断,中断的地址,控制中断的寄存器都
不同。两个程序
根本无法相互移植。当然懂一个,再看另外一个不难。虽然两个都是用CISC

【在 j*****I 的大作中提到】
: CS版有人这么回了,有点意思。
: ===========
: 机器码那是百分百的machine dependent, 汇编语言
: 是有一定的移植性的。比如8086的汇编你完全
: 可以做很小的修改移植到z80或者其他机器上去。
: 至少模块功能可以完全一致。
: ===========

j*****I
发帖数: 2626
13
嗯。可能assembly刚出来的时候,还没这么多的变化。

【在 Q****r 的大作中提到】
: 这个就要depend要修改多少了
: 不同的machine,汇编语言都有相似性,如果都是RISC或者都是CISC,从这个角度上来
: 看,可以移植,比如相加都是ADD,存放数据到寄存器都是MOV。
: 但是,assembly对machine的寄存器的操作,还有中断的操作,machine与machine之间
: 就不同了,
: 同样是51系列,8051的和8051F020,差别就大得去了,前者ROM RAM都很小,后者RAM大
: 多了,同时
: 加入在线flash,前者只有5个中断,后者22个中断,中断的地址,控制中断的寄存器都
: 不同。两个程序
: 根本无法相互移植。当然懂一个,再看另外一个不难。虽然两个都是用CISC

b******n
发帖数: 592
14
register names are different, one has LD, 8086 has MOV.
Assembly is not a programming language, it is a set of instruction sets..
that's why you can say 8086 Assembly, P4 Assembly and so on..

【在 j*****I 的大作中提到】
: CS版有人这么回了,有点意思。
: ===========
: 机器码那是百分百的machine dependent, 汇编语言
: 是有一定的移植性的。比如8086的汇编你完全
: 可以做很小的修改移植到z80或者其他机器上去。
: 至少模块功能可以完全一致。
: ===========

b******n
发帖数: 592
15
P4 has machine code back compatibility with Pentium..

pentium

【在 a****l 的大作中提到】
: 我觉得文章的意思是说:最早的机器是自己有自己的语言的,每台机器的语言都是不一
: 样的,是machine code,所以完全不能通用。当时的语言是直接和机器的硬件相关的。
: 当时世界上只有少数几台机器,所以不是个问题。后来机器多了,所以需要一个通用的
: 编程接口,所以发明了汇编语言,所以不同的机器可以用相同的程序。有了汇编,就是
: 有了一个虚拟的硬件接口,程序之需要操作这个接口了,然后由硬件(cpu)把这个虚
: 拟的口的操作实现在具体的硬件上。比如说,程序说要给Register0写入1,在pentium
: 上和p4上都是一个程序,但是具体到cpu就要把这个要求变为把xxx线变高电平把xxx线
: 变低电平,然后某个flip-flop的状态就变成了低或者高电平,然后这个0就写在了硬件
: 上了。显然,pentium上的这个flipflop和p4上的flip-flop是不一样的,所以实际的操
: 作是不同的,但是汇编就把这个区别屏蔽掉了。

1 (共1页)
进入Programming版参与讨论
相关主题
[合集] who can help me with this assembly code?
char *p = "string literal"; 和 char a[] = "string liter (转载)
问几句汇编指令(assembly language)
如何区分read page fault 和 write page fault
问一个C#问题
JavaScript is Assembly Language for the Web (转载)
recommend assembly code from gcc
拒了一个来面试的
从统一数据格式和算法写作格式的角度讲,matlab还是很先进的
来看v8他爹用什么来搞v8
相关话题的讨论汇总
话题: assembly话题: machine话题: code话题: language话题: machines