G64
This commit is contained in:
		
							parent
							
								
									70c3756257
								
							
						
					
					
						commit
						402d412e92
					
				
					 5 changed files with 206 additions and 0 deletions
				
			
		
							
								
								
									
										32
									
								
								nasm/D.asm
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								nasm/D.asm
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,32 @@ | ||||||
|  | extern printf | ||||||
|  | extern scanf | ||||||
|  | global main | ||||||
|  | 
 | ||||||
|  | section .text | ||||||
|  | main:	 | ||||||
|  | 	push y | ||||||
|  | 	push x | ||||||
|  | 	push nya1 | ||||||
|  | 	call scanf | ||||||
|  | 	add esp, 12 | ||||||
|  | 	 | ||||||
|  | 	mov eax, [x] | ||||||
|  | 	;mov ebx, [y] | ||||||
|  | 	cdq | ||||||
|  | 	idiv dword [y] | ||||||
|  | 
 | ||||||
|  | 	push eax | ||||||
|  | 	push nya | ||||||
|  | 	call printf | ||||||
|  | 	add esp, 8 | ||||||
|  | 
 | ||||||
|  | 	xor eax, eax | ||||||
|  | 	ret | ||||||
|  | 
 | ||||||
|  | section .data | ||||||
|  | nya db "%d", 10, 0 | ||||||
|  | nya1 db "%d %d", 0 | ||||||
|  | 
 | ||||||
|  | section .bss | ||||||
|  | x resd 1 | ||||||
|  | y resd 1 | ||||||
							
								
								
									
										32
									
								
								nasm/E.asm
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								nasm/E.asm
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,32 @@ | ||||||
|  | extern printf | ||||||
|  | extern scanf | ||||||
|  | global main | ||||||
|  | 
 | ||||||
|  | section .text | ||||||
|  | main:	 | ||||||
|  | 	push y | ||||||
|  | 	push x | ||||||
|  | 	push nya1 | ||||||
|  | 	call scanf | ||||||
|  | 	add esp, 12 | ||||||
|  | 	 | ||||||
|  | 	mov eax, [x] | ||||||
|  | 	;mov ebx, [y] | ||||||
|  | 	cdq | ||||||
|  | 	idiv dword [y] | ||||||
|  | 
 | ||||||
|  | 	push edx | ||||||
|  | 	push nya | ||||||
|  | 	call printf | ||||||
|  | 	add esp, 8 | ||||||
|  | 
 | ||||||
|  | 	xor eax, eax | ||||||
|  | 	ret | ||||||
|  | 
 | ||||||
|  | section .data | ||||||
|  | nya db "%d", 10, 0 | ||||||
|  | nya1 db "%d %d", 0 | ||||||
|  | 
 | ||||||
|  | section .bss | ||||||
|  | x resd 1 | ||||||
|  | y resd 1 | ||||||
							
								
								
									
										44
									
								
								nasm/G64.asm
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								nasm/G64.asm
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,44 @@ | ||||||
|  | global main | ||||||
|  | extern scanf | ||||||
|  | extern printf | ||||||
|  | section .text | ||||||
|  | 
 | ||||||
|  | main: | ||||||
|  | 	; scanf | ||||||
|  | 	sub rsp, 8 | ||||||
|  | 	mov rdi, nya | ||||||
|  | 	mov rsi, x | ||||||
|  | 	mov rdx, y | ||||||
|  | 	call scanf wrt ..plt | ||||||
|  | 	add   rsp, 8  | ||||||
|  | 	 | ||||||
|  | 	; comparsion | ||||||
|  | 	mov rax, qword [rel x] | ||||||
|  | 	add rax, [rel y] | ||||||
|  | 	 | ||||||
|  | 	jb meow	 | ||||||
|  | 	push rbp | ||||||
|  | 	mov rdi, no | ||||||
|  | 	call printf wrt ..plt | ||||||
|  | 	pop rbp | ||||||
|  | 
 | ||||||
|  | 	jmp end | ||||||
|  | 
 | ||||||
|  | meow: | ||||||
|  | 	push rbp | ||||||
|  | 	mov rdi, yes | ||||||
|  | 	call printf wrt ..plt | ||||||
|  | 	pop rbp | ||||||
|  | 
 | ||||||
|  | end:	 | ||||||
|  | 	xor rax, rax | ||||||
|  | 	ret | ||||||
|  | 
 | ||||||
