flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
system error 06 Jan 2017, 17:27
You are misplacing, missing and abusing RET instruction. Your logical path crosses many scope boundaries of a procedure.
|
|||
![]() |
|
dstyl 06 Jan 2017, 17:32
Ok thanks for your help
![]() |
|||
![]() |
|
system error 06 Jan 2017, 17:35
It should be something like
Code: procedureA: call procedureB ret ;----> your main function crosses this boundary due to missing ret statement procedureB: call procedureC ret proceduceC: ;----> again, you're missing the RET here and your code executes your data And put your data in a proper data section. I don't know how NASM allows a LOOP instruction to be used as a label name either. Maybe u should verify that first. Doesn't look right to me. |
|||
![]() |
|
dstyl 06 Jan 2017, 18:04
Code: ; ----------------------------------------------------------------------------- ; A 64-bit program that displays its command line arguments, one per line. ; ; On entry, rdi will contain argc and rsi will contain argv. ; ----------------------------------------------------------------------------- global main extern puts extern printf section .data ;DATA-------------------------------------------------------------------------| format: db "RDI = %d", 10, 0 section .text ;CODE-------------------------------------------------------------------------| main: mov r15, rdi call count ret ;-----------------------------------------------------------------------------| count: push rdi ;sichere register die puts nutzt push rsi ;// sub rsp, 8 ;stack align auf 8byte vor call mov rdi, [rsi] ;verschiebt die speicheradresse ;des argument strings in rdi call puts ;ausgabe des strings add rsp, 8 ;wiederherstellung des stack- ;pointers auf den alten wert. pop rsi ;wiederherstellen der register pop rdi ;rheinfolge beachten! add rsi, 8 ;Zeige auf nächstes arg dec rdi ;Zähle argc runter jnz count ;falls argc != 0 mache weiter call print ret ;-----------------------------------------------------------------------------| print: push rax push rcx mov rsi, r15 mov rdi, format xor rax, rax call printf pop rax pop rcx When i put the data in front of the code as own section it works fine seems to be the trouble with the missing data section. i dont know how to add an special data section in NASM but your advice fixed it thanks for your help ![]() |
|||
![]() |
|
_shura 28 Jan 2017, 10:43
1. print needs an ret too
2. some optimization: Code: jmp print |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.