I've just picked up learning assembly language coding.
Q: Convert a character string that represents any signed integer to its 2’s complement value, with the result stored in consecutive locations of memory in little endian order.
For example - 1 = 0xFFFFFFFFFFFFFFFE assuming 2's complement codewards are 64-bit. I've done the number -149 in my code which should result in 0xffff ffff ffff ff6b
.data
S: .string "-149"
Result: .quad
.text
.globl main
main:
mov S,%rax
cmp %rax,0
jl positive
sub %rax,%rax
not S
add S,%rax
sub $30,%rax
not %rax
add $1, %rax
mov %rax,Result
positive:
sub $30,%rax
not %rax
add $1,%rax
mov %rax,Result
In GDB, the value for the string integer stored is this.
(gdb) x/24xb &S
0x601038: 0x2d 0x31 0x34 0x39 0x00 0x00 0x00 0x00
0x601040: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x601048: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
if I wanted to do any computations to -149, I'd have to somehow access these locations in the memory - how do I go about doing this?
If I know that the 4 is in the 10's place, I could multiply it by 10 to get 40 and then add the 9 and similiar 1x100 to get 100 and add that as well.
How do I access them to do the computation?