logs archiveIRC Archive / Undernet / #asm / 2007 / February / 10 / 1
dextre
can some1 help
i've been trying to build an inline assembly function to be called from an inline assembly call..
and it works, but keeps giving me esp errors
i don't know what i'm doing wrong
http://cpp.sourceforge.net/?show=28896
EwICk
you're not specifying the size of your push'es
sum() is expecting two int's, but it's freeing as much
so your stack is corrupted after the first call
dextre
how do i fix it?
EwICk
I don't know if your compiler understands some sort of size specifier for that
but you could always move the two values to a 32-bit register before pushing
dextre
i put "leave" right before "ret"
and the error disappeared
however i don't know what "leave" means
it seems to pair up with "enter" but i am not using enter
EwICk
you're just making it worse
I still have my login thank you tid
Chiu_Lee
one question, just to see that I'm not messing things up: I wrote a bootloader that loads my program into memory. everything works fine. I set the stackpointer to 7c00 which is as usual. now I kept adding code to my program and at one point it started to freeze. I tracked it down to being a "small" stack problem (stack went over my program, loaded at 500, about 22KB). so I changed the stackpointer to FFFF and now everything works ok.
I know this stack will overwrite the bootloader but since I don't need that anymore, I guess it's not a problem. are there any other issues I need to know about with this setup? according to http://stakface.com/nuggets/index.php?id=10&replyTo=0 there shouldn't be anything else there in memory, between my program, bootloder and stack.
am I right or is that chart wrong?
dextre
what does the asm command "ret" do in terms of "mov" ?
what does "ret 8" do ?
CyberWarrior
hmm
8 bytes from stack ?
but actually dunno
lol
         

dbtid
dextre: there are online x86 assembly tutorials
why don't you try to find one?
CyberWarrior
dbtid: what was ret 8 for ?
hehe
dbtid
i don't know; i abhor intel assembly.
CyberWarrior
hmm
dbtid
i do powerpc, and now, arm4
CyberWarrior
i#d guess its a ret into another segment
dbtid
i should say
ARMv4
geez
c-bot intel assembly tutorial
c-bot
dbtid, the magic 8 ball says... you're not making any sense; try again.
dbtid
c-bot google intel assembly tutorial
c-bot
dbtid, searching ...
Programmingtutorials.com - Free Online Programming Tutorials, "http://www.programmingtutorials.com/assembly.aspx"
Assembly Language (x86) Resources, "http://cis.csuohio.edu/~somos/asmx86.html"
My Introductory Assembler Tutorial, "http://www.csn.ul.ie/~darkstar/assembler/"
8086 Microprocessor Emulator with Integrated 8086 Assembler, "http://www.emu8086.com/"
Introduction to Linux Intel Assembly Language, "http://heather.cs.ucdavis.edu/~matloff/50/LinuxAssembly.html"
dbtid
have at it
dextre
ret 8 cleans up 8 bytes
on return
from the stack
i'm just curious what "ret" does by itself
it seems to be the equivalent of "pop ebp jmp ebp"
CyberWarrior
call = jmp but put ip into stack
ret == jmp back to location in stack
so i guess if u use call 12345678:12345678
u need ret 8 to go back
hehe
that 'd at least make sense
dextre: then ret 8 should be pop rbp jmp rbp ;]
hehehe
dextre
why not ebp
rbp ?
what's that
CyberWarrior
64 bit register
dextre
and i don't have access to eip
CyberWarrior
rax rbx rcx rdx ...
;]
dextre
wow cool
call = jmp,, but how do i put the current ip onto stack ?
CyberWarrior
dunno
push $
?
push $+3
push $+4
well
something like that
dextre
push $ ?
         

CyberWarrior
yeah it'll push the offset
$ == current pos
at least for tasm
hehehe
you could probably even use labels
like this
push bla
jmp bla2
bla:
jmp end
bla2:
ret
;]
dextre
i think i got ret to work
CyberWarrior
watcha trying to do ?
dextre
it's "pop ebx jmp ebx" so as to not interfere with eax
i'm trying to understand what is happening on the most basic level
so.. this website i'm reading me tells me that call is "push $+2 jmp _dest_"
CyberWarrior
hmm
$+2 doesnt make sense at all
dextre
push the next instruction, then jmp
yeah :(
CyberWarrior
that should be offset +2
dextre
how do i get the address of the next instruction without labels?
CyberWarrior
no clue
cpu got access to the eip
you cant use it as register
better use labels instead of having a small dasm running to calculate the size of the opcode
hehehe
dextre
okay, i seem to have everything working
i just need one more
ret 8
how does the callee unroll pushed arguments?
i have the 8 there cuz i pushed 2 arguments into the stack before the CALL
so upon return, because i'm using _stdcall, the callee cleans
so ret 8 cleans up 2 32-bit args
add ebp, 8 ?
CyberWarrior
8 byte
dextre
sub ebp, 8
?
CyberWarrior
?
dextre
yah
i'm kinda at loss here
CyberWarrior
esp == stack pointer
dextre
sub esp, 8 ?
CyberWarrior
dunno
dextre
it doesn't like it
i got it
simply pop 3 times
haha
to any reigster
lol
i'm getting a hang of this!
one more question
how do i pop without supplying a register?
can i push and discard?
i mean
pop
pop and discard
CyberWarrior
?
Deathmaster
dextre? what do you want to know? how does ret clean the arguments from the stack?
lol talking to myself, forgot to scroll =))
tiocsti
it doesnt
the caller cleans arguments in c, not callee...this differs from pascal calling convention, where i believe callee is responsible
edcba
indeed
fruitbag
Hey
Any thoughts here on the implementation of a BSP in pure assembly?
A BSP renderer akin ot Doom.
dbtid
only that it's harder to do than in a higher level language
if you mean 'board support package'
fruitbag
Well, dbtid, it would be fun.
dbtid
not my idea of fun
i'm making some mods to u-boot for this board i'm bringing up
fruitbag
Well, I'm obsessed with math ;w
1 2 next »