nihonium
/
mipt_clang
Archived
1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

53 lines
549 B
NASM

global main
extern printf
extern scanf
section .text
main:
push x
push nya
call scanf
add esp, 8
push y
push nya
call scanf
add esp, 8
mov ebx, dword [x] ; a
mov ecx, dword [y] ; b
loop:
cmp ecx, 0 ; compare b
je end
mov eax, ebx ; move a to eax
cdq
div ecx ; a / b, remain in edx
mov ebx, ecx ; a = b
mov ecx, edx ; b = remain
jmp loop
end:
mov eax, dword [x]
mul dword [y]
cdq
div ebx
push eax
push nya
call printf
add esp, 8
xor eax, eax
ret
section .data
nya db "%u", 0
section .bss
x resd 1
y resd 1