3

Problem: in assembler, i want to proceed an string byte by byte. How can i do this?

My try:

Mov ebx, 0
S:
Mov eax, [var +ebx]
;somethin
Add ebx, 1
Jmp s

But it doesnt cut off the thing rigth

Comments
  • 1
    How's your string terminated? Is it terminated with null? You need a jump if your byte is null
  • 1
    @philcr really? Will try it out tomorrow (im located in germany :))
  • 1
    @linuxer4fun is that a sarcastic really???

    Currently your loop will keep going forever once it starts, as nothing defines the length of the string and gives you an exit.

    Is this x86 assembler?
  • 0
    @philcr yes... Ok so, i will tell u the more complex details... So first: 64 linux nasm. I have to check, if a variable contains an string element. When the dezimal value of the momchar is less than 48 or greater than 57, it should give an error, but it now gives also an error, when i oinput 56 or stuff.
  • 2
    Use gdb to check the run your code line by line and check for the register values. It's incredibly useful!
  • 1
    That is something of the like:

    while(True){
    // Do something...
    }

    I won't tell you the answer, because I'm almost sure it's homework, but I can point to you to something.

    Check out the book "Assembly: step-by-step", written by Jeff Duntemann.

    It's an awesome book, it's for x86 Linux (you're using 32bit registers instead of 64, those are RAX, RBX...) and in a chapter, he explains very well how to process a "string", he builds a "hex viewer"
  • 1
    @apex actually its more like an private prpjekt with my prof (compilerbuilding). So: how can is use gdb? Because, whenever i open it, and run a file, it doesnt halt
  • 0
    Well, if you take a mi it and read what I actually pointed out, you'll learn to use gdb.

    Also, I'd recommend kdbg or Nemiver, both work great for debugging ASM, but I personally enjoy more kdbg
Add Comment