Re: increment values from stdin
- From: Markus Pitha <spamtrap@xxxxxxxxxx>
- Date: Mon, 19 Mar 2007 11:28:49 +0100
Hello,
thanks for your explanations. There is still something different I don't
understand. I tried to use a different method for writing out numbers
bigger than 9 with shifting the bits to the left. First of all, I tried it
with reading a single char from stdin and I tried to "add" a "B", so the
output should be "AB". It should be 16 bit:
01000001......A
01000010......B
but that doesn't work because I get this output:
$ ./movetest
Enter a char: A
B
$ ./movetest
Enter a char: 123456789
B56789
It seems that the first 4 bytes are replaced by the 'B' but how does this
happen? I don't move 4 bytes anywhere.
Here is my test program:
segment .data
prompt1 db "Enter a char: ", 0
len equ $-prompt1
segment .bss
input1 resb 16
segment .text
global _start
_start:
mov eax, 4 ; write system call
mov ebx, 1 ; stdout (=1)
mov ecx, prompt1
mov edx, len
int 0x80 ; syscall
mov eax, 3 ; read system call
mov ebx, 0 ; stdin(0)
mov ecx, input1
mov edx, 16 ; input length in byte
int 0x80
;move it to the left and add a 'B'
mov ecx, [input1]
shl ecx, 8 ;move it 8 bytes to the left
mov ecx, 'B'
mov [input1], ecx
;output
mov eax, 4 ; write system call
mov ebx, 1 ; stdout (=1)
mov ecx, input1
mov edx, 16
int 0x80
mov eax, 1 ; kernel exit
mov ebx, 0
int 0x80
What did I do wrong this time?
Thanks,
Markus
.
- Follow-Ups:
- Re: increment values from stdin
- From: Frank Kotler
- Re: increment values from stdin
- From: Tim Roberts
- Re: increment values from stdin
- References:
- increment values from stdin
- From: Markus Pitha
- Re: increment values from stdin
- From: Frank Kotler
- Re: increment values from stdin
- From: Markus Pitha
- Re: increment values from stdin
- From: Frank Kotler
- increment values from stdin
- Prev by Date: Exceptions & Segmentation
- Next by Date: Re: Optimization Questions
- Previous by thread: Re: increment values from stdin
- Next by thread: Re: increment values from stdin
- Index(es):
Relevant Pages
|
|