nya
This commit is contained in:
		
							parent
							
								
									bcf24631d4
								
							
						
					
					
						commit
						89cd73673d
					
				
					 4 changed files with 213 additions and 0 deletions
				
			
		
							
								
								
									
										64
									
								
								asm/idiv.s
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								asm/idiv.s
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,64 @@ | |||
| 	.file	"idiv.c" | ||||
| 	.intel_syntax noprefix
 | ||||
| 	.text | ||||
| 	.section	.rodata | ||||
| .LC0: | ||||
| 	.string	"%hd %hd" | ||||
| .LC1: | ||||
| 	.string	"%hd\n" | ||||
| 	.text | ||||
| 	.globl	main
 | ||||
| 	.type	main, @function
 | ||||
| main: | ||||
| .LFB0: | ||||
| 	.cfi_startproc | ||||
| 	push	rbp | ||||
| 	.cfi_def_cfa_offset 16
 | ||||
| 	.cfi_offset 6, -16 | ||||
| 	mov	rbp, rsp | ||||
| 	.cfi_def_cfa_register 6
 | ||||
| 	sub	rsp, 16 | ||||
| 	mov	rax, QWORD PTR fs:40 | ||||
| 	mov	QWORD PTR -8[rbp], rax | ||||
| 	xor	eax, eax | ||||
| 	lea	rdx, -12[rbp] | ||||
| 	lea	rax, -14[rbp] | ||||
| 	mov	rsi, rax | ||||
| 	lea	rax, .LC0[rip] | ||||
| 	mov	rdi, rax | ||||
| 	mov	eax, 0 | ||||
| 	call	__isoc99_scanf@PLT
 | ||||
| 	movzx	eax, WORD PTR -14[rbp] | ||||
| 	movzx	edx, WORD PTR -12[rbp] | ||||
| #APP | ||||
| # 6 "idiv.c" 1 | ||||
| 	mov ax,%ax | ||||
| mov dx,%bx | ||||
| cwd | ||||
| idiv %bx | ||||
| mov %ax, %dx | ||||
| mov %dx, ax | ||||
| 
 | ||||
| # 0 "" 2 | ||||
| #NO_APP | ||||
| 	mov	WORD PTR -10[rbp], ax | ||||
| 	movsx	eax, WORD PTR -10[rbp] | ||||
| 	mov	esi, eax | ||||
| 	lea	rax, .LC1[rip] | ||||
| 	mov	rdi, rax | ||||
| 	mov	eax, 0 | ||||
| 	call	printf@PLT
 | ||||
| 	mov	eax, 0 | ||||
| 	mov	rdx, QWORD PTR -8[rbp] | ||||
| 	sub	rdx, QWORD PTR fs:40 | ||||
| 	je	.L3 | ||||
| 	call	__stack_chk_fail@PLT
 | ||||
| .L3: | ||||
| 	leave | ||||
| 	.cfi_def_cfa 7, 8 | ||||
| 	ret | ||||
| 	.cfi_endproc | ||||
| .LFE0: | ||||
| 	.size	main, .-main | ||||
| 	.ident	"GCC: (GNU) 11.2.0" | ||||
| 	.section	.note.GNU-stack,"",@progbits
 | ||||
							
								
								
									
										19
									
								
								asm/switch.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								asm/switch.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,19 @@ | |||
| int main() { | ||||
| 	int x = 1; | ||||
| 	switch(x) { | ||||
| 		case 1:  | ||||
| 			return 1; | ||||
| 			break; | ||||
| 		case 2: | ||||
| 			return 2; | ||||
| 			break; | ||||
| 		case 3: | ||||
| 		case 4: | ||||
| 			return 113; | ||||
| 		case 5: | ||||
| 			return 4; | ||||
| 			break; | ||||
| 		case 6: | ||||
| 			return  | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										42
									
								
								asm/switch.s
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								asm/switch.s
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,42 @@ | |||
| 	.file	"switch.c" | ||||
| 	.text | ||||
| 	.globl	main
 | ||||
| 	.type	main, @function
 | ||||
| main: | ||||
| .LFB0: | ||||
| 	.cfi_startproc | ||||
| 	pushq	%rbp | ||||
| 	.cfi_def_cfa_offset 16
 | ||||
| 	.cfi_offset 6, -16 | ||||
| 	movq	%rsp, %rbp | ||||
| 	.cfi_def_cfa_register 6
 | ||||
| 	movl	$1, -4(%rbp) | ||||
| 	cmpl	$4, -4(%rbp) | ||||
| 	jg	.L2 | ||||
| 	cmpl	$3, -4(%rbp) | ||||
| 	jge	.L3 | ||||
| 	cmpl	$1, -4(%rbp) | ||||
| 	je	.L4 | ||||
| 	cmpl	$2, -4(%rbp) | ||||
| 	je	.L5 | ||||
| 	jmp	.L2 | ||||
| .L4: | ||||
| 	movl	$1, %eax | ||||
| 	jmp	.L6 | ||||
| .L5: | ||||
| 	movl	$2, %eax | ||||
| 	jmp	.L6 | ||||
| .L3: | ||||
| 	movl	$113, %eax | ||||
| 	jmp	.L6 | ||||
| .L2: | ||||
| 	movl	$0, %eax | ||||
| .L6: | ||||
| 	popq	%rbp | ||||
| 	.cfi_def_cfa 7, 8 | ||||
| 	ret | ||||
| 	.cfi_endproc | ||||
| .LFE0: | ||||
| 	.size	main, .-main | ||||
| 	.ident	"GCC: (GNU) 11.2.0" | ||||
| 	.section	.note.GNU-stack,"",@progbits
 | ||||
		Reference in a new issue