flat assembler
Message board for the users of flat assembler.
Index
> Windows > window console add two number with MMX. |
Author |
|
Roman 26 Dec 2022, 19:32
Try:
mov eax, [num1] add eax, [num2] mov [result], eax What is this ? offset output ? invoke wsprintf, output, fo, [result] invoke WriteConsole, [hConOut], output, sizeof.output, addr n, 0 |
|||
26 Dec 2022, 19:32 |
|
sinsi 26 Dec 2022, 20:05
I don't use the macros, but wsprintf is C calling convention, not stdcall, so shouldn't you use cinvoke?
|
|||
26 Dec 2022, 20:05 |
|
Roman 26 Dec 2022, 20:36
Yes. cinvoke wsprintf, output, fo, [result]
|
|||
26 Dec 2022, 20:36 |
|
AsmGuru62 27 Dec 2022, 02:28
So... not using OLLYDBG?
Why not? You would instantly know which line of the code causes a crash. It is just guessing otherwise. |
|||
27 Dec 2022, 02:28 |
|
catafest 27 Dec 2022, 12:25
The source code in this output shown here is after several hours of testing OpenAI to see if it outputs working source code and even includes other C libraries, I think it is not trained enough to output working source code.
I didn't really have time to work with FASM, but I saw that they also launched fasmg. My assembly knowledge is somewhat limited and I have a few FASM gaps. I haven't really worked with ollydbg, I don't really find good tutorials, just what comes out of assembly programming. But because I spent time, I wanted to have a working source code and that's why I asked here, and if you have tutorials related to ollydbg or ResourceHacker software to work with res or rc files, it would be great to add them here or in - a special learning post. Thanks for the replies and I try to solve this source code ... Happy holidays to all developers. |
|||
27 Dec 2022, 12:25 |
|
Tomasz Grysztar 27 Dec 2022, 12:35
catafest wrote: But because I spent time, I wanted to have a working source code and that's why I asked here, and if you have tutorials related to ollydbg or ResourceHacker software to work with res or rc files, it would be great to add them here or in - a special learning post.[/i] |
|||
27 Dec 2022, 12:35 |
|
catafest 27 Dec 2022, 13:03
Tomasz Grysztar wrote:
Thank you. |
|||
27 Dec 2022, 13:03 |
|
Roman 27 Dec 2022, 19:06
catafest wrote: The source code in this output shown here is after several hours of testing OpenAI to see if it outputs working source code and even includes other C libraries, I think it is not trained enough to output working source code. Hm OpenAI . You using chatGP for generated asm code ? Show video how you do this. |
|||
27 Dec 2022, 19:06 |
|
catafest 27 Dec 2022, 21:15
Just I start asking and tested the result, when I got an error I ask to fix it, most of the responses were based on the FASM documentation and some part of the source code refer to c programming language. For example:
fix error in your source code error: undefined symbol 'FOREGROUND_GREEN'. To fix the "undefined symbol" error caused by the FOREGROUND_GREEN symbol in your code, you can follow these steps: Make sure that the FOREGROUND_GREEN symbol is defined in the include file or the library file that is being used by your program. The FOREGROUND_GREEN symbol is a constant that is used to specify the foreground color of the console output, and it is defined in the wincon.h include file. You can include the wincon.h file in your program by using the include directive, as follows: Copy code include 'wincon.h' |
|||
27 Dec 2022, 21:15 |
|
Roman 27 Dec 2022, 21:31
Try
FOREGROUND_GREEN = 10 FOREGROUND_INTENSITY = 10 Code: ;and remove all offset invoke SetConsoleTitle, consoleTitle invoke SetConsoleTextAttribute, [hConOut], 10+10 |
|||
27 Dec 2022, 21:31 |
|
Roman 28 Dec 2022, 12:41
My variant work fine. And i get 'The result is: 17'
Code: format PE GUI 4.0 entry Start include 'INCLUDE/WIN32AX.INC' SECTION '.data' DATA READABLE WRITEABLE executable consoleTitle db 'Add two numbers using MMX ',0 ;offset dd ? hConOut dd ? FOREGROUND_GREEN = 10 FOREGROUND_INTENSITY = 10 addr dd ? n dd ? sizeof.output = 256 ; I don't find a sizeof for output sizeof.prompt = 256 ; I don't find a sizeof for output num1 dd 15 num2 dd 2 result dd ? prompt db 'Enter two numbers to add:',0 fo db 'The result is: %d',0 ; format ?? output db 16 dup (0) section '.code' code readable writeable executable Start: invoke AllocConsole invoke GetStdHandle, STD_OUTPUT_HANDLE mov [hConOut], eax invoke SetConsoleTitle, consoleTitle invoke SetConsoleTextAttribute, [hConOut], FOREGROUND_GREEN or FOREGROUND_INTENSITY invoke WriteConsole, [hConOut], prompt, sizeof.prompt, addr n, 0 ; Read the two numbers from the console invoke ReadConsole, [hConOut], addr num1, 4, addr n, 0 invoke ReadConsole, [hConOut], addr num2, 4, addr n, 0 ; Add the two numbers with MMX movd mm0, [num1] movd mm1, [num2] paddw mm0, mm1 movd [result], mm0 emms ; Print the result to the console cinvoke wsprintf, output, fo, [result] invoke WriteConsole, [hConOut], output, sizeof.output, addr n, 0 invoke Sleep, 2000 invoke FreeConsole invoke MessageBox,0,'Done ! Exit',0,0 invoke ExitProcess,0 |
|||
28 Dec 2022, 12:41 |
|
catafest 21 Jan 2023, 11:57
thank you @Roman
... good to know, I see the errors versus my default example ... |
|||
21 Jan 2023, 11:57 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.