| | |
Assembly wierdness
![]() |
Almost all of these beginners are using 16-bit REAL Mode versions of the assembler. Very few are actually using 32-bit.
I am very aware of Virtual Memory, Code Segments, Data Segments, Stack Segments, Extra Segments, etc. Come from different physical memory in a 32-bit model. You can use 32-bit registers in REAL mode provided the processor is a 386 or above. There were no clear indications in their code that his person is pure Protected Mode. Granted they didn't have the tell-tale .ORG $100
Okay in reviewing his code, his crash dump clearly shows he's using 32-bit code!
I am very aware of Virtual Memory, Code Segments, Data Segments, Stack Segments, Extra Segments, etc. Come from different physical memory in a 32-bit model. You can use 32-bit registers in REAL mode provided the processor is a 386 or above. There were no clear indications in their code that his person is pure Protected Mode. Granted they didn't have the tell-tale .ORG $100
Okay in reviewing his code, his crash dump clearly shows he's using 32-bit code!
Last edited by wildgoose; Aug 17th, 2009 at 7:07 pm.
I installed MinGW since I'm running windows to get the GNU compiler for Windows.
And I modified your code. Your code would run but would crash in the end. I added returns to each function so it wasn't printing all the functions each time. Adding the return to _main solved the crash. It appears NASM-with the Win library doesn't need the .START declaration as it appears to be calling the procedure _main.
And I modified your code. Your code would run but would crash in the end. I added returns to each function so it wasn't printing all the functions each time. Adding the return to _main solved the crash. It appears NASM-with the Win library doesn't need the .START declaration as it appears to be calling the procedure _main.
Assembly Syntax (Toggle Plain Text)
[section .data] hello: db 'Hello world!', 10, 0 ;15 bytes nl: db ' ', 10, 0 ;3 bytes [section .text] global _main, _print_nl, _print_msg, _return extern _printf _print_nl: push nl call _printf add esp, 4 ret _print_msg: push hello call _printf add esp, 4 ret _return: mov eax, 0 ret _main: call _print_msg call _print_nl call _print_msg call _return ret
I ran your code and it doesn't do anything 
This is my code, the same thing but without the functions:

This is my code, the same thing but without the functions:
asm Syntax (Toggle Plain Text)
[section .data] hello: db 'Hello world!', 10, 0 ;15 bytes nl: db ' ', 10, 0 ;3 bytes [section .text] global _main extern _printf _main: push hello call _printf add esp, 4 push nl call _printf add esp, 4 push hello call _printf add esp, 4 mov eax, 0 ret
Last edited by tomtetlaw; Aug 18th, 2009 at 3:32 am.
...
wildgoose -
Please consult the Narue tutorial that tomtetlaw was talking about:
http://www.daniweb.com/forums/thread41309.html
Pay attention to the discussion of the C calling convention.
Please consult the Narue tutorial that tomtetlaw was talking about:
http://www.daniweb.com/forums/thread41309.html
Pay attention to the discussion of the C calling convention.
while (CPU is present) {some assembly required}
So EvenBit. I read the pdf. Read the NASM documents. My modified version of tomtetlaw's code works on the NASM and MinGW installations I had to install just to run his code, and it ran! I am using the standard C method CDECL calling conventions, just like in the PDF. I have no idea why his code doesn't run unless he has a different version of GNU which has other requirements. Except for a few quirks, NASM is similar to MASM, which is my primary assembler and that I have been programming professionally for a very long time.
Is the compiler he's using using fastcall, or stdcall instead of cdecl? CDECL is typically a C languge method.
So enlighten me please!
Is the compiler he's using using fastcall, or stdcall instead of cdecl? CDECL is typically a C languge method.
So enlighten me please!
Last edited by wildgoose; Aug 18th, 2009 at 3:43 pm.
![]() |
Similar Threads
- Questions about assembly and boolean algebra (Assembly)
- Assembly Programming Question (Assembly)
- How can i use inline assembly in VC++ editor (C++)
- Mips Assembly porting from C (Assembly)
- machine/assembly language, syntax error (C++)
- Using x86 Assembly Language with Microsoft Visual C++ (C++)
Other Threads in the Assembly Forum
- Previous Thread: Win32 functions in NASM
- Next Thread: assembly switch/case macro
| Thread Tools | Search this Thread |