|  | section .data | ||||||
|  | nya dq "%llu %llu", 0 | ||||||
|  | yes db "YES", 10, 0 | ||||||
|  | no db "NO", 10, 0 | ||||||
|  | 
 | ||||||
|  | section .bss | ||||||
|  | x resq 1 | ||||||
|  | y resq 1 | ||||||
							
								
								
									
										68
									
								
								nasm/N.asm
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								nasm/N.asm
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,68 @@ | ||||||
|  | global main | ||||||
|  | extern scanf | ||||||
|  | extern printf | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | section .text | ||||||
|  | main: | ||||||
|  | 	xor ebx, ebx | ||||||
|  | 
 | ||||||
|  | loop1: | ||||||
|  | 	cmp ebx, 8 | ||||||
|  | 	jge nya1 | ||||||
|  | 	inc ebx | ||||||
|  | 
 | ||||||
|  | 	; read element	 | ||||||
|  | 	lea edx, [a + 1*ebx] | ||||||
|  | 	push edx | ||||||
|  | 	push template | ||||||
|  | 	call scanf | ||||||
|  | 	add esp, 8	 | ||||||
|  | 
 | ||||||
|  | 	push word [edx] | ||||||
|  | 	push output | ||||||
|  | 	call printf | ||||||
|  | 	add esp, 8	 | ||||||
|  | 
 | ||||||
|  | 	jmp loop1 | ||||||
|  | 
 | ||||||
|  | nya1: | ||||||
|  | 	 | ||||||
|  | 
 | ||||||
|  | ;	xor ebx, ebx | ||||||
|  | ; | ||||||
|  | ;loop2: | ||||||
|  | ;	cmp ebx, 8 | ||||||
|  | ;	jge nya2 | ||||||
|  | ;	inc ebx | ||||||
|  | ; | ||||||
|  | ;	; read element	 | ||||||
|  | ;	push b | ||||||
|  | ;	push template | ||||||
|  | ;	call scanf | ||||||
|  | ;	add esp, 8	 | ||||||
|  | ; | ||||||
|  | ;	jmp loop1 | ||||||
|  | ; | ||||||
|  | ;nya1: | ||||||
|  | 
 | ||||||
|  | ;	xor ebx, ebx | ||||||
|  | ;loop3: | ||||||
|  | 	; output | ||||||
|  | ;	push word [a] | ||||||
|  | ;	push output | ||||||
|  | ;	call printf | ||||||
|  | ;	add esp, 8 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	xor eax, eax | ||||||
|  | 	ret | ||||||
|  | 
 | ||||||
|  | section .data | ||||||
|  | template db "%d", 0 | ||||||
|  | output db "%d", 10, 0 | ||||||
|  | t db "%d", 10, 0 | ||||||
|  | 
 | ||||||
|  | section .bss | ||||||
|  | a resw 8 | ||||||
|  | b resw 8 | ||||||
							
								
								
									
										30
									
								
								nasm/O.asm
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								nasm/O.asm
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,30 @@ | ||||||
|  | global _start | ||||||
|  | 
 | ||||||
|  | section .text | ||||||
|  | _start: | ||||||
|  | 	; input | ||||||
|  | 	mov eax, 3 | ||||||
|  | 	xor ebx, ebx | ||||||
|  | 	mov ecx, nya | ||||||
|  | 	mov edx, 1 | ||||||
|  | 	int 0x80	 | ||||||
|  | 	 | ||||||
|  | 	; modification | ||||||
|  | 	mov ax, word [nya] | ||||||
|  | 	or ax, 0111b | ||||||
|  | 	mov [nya], ax | ||||||
|  | 
 | ||||||
|  | 	; output | ||||||
|  | 	mov eax, 4 | ||||||
|  | 	mov ebx, 1 | ||||||
|  | 	mov ecx, nya | ||||||
|  | 	mov edx, 1 | ||||||
|  | 	int 0x80 | ||||||
|  | 	 | ||||||
|  | 	; program exit | ||||||
|  | 	mov     eax, 1 ; sys_exit = 1 | ||||||
|  | 	xor     ebx, ebx | ||||||
|  | 	int     0x80 | ||||||
|  | 
 | ||||||
|  | section .bss | ||||||
|  | nya resb 1 | ||||||
		Reference in a new issue