How to count character of a string in assembly not use 0Ah/int21h

How to count character of a string in assembly not use 0Ah/int21h

Content Index :

How to count character of a string in assembly not use 0Ah/int21h
Tag : assembly , By : user171752
Date : November 28 2020, 11:01 PM

help you fix your problem Start with a register pointing to the first character of the string and another register set to zero.
Loop until the contents of the first register are the NUL character (or whatever terminator you want), incrementing both those registers.
    push  r1, r3                 ; preserve registers
    load  r1, address-of-string
    xor   r2, r2                 ; xor a number with itself gives 0
    load  r3, [r1]               ; get memory contents
    beq   endloop                ; if NUL, we're at string end
    inc   r1                     ; otherwise incr both and loop back
    inc   r2
    bra   startloop
    pop   r3, r1                ; restore registers
                                ; r2 now has the length.

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Assembly x86 read a string character by character

Tag : assembly , By : msugar
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:

'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

Tag : assembly , By : user143038
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

 inc bl

 cmp cl,9
 jne input
cmp al,61h
jne no_inc
inc bl
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?

Tag : assembly , By : ChristianM
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?

Tag : assembly , By : ralph okochu
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
   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]

equal:           ; here we are
   mov rax, 0x2000001
   mov rdi, 58
Related Posts Related QUESTIONS :
  • I am not understanding this assemby language program for what(what will be the input or output)
  • What's the difference between the "/FAs command line option" (generate asm output) or the "Goto Disassemb
  • How to pass argv arguments to execv in asm on 64-bit (linux)
  • how to replace a text in a file in assembly using DOS instruction
  • Why is the comparing instruction not working?
  • In MIPS Assembly, how do I truncate to two decimal places if I have a floating point value X.YZDEF in a floating point r
  • How to shift a binary number by filling MSB with 1?
  • How many byes is each instruction compiled to in x86 assembly?
  • What does X mean in EAX,EBX,ECX ... in assembly?
  • How is return address specified in stack?
  • How to write to the console in fasm?
  • reading a BYTE as a DWORD in Masm
  • Print double-word number to string
  • 8086 assembly right mouse click interrupts
  • Assembly program crashes when reading second BMP file
  • how to find the implementation of s_init() which called by lowlevel_init() in uboot
  • How to write two bytes to a chunk of RAM repeatedly in Z80 asm
  • Re-use string at known address to save bytes and reduce size of shellcode payload
  • How to access PCIe configuration space? (ECAM)
  • Is the stack frame of a function cleared, or is it left as such on the stack, when we return from the function
  • Why does SEG not give an error message with this code fragment?
  • x86_64 Opcode encoding formats in the intel manual
  • Should using MOV instruction to set SS to 0x0000 cause fault #GP(0) in 64-bit mode?
  • How to change the foreground color of a string (32 Bit Assembly kernel)?
  • Is this AND+CMP between the same two operands just checking for one of them being zero?
  • segmentation fault while calling functions in nasm assembly
  • String reverse with x64 SSE / AVX registers
  • How Can Assembly Program Multitask Two Or More Tasks In The Same Time?
  • Cortex M7 floating arithmetic instruction duration with zero operand
  • How does mulw, prodl and prodh work together in assembler programming?
  • Questions about APIC interrupt
  • assembly: position of static/ global variables
  • When is the zero flag set?
  • how TEST instruction check if number is EVEN or ODD in assembly language
  • What does "Undefined" mean in Intel's asm documentation? FST effect on C0, C2, C3
  • How to decompile 64-bit binary to retrieve content?
  • BIOS Always Fails to Perform Disk Operations
  • My TSR program freezes when executed a second time
  • ARM assembly syntax in VST/VLD commands
  • Do assembly instructions map 1-1 to machine language?
  • What are the technical mechanics and operation of declaring variables in 32-bit MASM?
  • How are the SCAS and MOVS instructions affected by the value of the direction EFLAG?
  • Pointer to string in stand-alone binary code without .data section
  • How to enable MMU in QEMU (virt machine a57 cpu)
  • mips nested procedure with jr $ra
  • NASM-64bits-segmentation fault calling procedure
  • Is it possible to map a process into memory without mapping the kernel?
  • Index an array with constants with Turbo C++ inline asm
  • SIMD vectorize atan2 using ARM NEON assembly
  • Inline Assembly Procedure Crash When Accessing Arguments
  • Assembly TASM: Multiply 4 digit numbers by 4 digit numbers
  • How do assembly instruction differentiate between register, memory address, immediate value or offset parameter?
  • How can segmentation be used to expand memory?
  • Print spaces between every numbers that's printed in 8086 Assembly
  • the why of MOV command restrictions
  • Why a Word is 2 bytes and not 4 bytes in x86 Assembly?
  • Assembly memory operands clarification
  • Syntax error in assembly when using letter "C"
  • 6502 XASM defini data
  • How do I identify the instruction stored LC-3
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com