Hallo
iB,
Ich habe gerade dieses Stück Code in (nasm) Assembler geschrieben. Vielleicht kann jemand davon etwas lernen.
Source -> Programm:
Zitat:
$ nasm -felf prog.asm
$ gcc -o test prog.o
|
Programm ausführen mit:
Programm Source:
Zitat:
global main
extern puts
extern printf
section .rodata
strFormat db "%c",0
strEmpty db "",0
string db "Hello World!",0
section .text
main:
sub esp, 0x10
; /// COUNT THE CHARS ///
mov eax, string
xor ecx, ecx
dec ecx
dec eax
.COUNT
inc eax
movzx edx, byte [eax]
inc ecx
test edx, edx
jne .COUNT
; /// PRINT THE CHARS REVERSED ///
.PRINT
test ecx, ecx
je .END
dec eax
mov [esp+8], ecx
mov [esp+0xc], eax
mov edx, strFormat
movzx eax, byte [eax]
mov [esp+4], eax
mov [esp], edx
call printf
mov ecx, [esp+8]
mov eax, [esp+0xc]
dec ecx
jmp .PRINT
.END:
; /// NEW LINE ///
mov [esp], dword strEmpty
call puts
add esp, 0x10
ret
|
Viel Spass.
bye, pantheros
PS: Ja ich gebs zu, ich habs scheisse kommentiert :-( :P