I have been learning how to program x86 assembly on windows. I am using NASM to assemble, and MinGW GCC to link the program with glibc so that I can have access to a basic print function. Here is my code:
global _main
extern _printf
section .text
_copystring:
; ebx : our string
; ecx : our buffer
call _copyloop
ret
_copyloop:
cmp byte[ebx], 0
je _copyret
mov ah, byte[ebx]
mov byte[ecx], ah
add ebx, 1
add ecx, 1
jmp _copyloop
_copyret:
ret
_main:
push message
call _printf
add esp, 4
mov ebx, gb_msg
mov ecx, buffer
call _copystring
push buffer
call _printf
add esp, 4
ret
section .data
message db 'Hello, World', 10, 13, 0
gb_msg db 'goodbye!', 10, 13, 0
section .bss
buffer: resb 128
This is what I use for compiling:
nasm -fwin32 -o test.obj test.asm
gcc -o test test.obj -m32
What it does is print a message to the screen. Then it copies another string into a buffer (which is declared in .bss). The weird part is that when I opened the .exe executable in 7-zip (an archiving program) and viewed the .bss section in notepad, I expected that there should be 128 bytes hard coded in. To my amazement, there are none... In fact, there is no data in the .bss section. The program works perfectly fine, and I am not really concerned at the moment about my assembly skills so far, but I am mainly wondering why there is no data in the .bss section of the program. Any ideas?