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

📄 c-test.s

📁 一个编译器的例子,基于c语言,在linux下开发 现在了简单的c语言例子
💻 S
字号:
				# start of the file.include "defines.h"		# system call numbers.include "c-test.literals"	# include the string literal file	.global _start		.bss	.align	4_data:	.skip		8	# global variables' size.text	.align	4_start:	pushl %ebp		# save the ebp address	movl %esp, %ebp	subl $16, %esp		# allocate space for local variables	movl $97, _data+0	pushl %eax	popl %eax	movl $1, -4(%ebp)	pushl %eax	popl %eax	movl $0, -8(%ebp)	pushl %eax	popl %eax	movl $0, -12(%ebp)	pushl %eax	popl %eax	movl $0, -16(%ebp)	pushl %eax	popl %eax	movl $SYS_write, %eax	# load the write call number	movl $STDOUT, %ebx		# get the output channel	movl $literal0,%ecx		# get the literal string	movl $len0,%edx		# string length	int $0x80	movl _data+0,%eax		# get the integer value of the ID	call ishow	call newline	movl $1, -4(%ebp)	pushl %eax	popl %eaxWHILElabel0:	pushl $1	popl %eax	cmpl $0, %eax	je ENDWHILElabel0	leal -16(%ebp), %eax	pushl %eax	pushl -16(%ebp)	pushl -4(%ebp)				# arithmetic calculate	popl %ebx	addl %ebx, (%esp)	popl %ebx	popl %eax	movl %ebx, (%eax)	pushl (%eax)	popl %eax	pushl $100	pushl -4(%ebp)	popl %ebx	popl %eax	cmpl %ebx, %eax	sete %al	movzbl %al, %eax	pushl %eax	cmpl $0, (%esp)	je ELSElabel0	jmp ENDWHILElabel0	jmp ENDIFlabel0ELSElabel0:	leal -4(%ebp), %eax	pushl %eax	pushl -4(%ebp)	pushl $1				# arithmetic calculate	popl %ebx	addl %ebx, (%esp)	popl %ebx	popl %eax	movl %ebx, (%eax)	pushl (%eax)	popl %eaxENDIFlabel0:	jmp WHILElabel0ENDWHILElabel0:	movl $SYS_write, %eax	# load the write call number	movl $STDOUT, %ebx		# get the output channel	movl $literal1,%ecx		# get the literal string	movl $len1,%edx		# string length	int $0x80	movl -16(%ebp),%eax		# get the integer value of the ID	call ishow	call newline	leal -8(%ebp), %eax	pushl %eax	pushl -16(%ebp)	pushl -4(%ebp)				# arithmetic calculate	popl %ebx	popl %eax	cltd	idivl %ebx	pushl %eax	popl %ebx	popl %eax	movl %ebx, (%eax)	pushl (%eax)	popl %eax	leal -8(%ebp), %eax	pushl %eax	pushl -12(%ebp)	pushl -8(%ebp)	call getMax		# call function to get result to return	pop %edx		# release pushed arguments memory after call	pop %edx		# release pushed arguments memory after call	pushl %eax	popl %ebx	popl %eax	movl %ebx, (%eax)	pushl (%eax)	popl %eax	movl $SYS_write, %eax	# load the write call number	movl $STDOUT, %ebx		# get the output channel	movl $literal2,%ecx		# get the literal string	movl $len2,%edx		# string length	int $0x80	movl -8(%ebp),%eax		# get the integer value of the ID	call ishow	call newline	pushl $0	popl %eax		# save the return value in eax	movl %ebp, %esp	popl %ebp		# restore the ebp address	movl $SYS_exit,%eax	# load the exit call number	movl $0,%ebx		# load the exit code	int $0x80		# and exit!				# end of the filegetMax:	pushl %ebp		# save the ebp address	movl %esp, %ebp	subl $0, %esp		# allocate space for local variables	pushl 8(%ebp)	pushl 12(%ebp)	popl %ebx	popl %eax	cmpl %ebx, %eax	setg %al	movzbl %al, %eax	pushl %eax	cmpl $0, (%esp)	je ELSElabel1	pushl 8(%ebp)	popl %eax		# save the return value in eax	movl %ebp, %esp	popl %ebp		# restore the ebp address	ret	jmp ENDIFlabel1ELSElabel1:	pushl 12(%ebp)	popl %eax		# save the return value in eax	movl %ebp, %esp	popl %ebp		# restore the ebp address	retENDIFlabel1:

⌨️ 快捷键说明

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