Programming :: Traverse Byte Array In Assembly Using Nasm As Assembler?
Jun 16, 2010
I am trying to learn assembly using nasm as assembler. I did not found example related to string operation. I had following example code,
global asm_strlen
section .data
section .bss
section .text
[code].....
my problem is at highlighted line, I am not getting how to copy a byte into 4 byte reg. rather what is syntax of mov instruction to mov byte to WORD DWORD etc.
I need to convert an integer to a byte array of size 2 and vice versa. The code shown below works well for positive values but not for negative values. Also, using an array of size four makes the conversion works. However, I am limited to an array of size 2.
I got across a peculiar problem with memcpy.History:writing a code which do flash/Read functionality for SPI Parts.
Implementation: 1.memory map the Flash chip registers to userspace. - fine 2.Issue block read command 3.Just print the data I got, using the memory mapped address - fine I got the correct data. 4.Copy the data to a local buffer from memory mapped address using memcpy - FAIL
UPDATE: on SUSE 11.3 -32 bit the above code worked perfectly, but on SUSE 11.4 - 64bit , Ubantu, Fedora it failed. I am using gcc compiler obviously. I am using i386/x86_64 OS. Processor: Intel core 2 duo, SNB after step 4 , when I dump the data from local buffer every thing is FF.But step 4, if i implement byte by byte copy using assignment operator, it worked.is there any known bug with memcpy? am I missing anything?
In the comment line, I've got the parent node of the current node. Parent node is "User" node. I would like to obtain the children of this parent node, say "name","surname " etc. How can I do this? Is there any function such as : "$parent_nodes->bringChildren('name')".
I am searching for the IDE that can compile and debug a NASM code. I am using ubuntu 10.04 and I can make compile via terminal but I must view registers for educational purposes.
I found on the Internet a rough suggestion to debug code which says to add a line:
An example shows this lists the lines of source that do work.
I do not know where these lines are supposed to go and whether the "notdeadyet" should be a call to a subroutine or what. I only found that "%define" is used to link to external files, so I am confused because what I tried did not work.
(I am unable to use (and learn) any debugging tool for another few weeks and I'd like to progress on this If I can.)
I need to write a module in pure assembler.Now the linker needs symbols out of the kernel library to link to ( module_init, module_exit, printk).Does anybody know the kernel library name, or are these symbols only in the compressed kernel image (vmlinuz) ?And if, how can I link to a compressed kernel image ?
GNU assembler 2.17 And without having to prefix them. I'm skimming through as info page and can't find any pseudo operator or assembler directive of this type. E.g. 74 would be a decimal number. But I want it to be hexa 74 without the need to write 0x74.
NOTE: as is the GNU assembler.
EDIT: Google led me to discover this:
Quote:
If you write numbers without an explicit indication of the base, the most recent `.RADIX S' command determines how they are interpreted. However, on the one hand, it says the most recent and, on the other one, it applies to GASP, the GNU assembler preprocessor. IDK if it is the same as as (the GNU assembler).
It's good that GCC support intel inline disassembly syntax, but it cannot even simply address local variables/parameters properly, making itself stupid and essentially useless, look at the following:
int myfunc(float f){ int x; float fa[8]; asm(".intel_syntax noprefix " "mov eax, [x]
i tried a code to accept a character and print the same ! i can accept it with following code but its not working with printing that character i use NASM version 2.07
Code:
segment .data msg1: db 'Enter a key',10 msg1len: equ $-msg1
Could you please explain the relationship between the languages?For one, is C writing assembly when you compile, does every piece of code end up assembly/hex? Is there a way to convert (?port?) between them?I don't understand much at all of them yet, but I've seen examples where it looks like they are interacting, and an understanding of all of them looks to be important?
i wanna use chmod() in linux x86 [debian 3.7.2 x86] but i have some problem in function argv
look at this function: Code: Select all int chmod(const char *path, mode_t mode);
and mode_t modes: Code: Select all S_ISUID (04000) set-user-ID (set process effective user ID on execve(2))
S_ISGID (02000) set-group-ID (set process effective group ID on execve(2); mandatory locking, as described in fcntl(2); take a new file's group from parent direcق tory, as described in chown(2) and mkdir(2))
[code]...
i know there is some problem in ecx and mode_t value/
I've been converting some C code to assembly for my homework; it was going well but I'm having trouble with a for loop for hours. I could not understand where is the problem and decided to ask. I'm posting the part where I'm having trouble of my C-code and assembly-code; every other part of codes act same and the variable values are same. I'm waiting this two codes to act same, but they don't.
I'm reading "Understanding the Linux Kernel" and came upon this assembly instruction: movl $(__KERNEL_CS << 16), %eax I am curious as to what "<<" means/does. I tried to gooogle, but google doesn't search for "<<".
I'm learning C and trying to write a program to convert gigabyte into byte. It will take 50% of the value given and then convert that value into byte. But the problem is the output goes into minus / negative value. Like, if I enter 22, I get output: -2147483648.
Code:
#include <stdio.h> #include <math.h> main (int argc, char* argv[]) {
In words, AND the byte at memory location 45 with immediate value 03. As reports "Ambiguous operand size for and". How could I code the instruction such that as understands my intention?
john: .byte 45 and byte[john],03 gives the same error.
if the address of stWndClass is 403000h, WHY it would be compile as mov eax,[esi+403004] and the first one would be mov eax,[esi+4]? I know how to get the values 403004h and 4,but do not know why.
I have read where C is first converted to Assembly before its final compilation to binary. Is there a way to do this with Bash commands? I would like the understanding that Assembly allows to Bash somehow.
I'm trying to write an extension to PHP which means coding in C. I'm really really rusty at C coding and was never very good at it.
Can anyone propose an efficient, safe, and [hopefully] future-proof way of reversing a double? Keep in mind that it should work on as many systems as possible and on 32- and 64-bit systems (and on ???-bit systems in the future?). Will the size of a 'double' ever change or will it always be 8 bytes?
I've tried this and it doesn't work...the compiler complains about "invalid operands to binary" because I'm trying bitwise shiftw on a non-integer.
I thought there exists a built-in function that gives total size of a list object in byte. So using the function produces 1 for a1, 3 for a2. I haven't found such function or module yet.
I'm writing a PHP program. I've encountered a problem; in the following code I try to pass $_POST['delete'] which is an array as the value of a hidden input to some form, but it doesn't do so.there's something wrong with converting PHP array into HTML array. I'm sure that $_POST['delete'] is not null and is a real array.
(I am using vector() and matrix() functions from "Numerical recipes in C".)There are 100 numbers to be stored in 2D array of 10 rows and 10 columns.100 numbers are stored in a 1D array.I get "segmentation fault" at the line indicated in the segment of my code below: