Message board for the users of flat assembler.
> Windows > Can anyone help me convert nasm code to fasm
or we can say:
"123" -> starting from 1
1 + 0 * 10 = 1
2 + 1 * 10 = 12
3 + 12 * 10 = 123
This will match to atoi function as below:
push %ebx # preserve working registers
mov $0, %eax # initialize the accumulator
mov $0, %ebx # clear all the bits in EBX
mov (%esi), %bl # load next character in BL
inc %esi # and advance source index
cmp $'0', %bl # does character preceed '0'?
jb inval # yes, it's not a numeral jb:jump below
cmp $'9', %bl # does character follow '9'?
ja inval # yes, it's not a numeral ja:jump above
sub $'0', %bl # else convert numeral to int
mull ten # multiply accumulator by ten. %eax * 10
add %ebx, %eax # and then add the new integer
jmp nxchr # go back for another numeral
pop %esi # recover saved registers
This is a subroutine about string to int
Any help would be appreciated!
Suddenly fell in love with fasm
|16 Sep 2020, 15:47||
That is AT&T syntax, and it is the worst possible syntax.
To convert remove all % and $ symbols, reverse the order of operands. change () to , and # to ;
That should get most of it.
|16 Sep 2020, 22:35||
There is no check for something like: "-123".
|17 Sep 2020, 12:41||
< Last Thread | Next Thread >
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.