Archived
1
0
Fork 0
This repository has been archived on 2022-06-20. You can view files and clone it, but cannot push or open issues or pull requests.
mipt_clang/nasm/H.asm
2022-04-05 15:43:58 +03:00

52 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