MASM + Masm32 SDK, функции scanf и printf импортируются из библиотеки msvcrt.lib.
Проверка корректности ввода с клавиатуры не производится.
.386
.model flat, stdcall
option casemap:none
include kernel32.inc
include msvcrt.inc
includelib kernel32.lib
includelib msvcrt.lib
.stack 100h
.data
Prompt db 'Введите верхний предел диапазона: ',0
InpFormat db '%i',0
OutFormat db '%8i',0
Result db 'Составные числа от 2 до %i:',13,10,0
QuitPrompt db 13,10,10,'Для завершения работы нажмите любую клавишу... ',0
.data
N dd ?
X dd ?
IntBuf dd ?
.code
N88738523:
invoke crt_printf,addr Prompt
invoke crt_scanf,addr InpFormat,addr N
mov dword ptr X,2
finit
fstcw word ptr IntBuf
or word ptr IntBuf,0C00h
fldcw word ptr IntBuf
invoke crt_printf,addr Result,N
MainLoop:
mov eax,X
cmp N,eax
jl Quit
fild X
fsqrt
fistp IntBuf
mov ecx,IntBuf
TestLoop:
cmp ecx,2
jb NextNumber
mov eax,X
cdq
idiv ecx
test edx,edx
jz PrintNumber
dec ecx
jmp TestLoop
PrintNumber:
invoke crt_printf,addr OutFormat,X
NextNumber:
inc dword ptr X
jmp MainLoop
Quit:
invoke crt_printf,addr QuitPrompt
WaitKey:
invoke crt__kbhit
test eax, eax
jz WaitKey
invoke ExitProcess,0
end N88738523