assembly

Hello, world in assembly language with Linux system calls?

喜夏-厌秋 提交于 2020-06-23 18:05:10
问题 I know that int 0x80 is making interrupt in linux. But, I don't understand how this code works. Does it returning something? What $ - msg standing for? global _start section .data msg db "Hello, world!", 0x0a len equ $ - msg section .text _start: mov eax, 4 mov ebx, 1 mov ecx, msg mov edx, len int 0x80 ;What is this? mov eax, 1 mov ebx, 0 int 0x80 ;and what is this? 回答1: How does $ work in NASM, exactly? explains how $ - msg gets NASM to calculate the string length as an assemble-time

where to get the I/O port addresses assignment

青春壹個敷衍的年華 提交于 2020-06-23 06:43:27
问题 I've been learning assembly language recently, and I already know how to use the in/out command. But I have some questions: where did the port addresses come from, like 0x70. How do I know how many ports my computer has and the addresses of them. I've checked the Intel developer's manual, but I can't find the answer. Thank you for your attention 回答1: There's a maximum of 65536 IO ports, and most aren't used. The IO ports that are used on a modern PC can be split into 2 categories: PCI devices

where to get the I/O port addresses assignment

你说的曾经没有我的故事 提交于 2020-06-23 06:42:42
问题 I've been learning assembly language recently, and I already know how to use the in/out command. But I have some questions: where did the port addresses come from, like 0x70. How do I know how many ports my computer has and the addresses of them. I've checked the Intel developer's manual, but I can't find the answer. Thank you for your attention 回答1: There's a maximum of 65536 IO ports, and most aren't used. The IO ports that are used on a modern PC can be split into 2 categories: PCI devices

Scanf ARM Assembly

我与影子孤独终老i 提交于 2020-06-23 05:16:09
问题 I know there's a question here but I really don't understand what the OP did. I've used x86 assembly before and for that you'd do something like this: push dword int1 push dword fmtInput call scanf add esp, 12 ; value is now in int1 my guess for ARM is something like this ldr r0, fmtInput push r1 @ says this is too complex, tried `ldr r1` but that also failed saying that ldr needed more inputs bl scanf @ I'm assuming the value is now in r1 I'm sure I'm missing something simple but I'm really

How can I tell if a number is a multiple of four using only the logic operator AND?

梦想的初衷 提交于 2020-06-22 08:08:05
问题 I'm messing with assembly language programming and I'm curious how I could tell if a number is a multiple of 4 using the logic operator AND? I know how to do it using "div" or "remainder" instructions but I'm trying to do this with bit manipulation of number/word. Can anyone point me in the right direction? I'm using MIPs but a Language agnostic answer is fine. 回答1: Well, to detect if a number is a multiple of another, you simply need to do x MOD y . If the result is 0 , then it is an even

segment limit check in AMD 64-bit mode

一世执手 提交于 2020-06-17 17:07:29
问题 I am writing my own OS for 64bit processors and I am stuck with the problem of general protection. My OS will not rely on page fault to implement user space protection mechanism, so I found there is a way to do it with segment limit checking: This presentation from VMWare http://download3.vmware.com/vmworld/2005/pac346.pdf on page 20 says: Initial AMD64 architecture did not include segmentation in 64-bit mode Segmentation also missing from EMT64T How do we protect the VMM ? 64-bit guest

Why does not XORing %eax causes segfault? [duplicate]

别等时光非礼了梦想. 提交于 2020-06-17 13:21:25
问题 This question already has answers here : Segmentation fault on printf - NASM 64bit Linux (1 answer) Calling printf in x86_64 using GNU assembler (2 answers) main and stack alignment (1 answer) Why does System V / AMD64 ABI mandate a 16 byte stack alignment? (1 answer) Closed 12 days ago . .text having this: str: .string "string" .globl main main: xor %eax, %eax #is commented causes segfault leaq str(%rip), %rdi call printf xorq %rdi, %rdi call exit Does printf uses %rax ? or is the segfault

string comparison in 8086

Deadly 提交于 2020-06-17 03:36:08
问题 I have problem with this question. I don't know what it wants from me. Question : Write a procedure that compares a source string at DS:SI to a destination string at ES:DI and sets the flags accordingly. If the source is less than the destination, carry flag is set. if string are equal , the zero flag is set. if the source is greater than the destination , the zero and carry flags are both cleared. My Answer : MOV ESI , STRING1 MOV EDI, STRING2 MOV ECX, COUNT CLD REPE CMPSB Still I am not

Copying to arrays in NASM

╄→尐↘猪︶ㄣ 提交于 2020-06-16 08:41:53
问题 I have to write in assembly code which copy 100 bytes in memory in loop. I wrote it like this: section .data a times 100 db 1 ;reserve 100 bytes and fill with 1 b times 100 db 0 ;reserve 100 bytes and fill with 0 section _start global _start _start: mov rsi, a ;get array a address mov rdi, b ;get arrat b address _for: ;początek pętli cmp cx, 100 ;loop jae _end_for ;loop push cx ;loop mov byte al, [rsi] ;get one byte from array a from al mov byte [rdi], al ;put one byte from al to array b inc

Assembly language (arrays)

筅森魡賤 提交于 2020-06-15 05:09:27
问题 I'm new to assembly language and everything seems a little complicated. I'm programming an old MCU (68hc11), I'm trying to migrate from C language to assembly code using the 68hc11 instructions. I want to solve 2 different situations: FIRST CASE I want to write a program in assembly that counts the number of POSITIVE, NEGATIVE, and ZERO values that exist inside a given array. DO NOTE that all values inside ARRAY could be all positive or all negative or all zeros,do you get me? So I should