assembly

x86 NASM Indirect Far Jump In Real Mode

拈花ヽ惹草 提交于 2021-02-05 08:51:15
问题 I have been messing around with a multi-stage bootloader and I have got all of my code to work, except for the last part: The Jump . I have gotten this code to work out before now but I wanted to make it more modular by replacing this line: jmp 0x7E0:0 With this one: jmp far [Stage2Read + SectorReadParam.bufoff] Instead of hard coding where the code will load in, I wanted to do an indirect jump to it. Here's the rest of my code: ; This is stage 1 of a multi-stage bootloader bits 16 org 0x7C00

How to fix 'Error: junk at end of line, first unrecognized character 0xe2' in Assembly

半世苍凉 提交于 2021-02-05 08:41:08
问题 I am trying to write a basic arm assembly file on my raspberry pi 3 that has access to printf and scanf through the gcc compiler, but upon compiling my code I get a strange error. This is my third application written in assembly to use the gcc compiler, so I wanted to do incremental testing so I set up my prompts and strings, and I try and exit cleanly; however, this is my code that throws the error: .data .balign 4 promptNum1: .asciz “Please enter some number that you want to work with”

How to compile this asm code under linux with nasm and gcc?

时光总嘲笑我的痴心妄想 提交于 2021-02-05 08:24:14
问题 I have the following source snippet from a book that I'm reading now. So I created an asm file and typed exactly. Then used nasm command ( nasm -f elf test.asm ) then tried to compile into an executable file by using gcc ( gcc test.o -o test ) then I get the following error. Error: ld: warning: ignoring file test.o, file was built for unsupported file format which is not the architecture being linked (x86_64) Source code: [BITS 16] [SECTION .text] START: mov dx, eatmsg mov ah, 9 int 21H mov

Matching the intel codes to disassembly output

試著忘記壹切 提交于 2021-02-05 08:18:52
问题 I'm starting to use the Intel reference page to look up and learn about the op codes (instead of asking everything on SO). I'd like to make sure that my understanding is OK and ask a few questions on the output between a basic asm program and the intel instruction codes. Here is the program I have to compare various mov instructions into the rax -ish register (is there a better way to say "rax" and its 32- 16- and 8- bit components?): .globl _start _start: movq $1, %rax # move immediate into

Matching the intel codes to disassembly output

大兔子大兔子 提交于 2021-02-05 08:18:49
问题 I'm starting to use the Intel reference page to look up and learn about the op codes (instead of asking everything on SO). I'd like to make sure that my understanding is OK and ask a few questions on the output between a basic asm program and the intel instruction codes. Here is the program I have to compare various mov instructions into the rax -ish register (is there a better way to say "rax" and its 32- 16- and 8- bit components?): .globl _start _start: movq $1, %rax # move immediate into

DOS assembly read two succeeding characters, and convert to number

[亡魂溺海] 提交于 2021-02-05 08:17:26
问题 I'm writing a simple program that takes in two numbers between 1-99, adds them and prints out the result. I'm done with the printing part, I can print up too three digits, 99+99=198 so it's enough for this program. I have the program working for two one digit numbers. Example: 1 1 = 2 , 4 4 = 8 So the digits is separated by spaces. Now I need the following; 11 1 = 12, 1 45 = 46 what I got so far, when I first read a valid number i store it on the stack while I check what the next char is, if

Allocate writable memory in the .text section

跟風遠走 提交于 2021-02-05 08:12:10
问题 Is it possible to allocate memory in other sections of a NASM program, besides .data and .bss ? Say I want to write to a location in .text section and receive Segmentation Fault I'm interested in ways to avoid this and access memory legally. I'm running Ubuntu Linux 回答1: If you want to allocate memory at runtime , reserve some space on the stack with sub rsp, 4096 or something. Or run an mmap system call or call malloc from libc, if you linked against libc. If you want to test shellcode /

Generated Assembly For Pointer Arithmetic

▼魔方 西西 提交于 2021-02-05 08:11:09
问题 This is a simple question but I just came across it. In the code snippet below I create three pointers. I know the three will exhibit equivalent behavior (all point to the same thing), but I honestly thought the third action in the code was the most "efficient", meaning that it would generate less assembly instructions to accomplish the same thing as the other two. I assumed that the first two have to first deference a pointer, and then take the memory address of the thing that was

Generated Assembly For Pointer Arithmetic

情到浓时终转凉″ 提交于 2021-02-05 08:10:08
问题 This is a simple question but I just came across it. In the code snippet below I create three pointers. I know the three will exhibit equivalent behavior (all point to the same thing), but I honestly thought the third action in the code was the most "efficient", meaning that it would generate less assembly instructions to accomplish the same thing as the other two. I assumed that the first two have to first deference a pointer, and then take the memory address of the thing that was

How to link C language libraries?

喜欢而已 提交于 2021-02-05 08:09:10
问题 I am interested in executing a function which is written in C language:- //filename "CLang.c" #include<stdio.h> void fun() { printf("Hello World"); } I want to call this fun() through assembly language which i have written:- (NASM 64bit) ; filename "MyASM.asm" section .data section .bss section .text global _start _start: call fun mov rax,60 ; exit mov rdi,1 syscall I have created object file by using these commands nasm -f elf64 MyAsm.asm and gcc -c CLang.c . When I merge these two file with