Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- includelib libcmt.lib
- includelib libvcruntime.lib
- includelib libucrt.lib
- includelib legacy_stdio_definitions.lib
- extern printf_s: proc, scanf_s: proc, getchar: proc
- .data
- prompt byte "Enter an integer number: ", 0
- inputFormatString byte "%d", 0
- invalidInputMessage byte "Error: Invalid Input.", 0
- formatString1 byte "The number %2d is divisible by both 3 and 5", 10, 13, 0
- formatString2 byte "The number %2d is divisible by 3 but not 5", 10, 13, 0
- formatString3 byte "The number %2d is divisible by 5 but not 3", 10, 13, 0
- formatString4 byte "The number %2d is neither divisible by 3 nor 5", 10, 13, 0
- .data?
- num sdword ? ; int x, y, sum, product, difference;
- .code
- main proc
- enter 32, 0
- lea rcx, [prompt] ; printf("Enter two integers: ");
- call printf_s ;
- lea rdx, [num] ;
- lea rcx, [inputFormatString] ;
- call scanf_s ;
- cmp rax, 1
- jne error
- call getchar
- cmp rax, 32
- je program
- cmp rax, 10
- je program
- cmp rax, 9
- je program
- jmp error
- error:
- lea rcx, [invalidInputMessage]
- call printf_s
- jmp terminate
- program:
- mov eax, num
- cdq
- mov ebx, 5
- idiv ebx
- cmp edx, 0
- je cond1
- jmp cond2
- cond1: ;by 5 and 3
- mov eax, num
- cdq
- mov ebx, 3
- idiv ebx
- cmp edx, 0
- jne cond3
- mov edx, dword ptr [num]
- lea rcx, [formatString1]
- call printf_s
- jmp terminate
- cond2: ;by 3 but not 5
- mov eax, num
- cdq
- mov ebx, 3
- idiv ebx
- cmp edx, 0
- jne cond4
- mov edx, dword ptr [num]
- lea rcx, [formatString2]
- call printf_s
- jmp terminate
- cond3: ;by 5 but not 3
- mov edx, dword ptr [num]
- lea rcx, [formatString3]
- call printf_s
- jmp terminate
- cond4: ;neither 3 nor 5
- mov edx, dword ptr [num]
- lea rcx, [formatString4]
- call printf_s
- terminate:
- xor rax, rax
- leave
- main endp
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement