the program find max number from a list of numbers, using assembly language on x86 architecture,
code:
max_num2.s:
# find max number in a list of numbers, loop reverse,
# and don't need the register that record total_count,
#
# registers:
# %eax store each number to compare
# %ebx the max number
# %edi index of number during comparation
.section .data
num_items:
.long 3,67,34,222,45,75,54,34,44,33,22,11,66
num_count:
.long 13
.section .text
.globl _start
_start:
movl num_items, %ebx
movl num_count, %edi
decl %edi
loop:
cmp $0, %edi # detect whether reach end
jl exit
movl num_items(,%edi,4), %eax # read next number
decl %edi # decrease index by 1
cmp %eax, %ebx
jge loop
movl %eax, %ebx
jmp loop
exit:
movl $1, %eax
int $0x80
compile:
as max_num2.s -o a.o
ld a.o -o a.out
run:
./a.out
get result: (the result is stored in %ebx, then call exit syscall, which read status code from this register)
echo $?
分享到:
相关推荐
osgi-blueprint-helloworld-assembly Apache Karaf功能 如何建造 它使用Maven框架。 构建项目的先决条件: Maven,版本3+ Java JDK 1.8 建立它 这是一个maven项目,要使用以下命令进行构建 mvn clean install ...
rust代码-Hello World Rust
rust学习爱好者
在DOS中编译,显示HELLO WORLD的汇编语言!
ARM-CortexM4-HelloWorld 要求 硬件 STM32F407G-DISC1(开发套件) 微型USB到USB-A 软件 STM32Cube IDE 硬件规格 核心架构-Arm 数据总线宽度-32位 记忆体大小-1MB 内存大小-192kB 接口-CAN,以太网,I2C,SPI,...
java8 ...Helloworld programs in different languages,pull requests are welcome :) Awk - A script that cleans up the php.ini file with security in mind Batchfile - Python best practices gui
NES的Hello World(ca65汇编程序的6502汇编版本) 请参阅父存储库以了解其他项目。 正在进行中,但解决方案当前显示精灵,显示背景,并使用d-pad移动精灵。 项目内容 hello_world.s-ca65源文件 hello.chr-精灵...
gb样板 用于Game Boy RGBDS项目的最小的,可定制的,易于编译的样板。 正在下载 您可以简单地使用Git克隆存储库,或者,如果您只想下载它,请单击它右侧的Clone or download按钮。 此存储库也可用作创建新存储库的...
Assembly - A cross-platform x86 assembler with an Intel-like syntax - - Continuous Unix commit history from 1970 until today - Original Apollo 11 Guidance Computer (AGC) source code for the command ...
这个项目向您展示了如何用您能想到的所有语言编写传奇的基本“ hello-world”。 先决条件和用法 对于每个问候世界,请下载该语言的编译器并运行文件。 结构体 每种语言的hello-world代码位于其自己的目录中。 该目录...
数学所以,在我的 hello world 之后,我想做一些基本的数学运算。 我只是“让我们添加东西,然后将结果打印到终端”是的,这并没有真正起作用,因为在汇编中将数字隐式转换为字符串是闻所未闻的。 所以,我只是使用 ...
打印字符串“ Hello,World!” 2号实验室工作 删除给定单词之后的行中的单词。 3号实验室工作 输入一个由30个元素组成的整数数组。 计算其值在给定范围内的元素数。 4号实验室工作 游戏“蛇”。 实验室工作五 ...
运行sbt assembly创建可执行的helloworld.jar文件 通过 USB 线连接 EV3 跑. deploy.sh . deploy.sh通过 USB 连接部署到 EV3 Brick 在 leJOS 下的 EV3 Programs上选择Programs > helloworld.jar > Execute program
你好,世界 您的第一种编程语言中的第一个程序。 我正在练习github。
SimpleOS 仅显示“ Hello World!”的裸机最低操作系统。 并列出字母。 您可以在虚拟机下运行此操作系统。 qemu就是这样一种VM。 如果希望使用qemu运行(仅在Linux上进行了测试),则使用终端cd进入包含boot.bin文件...
你好世界医学博士
脚步 mvn assembly:assembly -DdescriptorId=jar-with-dependencies java -jar target/helloWorld-1.0-SNAPSHOT-jar-with-dependencies.jar
你好,世界 每种计算机语言的世界您好。 当我看到产品系列扩展时,这个项目的爆炸力超过了我的想象。 感谢每个继续做出贡献的人; 每天都会创建新的语言! 请务必查看以获取有关对该项目进行的说明!...
您好不同操作系统的各种编程语言中的“ Hello world”示例。
可执行文件的剖析可执行文件,共享库和可重定位目标代码的表示通过多种文件格式进行了标准化,这些文件格式提供了汇编指令和数据的封装。 两种这样的格式分别是Windows和Linux分别使用的可移植可执行(PE)文件格式...