nasm

add 16 bits to 64 bits register [duplicate]

这一生的挚爱 提交于 2020-01-30 08:38:28
问题 This question already has answers here : Issue storing a byte into a register x86-64 assembly (1 answer) Why can't I move directly a byte to a 64 bit register? (2 answers) Closed 2 years ago . Here is what i want to do: add rsi, word [rsi+16] I want to read the unsigned short value which is at rsi+16 adress. And i want to add this value to rsi. Here is the error i get in nasm: s2.asm:62: error: mismatch in operand sizes This is strange. Why nasm and my cpu are not able to add 16 bits to 64

add 16 bits to 64 bits register [duplicate]

喜夏-厌秋 提交于 2020-01-30 08:38:26
问题 This question already has answers here : Issue storing a byte into a register x86-64 assembly (1 answer) Why can't I move directly a byte to a 64 bit register? (2 answers) Closed 2 years ago . Here is what i want to do: add rsi, word [rsi+16] I want to read the unsigned short value which is at rsi+16 adress. And i want to add this value to rsi. Here is the error i get in nasm: s2.asm:62: error: mismatch in operand sizes This is strange. Why nasm and my cpu are not able to add 16 bits to 64

calling printf from assembly language on 64bit and 32bit architecture using nasm

强颜欢笑 提交于 2020-01-30 04:04:56
问题 I want to call printf function from assembly language in linux. i want to know the method for for 64 bit and 32 bit assembly language programs. 1) please tell me for two cases if i want to pass a 32 bit arguement and 64 bit arguement in printf with a string. how should i do it? 2) for x86 32 bit architecture if i want to do the same thing as in point 1. please tell me the code. and let me know do i need to adjust the stack for both cases and do i just need to pass the arguements in registers?

assembly x86 qemu: fatal: Trying to execute code outside RAM or ROM

て烟熏妆下的殇ゞ 提交于 2020-01-24 11:23:36
问题 I'm working on a very basic shell where the only command currently is 'help'. If you type something wrong, you're informed that the command isnt recognized. Somewhere in the segment and stack setup I have a bug that causes the shell to spit out some nonsense after I type anything and then freeze completely. Error I get in terminal qemu: fatal: Trying to execute code outside RAM or ROM at 0xff0fe990 EAX=0000ffe0 EBX=0000ffff ECX=ff00e990 EDX=0000e000 ESI=000001a4 EDI=0000011e EBP=00000019 ESP

assembly x86 qemu: fatal: Trying to execute code outside RAM or ROM

故事扮演 提交于 2020-01-24 11:23:26
问题 I'm working on a very basic shell where the only command currently is 'help'. If you type something wrong, you're informed that the command isnt recognized. Somewhere in the segment and stack setup I have a bug that causes the shell to spit out some nonsense after I type anything and then freeze completely. Error I get in terminal qemu: fatal: Trying to execute code outside RAM or ROM at 0xff0fe990 EAX=0000ffe0 EBX=0000ffff ECX=ff00e990 EDX=0000e000 ESI=000001a4 EDI=0000011e EBP=00000019 ESP

What is proper way to call execve with arguments in assembly?

穿精又带淫゛_ 提交于 2020-01-24 11:17:50
问题 I am trying to execute the following with execve : /bin//nc -lnke /bin/bash -p 4444 When reading the man page for execve , I see the following requirements: int execve(const char *filename, char *const argv[], char *const envp[]); The issue I am running into is pushing arguments to argv ; I do not understand how you push an array (in assembly) for this to work properly. The assembly that I am currently using is below: global _start _start: xor eax, eax ; command push eax push 0x636e2f2f push

What is proper way to call execve with arguments in assembly?

安稳与你 提交于 2020-01-24 11:17:30
问题 I am trying to execute the following with execve : /bin//nc -lnke /bin/bash -p 4444 When reading the man page for execve , I see the following requirements: int execve(const char *filename, char *const argv[], char *const envp[]); The issue I am running into is pushing arguments to argv ; I do not understand how you push an array (in assembly) for this to work properly. The assembly that I am currently using is below: global _start _start: xor eax, eax ; command push eax push 0x636e2f2f push

What does double dollar sign mean in x86 assembly (NASM)

家住魔仙堡 提交于 2020-01-21 12:04:12
问题 The expression is: times 512-($-$$) db 0 I know what the dollar sign means but I don't know what it means when it's double. What does the double dollar sign mean? 回答1: When all else fails, Read The Fine Manual (section 3.5 "Expressions"): NASM supports two special tokens in expressions, allowing calculations to involve the current assembly position: the $ and $$ tokens. $ evaluates to the assembly position at the beginning of the line containing the expression; so you can code an infinite

NASM Print one Character at a Time

﹥>﹥吖頭↗ 提交于 2020-01-21 09:02:07
问题 How come this program is not printing out to the screen, am I missing something on the INT 80 command? section .bss section .data hello: db "Hello World",0xa ;10 is EOL section .text global _start _start: mov ecx, 0; ; int i = 0; loop: mov dl, byte [hello + ecx] ; while(data[i] != EOF) { cmp dl, 0xa ; je exit ; mov ebx, ecx ; store conetents of i (ecx) ; Print single character mov eax, 4 ; set sys_write syscall mov ecx, byte [hello + ebx] ; ... mov edx, 1 ; move one byte at a time int 0x80 ;

Calling Convention of Floats in Nasm

二次信任 提交于 2020-01-17 03:43:06
问题 So recently we learned about floating point operations and got a few questions as a homework. One of those is: "Write down the calling convention of single precision floats!". So i know about the xmm registers and know that on double precision the first input goes into xmm0 and so on. I looked up the topic on Google but couldn't find the answer. Would be nice if someone could help me on this question. 回答1: Every calling convention I'm familiar with handles single float the same as it does