assembly

Should I use “mul” or “imul” when multiplying a signed number to an unsigned number?

爷,独闯天下 提交于 2021-01-01 04:19:30
问题 I have found out that both mul and imul can be used to multiply a signed number to an unsigned number. For example: global _start section .data byteVariable DB -5 section .text _start: mov al, 2 imul BYTE [byteVariable] You can replace imul with mul , and the result would still be the same ( -10 ). Are mul and imul exactly the same when multiplying a signed number to an unsigned number, or is there a difference between them? 回答1: The upper half is different, as mentioned in the comments. If

Program solving expression in assembly

丶灬走出姿态 提交于 2020-12-31 04:43:51
问题 I have a problem with my simple program in assembly. I'm using DOSBox and TASM. The problem is that the operand types don't match in lines 76, 78, and 80. This is after multiplication. I tried to make some changes by using a different variable size. ; -------------------------------------------- ; Equation=(a+c*b)/d-2*c, ; -------------------------------------------- .model small .stack 100h .data a db 0 b db 0 c db 0 d db 0 result1 db ? result2 db ? message1 db "Equation: (a+c*b)/d-2*c a=$"

Program solving expression in assembly

别说谁变了你拦得住时间么 提交于 2020-12-31 04:43:29
问题 I have a problem with my simple program in assembly. I'm using DOSBox and TASM. The problem is that the operand types don't match in lines 76, 78, and 80. This is after multiplication. I tried to make some changes by using a different variable size. ; -------------------------------------------- ; Equation=(a+c*b)/d-2*c, ; -------------------------------------------- .model small .stack 100h .data a db 0 b db 0 c db 0 d db 0 result1 db ? result2 db ? message1 db "Equation: (a+c*b)/d-2*c a=$"

Use of Turbo Assembler

吃可爱长大的小学妹 提交于 2020-12-30 03:38:31
问题 I use an IBM processor, and I have barely begun to delve into x86 assembly. Now that I have thoroughly read through an assembly book, I decided to put a simple program to the test (one that prints an exclamation mark on the screen): .MODEL SMALL .CODE MOV AH,2h MOV DL,21h INT 21h INT 20h END Now, there was a similar example in the book titled Peter Norton's Assembly Language Book for the IBM PC that went along these lines: .MODEL SMALL .CODE MOV AH,2h MOV DL,2Ah INT 21h INT 20h END I assume

Use of Turbo Assembler

坚强是说给别人听的谎言 提交于 2020-12-30 03:37:42
问题 I use an IBM processor, and I have barely begun to delve into x86 assembly. Now that I have thoroughly read through an assembly book, I decided to put a simple program to the test (one that prints an exclamation mark on the screen): .MODEL SMALL .CODE MOV AH,2h MOV DL,21h INT 21h INT 20h END Now, there was a similar example in the book titled Peter Norton's Assembly Language Book for the IBM PC that went along these lines: .MODEL SMALL .CODE MOV AH,2h MOV DL,2Ah INT 21h INT 20h END I assume

Printing hex from dx with nasm

守給你的承諾、 提交于 2020-12-30 02:56:54
问题 I actually want to print the content of the dx register with nasm. Thereby the content is a 16 bit hex digit such as 0x12AB. Therefore I've first implemented a function which is able to print a string: print_string: pusha mov ah, 0xe print_character: mov al, [bx] inc bx or al, al jz print_done int 0x10 jmp print_character print_done: popa ret You can use this function in this way: mov bx, MSG call print_string MSG: db 'Test',0 Now i want to have a function, which converts the hex to a string,

Printing hex from dx with nasm

坚强是说给别人听的谎言 提交于 2020-12-30 02:56:52
问题 I actually want to print the content of the dx register with nasm. Thereby the content is a 16 bit hex digit such as 0x12AB. Therefore I've first implemented a function which is able to print a string: print_string: pusha mov ah, 0xe print_character: mov al, [bx] inc bx or al, al jz print_done int 0x10 jmp print_character print_done: popa ret You can use this function in this way: mov bx, MSG call print_string MSG: db 'Test',0 Now i want to have a function, which converts the hex to a string,

Is there a way to flush the entire CPU cache related to a program?

荒凉一梦 提交于 2020-12-29 12:08:36
问题 On x86-64 platforms, the CLFLUSH assembly instruction allows to flush the cache line corresponding to a given address. Instead of flushing the cache related to a specific address, would there be a way to flush the entire cache (either the cache related to the program being executed, or the entire cache), for example by making it full of dummy contents (or any other approach I would not be aware of): using only standard C++17? using standard C++17 and compiler intrinsics if necessary? What

Is there a way to flush the entire CPU cache related to a program?

亡梦爱人 提交于 2020-12-29 12:00:17
问题 On x86-64 platforms, the CLFLUSH assembly instruction allows to flush the cache line corresponding to a given address. Instead of flushing the cache related to a specific address, would there be a way to flush the entire cache (either the cache related to the program being executed, or the entire cache), for example by making it full of dummy contents (or any other approach I would not be aware of): using only standard C++17? using standard C++17 and compiler intrinsics if necessary? What

gedit syntax highlighting for assembler files (*.asm)

元气小坏坏 提交于 2020-12-28 07:48:43
问题 By default, gedit doesn't syntax highlight .asm files. How can I add this support for this language? 回答1: The following steps should be enough. wget http://www.carminebenedetto.net/_downloads/asm-intel.lang sudo cp asm-intel.lang /usr/share/gtksourceview-3.0/language-specs/ Note that the exact folder to copy the .lang file to depends upon your version. You may have gtksourceview-2.0 instead, or even something else. On my machine I had both 2.0 and 3.0, and copied the file into each one's