NASM, Jumping, and I'm new to this...
Hello. If anyone here knows assembly I'd sure like you to help me out. Here is my file:
Code:
section .text ;linker things, right? Thanks |
First, You have TEST and CMP confused. TEST is used to check for the existance of certain bits in an operand, then sets FLAGS. CMP subtracts the two operands and sets FLAGS. For what you want to do, replace TEST with CMP and the example will work.
Second, { msg db "Hello! It works!\n",0xa } this would be correct had you been using a C function like printf to output msg. But since you are using the write syscall, your \n will not be interpreted and a \n will be outputted as well. For a newline you will have to use 0xA, the ASCII LineFeed character, for a newline (which was at the end of msg). Third, the general purpose registers are: 32-bit: eax ebx ecx edx esi edi ebp esp eflags, eip (not for general use) 16-bit: ax bx cx dx si di bp sp 16-bit segment registers: CS, SS, DS, ES, FS, GS 8-bit(high): ah bh ch dh 8-bit(low): al bl cl dl Hope I helped... |
using '\n' with write is fine
|
Quote:
I said that you cannot use \n with the write SYSCALL. I also said \n would be ok had KneeLess been using C to output msg, but he is not. The C function write can accept \n, but sycall #4 (write) does not accept escape sequences. |
Incase you need proof, try running this code...
Code:
; no_newline.s Code:
~> nasm -f elf no_newline.s |
All times are GMT -5. The time now is 06:24 PM. |