Assembly x86 read a string character by character
Date : March 29 2020, 07:55 AM
will be helpful for those in need A string is only an array. So the first letter is for example in "edx" the second letter in "edx+1" the third letter in "edx+2" and so on.. You can convert the characters back to integers with this calculation: "123"
'1' (or 49 in dec) - 48 = 1
'2' (or 50 in dec) - 48 = 2
'3' (or 51 in dec) - 48 = 3
|
assembly language count all 'a' in character input
Date : March 29 2020, 07:55 AM
I wish this helpful for you my code supposed to count all character 'a' in every user input i use cmp if equal then my program jump to 'incre:' that increment the value of bl.the output is always this>ΒΆ< .i don't know where the problem is , You've got a typo in your code: mov ah,02h
mov dh,bl <-- HERE
int 21h
cmp al,61h
je incre
cmp cl,9
je incre <-- Wrong. al didn't equal 'a', so we shouldn't jump to incre.
jmp input
cmp al,61h
je incre
cmp cl,9
je done ; We're done. Jump past the end of the loop without incrementing bl
jmp input
incre:
inc bl
cmp cl,9
jne input
done:
cmp al,61h
jne no_inc
inc bl
no_inc:
cmp cl,9
jne input
|
Debug code regarding parsing a string character by character in NASM assembly for IA32
Tag : linux , By : user112141
Date : March 29 2020, 07:55 AM
To fix this issue I am a novice in assembly programming.I stumbled across a program in which i am required to write a code to take a string and a number from the user and increment each character of the string by the given number. , Near the end: mov edx,count
movzx edx, byte [count]
|
How to count character and line from a string in assembly?
Date : March 29 2020, 07:55 AM
wish helps you When reading characters, they are only 8 bits wide, so only read and compare 8 bit values mov al, [msg+rcx]
inc rcx
cmp al, 0
je exit
cmp al, 10
jne lp
inc rbx
jmp lp
|
How can I compare the first character of a string with another character in x86-64 assembly?
Date : March 29 2020, 07:55 AM
seems to work fine I'll explain the changes side-by-side (hopefully that's easier to follow): global start
section .data
msg: db "Hello, World!", 10, 0
section .text
start:
mov rdx, msg
mov al, [rdx] ; moves one byte from msg, H to al, the 8-bit lower part of ax
mov ah, 'H' ; move constant 'H' to the 8-bit upper part of ax
cmp al, ah ; compares H with H
je equal ; yes, they are equal, so go to address at equal
mov rax, 0x2000001
mov rdi, [rdx]
syscall
equal: ; here we are
mov rax, 0x2000001
mov rdi, 58
syscall
|