nasm

64 bit version of socketcall system call Linux

自闭症网瘾萝莉.ら 提交于 2020-01-15 07:43:04
问题 In 32 bit, there is a system call called socketcall which is a common kernel entry point for the socket system calls. However, in 64 bit mode, I can't seem to find the corresponding system call. Is there a similar system call I can use that has the same functionality? 回答1: The man page states: On a some architectures--for example, x86-64 and ARM--there is no socketcall() system call; instead socket(2), accept(2), bind(2), and so on really are implemented as separate system calls. 来源: https:/

Declaring variable-sized arrays in assembly

余生长醉 提交于 2020-01-15 05:21:07
问题 I'm writing an assembly program which I want to be able to do the (basic) following: x = 100; y = int[x] E.g. the size of y depends on the value of x. NOTE: I am using NASM instruction set on a 64 bit Ubuntu system. In assembly I know that the size of an array needs to be declared in the data section of the file e.g. myvariable resq 1000 The problem is I won't know how big to make it till I have done a previous calculation. What I really want is something like: mov rax, 100 myvariable resq

How to subtract two 64 bit integers in 8086 assembly

寵の児 提交于 2020-01-14 14:01:48
问题 Write a program called SUB64 to subtract the 64-bit integer in memory locations 0x0150 and 0x0154 from the 64-bit integer in 0x0160 and 0x0164. Store the result in memory location 0x0170 and 0x0174. I understand the logic behind separating it into smaller pieces since we can't fit 64 bits into the registers. And I know we subtract the least significant pieces first. I'm struggling with actually coding it. Does it matter which GPIO we use? This is my example, so maybe you can see how I'm

“times 510-($-$$) db 0” does not work

天涯浪子 提交于 2020-01-13 20:32:12
问题 I am learning about boot sectors. I downloaded nasm-installer-x64.exe from the NASM website. My operating system is win7-64bit. When I run the following code it does not work correctly mov ah, 0x0e; mov al, the_secret; int 0x10; mov al, [the_secret]; int 0x10; mov bx, [the_secret]; add bx, 0x7c00; mov al, [bx]; int 0x10; mov al, [0x7c1e]; int 0x10; jmp $; the_secret:; db 'X'; times 510-($-$$) db 0; dw 0xaa55; 回答1: I don't believe there is anything wrong with times 510-($-$$) db 0 . It seems

“times 510-($-$$) db 0” does not work

和自甴很熟 提交于 2020-01-13 20:27:39
问题 I am learning about boot sectors. I downloaded nasm-installer-x64.exe from the NASM website. My operating system is win7-64bit. When I run the following code it does not work correctly mov ah, 0x0e; mov al, the_secret; int 0x10; mov al, [the_secret]; int 0x10; mov bx, [the_secret]; add bx, 0x7c00; mov al, [bx]; int 0x10; mov al, [0x7c1e]; int 0x10; jmp $; the_secret:; db 'X'; times 510-($-$$) db 0; dw 0xaa55; 回答1: I don't believe there is anything wrong with times 510-($-$$) db 0 . It seems

Eject CD/Optical Drive in Assembly Language

流过昼夜 提交于 2020-01-11 10:22:31
问题 This couldn't have been simpler, but isn't budging. I have a simple code that I'm using to see if the optical drive will eject The code is in assembly language, intel nasm syntax. [BITS 16] [ORG 0X07C00] STI Eject: mov ah, 46h mov al, 00h mov dl, 00h int 13h endprogram: times 510-($-$$) db 0 db 0x55 db 0xAA I could simply increase the drive number, but shouldn't this work correctly if the drive was 0? may be the drive start somewhere around 128 decimal Thanks, 回答1: There does not appear to be

Are the prologue and epilogue mandatory when writing assembly functions?

╄→尐↘猪︶ㄣ 提交于 2020-01-11 08:38:10
问题 Recently I rewrote some libc functions in assembly and for some of them (the one that didn't need any call or syscall instructions, like strlen), I discarded the prologue and epilogue because my tests didn't failed without it (maybe they were not complex enough). During peer review, someone told me it was bad practice to discard them, but couldn't explain me why. So, am I running into problems when I call asm functions that don't have the prologue/epilogue combination? Is it a good practice

Translation from NASM to GAS

时间秒杀一切 提交于 2020-01-07 03:10:12
问题 how do I translate mov [ebx], al from NASM to GAS? I tried mov %al, (%ebx) but it does segmentatiob fault. Another question, lets say I have an array in GAS .lcomm array, 50 Do I have to put a dollar($) sign in array like this: mov %rbx, $array or need not to? Any answer would be helpful :) 回答1: How about intel2gas? usage: intel2gas [options] [-o outfile] [infile] where options include: -h this help -i convert from intel to at&t format (default) -g convert from at&t to intel format -m -t

nasm dos interrupt (output string)

匆匆过客 提交于 2020-01-06 17:57:49
问题 I have the following code: %include "io.inc" section .data msg db 'Hello World...$' section .text global CMAIN CMAIN: ;write your code here mov ah,09 mov dx,OFFSET msg int 21h xor eax, eax xor dx,dx ret and it gets the next error: [19:28:32] Warning! Errors have occurred in the build: C:/Users/user/AppData/Local/Temp/SASM/program.asm:12: error: comma, colon, decorator or end of line expected after operand gcc.exe: error: C:/Users/user/AppData/Local/Temp/SASM/program.o: No such file or

Displaying a number - assembly code not working Linux, x64 (NASM)

ε祈祈猫儿з 提交于 2020-01-06 15:06:41
问题 I am learning assembly on Linux (NASM) x64 machine (I don't have access to 32 or 16 bit machine), and I am trying to display number on screen (reverse of number according to code but that's a start). Number is predefined in section .data -> num. I am quite a newbie at assembly programming and due to the lack of material on x64 assembly (really, cant find much, and all I was able to find was quite confusing) I am unable to resolve the issue. The issue is that the code compiles an links with no