⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sh.s

📁 用于汇编领域的,运用于OS的MAIN函数.基于硬件基础的源代码
💻 S
字号:
.globl _start_start:# infinite loop# write(1, "$", 1): print out prompt# 1st arg in ebx, 2nd arg in ecx, 3rd arg in edx     movl $1, %ebx   # fd=1, the standard output   movl $prompt, %ecx  # put the addr of prompt in ecx   movl $1, %edx   # n=1   movl $4, %eax   int $0x80# n=read(0, buf, 20): read max 20 bytes from keyboard   movl $0, %ebx   movl $buf, %ecx # put the addr of buf iin ecx   movl $20, %edx   movl $3, %eax   int $0x80   # eax has the length. make it a string. hos already made it a string    # movl $0, buf(%eax) # put 0 in buf[eax]#  fork()   movl $2, %eax   int $0x80   cmpl $0, %eax   je   childparent:   # wait()   movl $7, %eax   int $0x80   jmp _start # go back to infinite loopchild:   # exec(buf). exec to program in buf   movl $buf, %ebx   movl $11, %eax   int $0x80buf: .fill 20,1,0prompt: .asciz "$"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -