assembly

generating sound in assembly 8086

冷暖自知 提交于 2020-02-02 15:01:08
问题 I'm trying to generate a sound with a specific frequency using 8086 assembly. I have searched and searched and found lots of codes regarding connecting to the speaker (not the PC speaker). Yet, none of them seem to work. The following is my code: mov al, 182 ; meaning that we're about to load out 43h, al ; a new countdown value mov ax, 2153 ; countdown value is stored in ax. It is calculated by ; dividing 1193180 by the desired frequency (with the ; number being the frequency at which the

x86 partial register usage

你离开我真会死。 提交于 2020-02-02 11:42:50
问题 If I save a value, let's say 10, in 8 bit register DH and then another value, 15, in 8 bit register DL . Would that work or will they override each other since they are both in 32-bit EDX register? mov $10, %DH mov $15, %DL cmp %DL, %DH jle done Basically I'm just confused when I'm using the 8 bit register how will it affect the 32 bit register and vice versa. Thanks. Also, can you save the value 7 in EDX and DH and DL would still have their own values or will they now have 7? 回答1: DL is the

How does noexcept in C++ change the assembly?

自作多情 提交于 2020-02-02 11:18:17
问题 How does noexcept in C++ change the assembly? I tried a bit with small functions, in godbolt, but the assembly did not change. float pi() //noexcept // no difference { return 3.14; } int main(){ float b{0}; b = pi(); return 0; } I am looking for a minimal working example, where I can see a change in the assembly due to noexcept . 回答1: Pretty simple examples can be constructed that involve destructors directly rather than introspection on noexcept status: void a(int); void b() noexcept; void c

How does noexcept in C++ change the assembly?

余生长醉 提交于 2020-02-02 11:18:04
问题 How does noexcept in C++ change the assembly? I tried a bit with small functions, in godbolt, but the assembly did not change. float pi() //noexcept // no difference { return 3.14; } int main(){ float b{0}; b = pi(); return 0; } I am looking for a minimal working example, where I can see a change in the assembly due to noexcept . 回答1: Pretty simple examples can be constructed that involve destructors directly rather than introspection on noexcept status: void a(int); void b() noexcept; void c

avoiding text relocations when mixing c/c++ and assembly in a .so

人走茶凉 提交于 2020-02-01 09:11:39
问题 I am trying to remove all text relocations from an .so that mixes c, c++ and assembly. For c/c++ -fpic takes care of PIC. On Android ARM target, we are able to call exported asm functions from c/c++ without causing text relocations. But in our implementation we have arrays of data that must be accessible from both C++ and assembly. On C++ it's a plain old array i.e. extern "C" { __declspec(align(32)) int16_t myarray[256]; } and on asm side we use .global myarray . The second we use such a

avoiding text relocations when mixing c/c++ and assembly in a .so

十年热恋 提交于 2020-02-01 09:11:30
问题 I am trying to remove all text relocations from an .so that mixes c, c++ and assembly. For c/c++ -fpic takes care of PIC. On Android ARM target, we are able to call exported asm functions from c/c++ without causing text relocations. But in our implementation we have arrays of data that must be accessible from both C++ and assembly. On C++ it's a plain old array i.e. extern "C" { __declspec(align(32)) int16_t myarray[256]; } and on asm side we use .global myarray . The second we use such a

Linux X86-64 assembly and printf

不打扰是莪最后的温柔 提交于 2020-02-01 05:04:25
问题 I am reading some linux assembly manuals and found idea about using printf() function. I need it to output register values for debugging reasons in binary form to terminal, but now I am tried simply to test that function with text. I am stuck, because of segfault when I am using pushq instead of pushl. How can I change this program to output strings and binary form of registers? .data input_prompt: .string "Hello, world!" printf_format: .string "%5d " printf_newline: .string "\n" size: .long

How to perform low-level IO with a USB flash drive under the BIOS (compared to a floppy)?

老子叫甜甜 提交于 2020-01-31 10:18:11
问题 I have recently been studying some bootstrap code which was intended for use with a floppy drive. My goal is to modify the program so that it uses my USB flash drive. Now I see how the INT 13H function has been used with the floppy device, but I guess my question is, how will communicating with the USB drive differ? For example, here is a snippet of the floppy code (GNU assembler): movb $0x00,%dl /* select 1st floppy */ /* later */ movw sec,%cx /* get sector number */ movw head,%dx /* get

How to perform low-level IO with a USB flash drive under the BIOS (compared to a floppy)?

你说的曾经没有我的故事 提交于 2020-01-31 10:18:10
问题 I have recently been studying some bootstrap code which was intended for use with a floppy drive. My goal is to modify the program so that it uses my USB flash drive. Now I see how the INT 13H function has been used with the floppy device, but I guess my question is, how will communicating with the USB drive differ? For example, here is a snippet of the floppy code (GNU assembler): movb $0x00,%dl /* select 1st floppy */ /* later */ movw sec,%cx /* get sector number */ movw head,%dx /* get

Understanding gcc -S output

陌路散爱 提交于 2020-01-30 14:35:08
问题 I did gcc -S on the very complex program below on x86_64: int main() { int x = 3; x = 5; return 0; } And what I got was: .file "main.c" .text .globl main .type main, @function main: .LFB0: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 movl $3, -4(%rbp) movl $5, -4(%rbp) movl $0, %eax leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE0: .size main, .-main .ident "GCC: (GNU) 4.4.7 20120313 (Red Hat 4.4.7-3)" .section .note.GNU-stack,"",