0

i try echo memory location

but result is not char...

how to solve this problem??

assembly is really funny

like a return to the beginning of time to learn

==============================================

STD_OUTPUT_HANDLE   EQU -11
NULL                EQU 0

GLOBAL GobleyGook
EXTERN ExitProcess, GetLastError, GetStdHandle, WriteConsoleA, WriteConsoleOutputA, FormatMessageA

SECTION .data
msg                 DB "Hello World!", 13, 10, "M", 0
msg.len             EQU $ - msg

SECTION .bss
dummy   RESD 1
text    RESD 1

SECTION .text
GobleyGook: 
    PUSH    STD_OUTPUT_HANDLE
    CALL    GetStdHandle

    MOV     DWORD[text], msg

    PUSH    NULL
    PUSH    dummy
    PUSH    16
    PUSH    text
    PUSH    eax
    CALL    WriteConsoleA

    PUSH    NULL
    CALL    ExitProcess

On Windows 8 use golink

nasm -f win32 print2.asm
golink.exe /console /entry GobleyGook print2.obj kernel32.dll
Michael
  • 33
  • 5
  • Did you mean to `push OFFSET dummy` or something? If you want an ASCII representation of an address, instead of the raw 4 or 8 bytes, you need to convert the number to a string. – Peter Cordes Aug 26 '16 at 03:20
  • @Peter Cordes,yes, i need convert the number to string, but without use C function – Michael Aug 26 '16 at 03:58
  • See http://stackoverflow.com/documentation/x86/3273/converting-decimal-strings-to-integers for the reverse problem, or search Stackoverflow for any of the dozens of integer->string asm questions. – Peter Cordes Aug 26 '16 at 04:09
  • @Peter Cordes can you give me the example for int to string use NASM on win32? – Michael Aug 26 '16 at 06:37
  • Sorry, when I closed this as a duplicate I was thinking that one of the versions in Brendan's answer there stored characters to a buffer, so you could use that directly. The other answer on the dup-target uses the stack to get the string into a buffer in the correct order (most significant digit first, which is calculated last). **Convert into a buffer, then pass that buffer to `WriteConsoleA`.** If you look around on Stack Overflow, you can probably find a better duplicate target. If you do, let me know and we can change the duplicate target. – Peter Cordes Aug 26 '16 at 06:44

0 Answers0