Hey /prog/, I am learning Pentium Assembly on linux, using nasm assembler. I've been having trouble with the stack operations. Could somebody explain how I can simply push 4 integers(hex/dec) onto the stack, and then later pop them off? I get some really weird messages when I try to do this.
>>5
What part of read the Intel manuals because giving no code at all nor any of those weird error messages make you look like a retarded newbie just like that noko in the sage field do you not understand?
Name:
Anonymous2011-04-25 16:44
; following code will output "Lisp sucks"
mov rdx, mypenis
mov rcx, 9001
call setSize
call doesLispSuck
test rax, rax
jnz lisp_sucks
mov rdx, NOT_SUX_TEXT
call puts
ret
lisp_sux:
mov rdx, SUX_TEXT
call puts
ret
>>8
You suck at asm and have obviously not read your SICP to be hating on Lisp.
Here's how to write it:
.code
start:
call DoYouFail
push dword ptr [eax+pFailures]
call puts ; using fast printf is left to the user (see: http://dis.4chan.org/read/prog/1279520490/3 )
ret
; valid return value: 0 or 1
DoYouFail:
xor eax,eax
inc eax
ret
>>12
That should be _start, and you can't just ret from it.
section .code
_start: mov edx, hnHungarianNotationConsideredHarmful
mov esi, hnHungarianNotationConsideredBeneficial
call failp
cmovz edx, esi
push edx
call puts
syscall1 1,0 ; macro left as an exercise for the reader
failp: xor eax, eax
inc eax
ret
section .data
hnHungarianNotationConsideredHarmful: db 'FAIL',0
hnHungarianNotationConsideredBeneficial: db 'FAIL ANYWAY',0
Setting a register to zero by xoring it with itself has been slower since probably the Pentium Pro. Similarly, swapping the values of two registers is faster using an additional temporary register, even if you have to save its value on the stack.
Hmm, I ended up figuring it out, thanks guys. Right now I'm trying to use the stack to convert from hex to decimal. Let's say I have the hex value: 2B3A. I first take each character, starting from the left, and push it on the stack. So if I had 2B3A, I would end up with this:
ESP -> 10
3
11
2
I'm trying to figure a good way to convert this to decimal