nasm

Can I POP a value from the stack, but put it nowhere in NASM Assembly?

白昼怎懂夜的黑 提交于 2020-07-29 06:51:12
问题 NASM Assembly, Ubuntu, 32-bit program. Normally, when popping a value from the stack, I'll do POP somewhere Into a register or a variable. But sometimes, I simply don't want to put it anywhere - I just want to get rid of the next element in the stack. Doing POP Just like that won't work. A workaround I had was to make a 4-byte variable I don't use at all and dump the POP into it. Is there a better way to achieve this? 回答1: Adjust the stack pointer by four bytes (or some other amount),

直接在x86硬件上显示图片(无os)

对着背影说爱祢 提交于 2020-07-28 08:25:09
1 任务   为了学习计算机底层和os,我给自己布置了一个任务:在x86硬件上,使用c和nasm来显示一张bmp图片。完成这个任务,前后估计花了2个月的业余时间。   这个任务涉及了很多知识点,包括:启动区、保护模式、nasm汇编、c和nasm汇编互调、ld链接、硬盘io读取、显卡调色板模式、bmp图片格式、bios中断指令、c指针操作内存、borch虚拟机、binutils工具集、makefile等。 2 环境 ubuntu borchs nasm和 c PS: c代码遵循google的C++ 风格指南,使用gnu99标准 。 3步骤 3.1 生成一个10M的硬盘镜像   bximage是borchs软件包的一个小工具,可以用于生成硬盘或软盘镜像。打开终端,输入:bximage。按照如下图所示的,一步一步地操作。 最终会在当前目录下,生成一个名为10M.img的文件。 3.2 准备一张320*200的bmp图片   为简单起见,屏幕的分辨率使用320*200。因此我们的bmp图片的大小320*200。我准备了一张图片,如下,这是我家主子的靓照。   将文件命名为cat-666.bmp,然后写入到#201扇区 dd if =src/cat-ham.bmp of=10M.img bs=512 seek=201 conv=notrunc 3.3 引导区   引导区位于启动盘的#0扇区

Centos7安装FFmpeg

雨燕双飞 提交于 2020-07-24 18:42:23
第一部分:基础知识简介 1. FFmpeg介绍 FFmpeg是一个完整的,跨平台的解决方案,用于记录,转换和流化音视频.其中FF代表Fast Forword 2. FFmpeg的组件 包含libavcodec,libavutil,libavformat,libavfilter,libavdevice,libscale和libswresample,以及ffmpeg,ffplay和ffprobe,如图所示 [ lidengyin@ldy ~ ] $ ffmpeg --version ffmpeg version 4.1 Copyright ( c ) 2000-2018 the FFmpeg developers built with gcc 4.8.5 ( GCC ) 20150623 ( Red Hat 4.8.5-39 ) configuration: --prefix = /usr/local/ffmpeg --enable-libx264 --enable-gpl libavutil 56. 22.100 / 56. 22.100 libavcodec 58. 35.100 / 58. 35.100 libavformat 58. 20.100 / 58. 20.100 libavdevice 58. 5.100 / 58. 5.100 libavfilter 7. 40

Why does my data section appear twice in the compiled binary? Ubuntu, x86, nasm, gdb, reaelf

▼魔方 西西 提交于 2020-07-21 03:52:31
问题 A prior related question was answered. Thank you! However this creates a new question for me. Why does nasm put data bytes at two different memory locations? I include program information and other data dump below. ---------- code snippet compiled with nasm, ld ----------------- section .text ... zero: jmp short two one: pop ebx xor eax, eax mov [ebx+12], eax mov [ebx+8], ebx mov [ebx+7], al lea ecx, [ebx+8] lea edx, [ebx+12] mov al, 11 int 0x80 two: call one section .data align=1 msg: db '

Why does my data section appear twice in the compiled binary? Ubuntu, x86, nasm, gdb, reaelf

邮差的信 提交于 2020-07-21 03:49:07
问题 A prior related question was answered. Thank you! However this creates a new question for me. Why does nasm put data bytes at two different memory locations? I include program information and other data dump below. ---------- code snippet compiled with nasm, ld ----------------- section .text ... zero: jmp short two one: pop ebx xor eax, eax mov [ebx+12], eax mov [ebx+8], ebx mov [ebx+7], al lea ecx, [ebx+8] lea edx, [ebx+12] mov al, 11 int 0x80 two: call one section .data align=1 msg: db '

How can I get nasm to work as a command in terminal in MacOS?

丶灬走出姿态 提交于 2020-07-05 03:32:05
问题 I have been trying to get nasm to work as a command in terminal, but nothing seems to be working. I just keep getting the error: nasm: error: unable to find utility "nasm", not a developer tool or in PATH So, first, I tried updating my PATH variable. I tried editing the PATH variable: safecrackers-MacBook-Pro-2:Library safecracker$ export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Library/Libraries/nasm-2.14/ safecrackers-MacBook-Pro-2:Library safecracker$ nasm nasm: error: unable to

Segfault when loading function parameter into a register

拜拜、爱过 提交于 2020-06-28 05:04:21
问题 I'm quite new to x86 assembly, and I'm trying to build off a hello world program. I'm trying to make a subroutine, that writes a single byte to stdout, but i've hit a problem. The line mov ebx, [esp+1] (to load the byte passed, when I call the subroutine) causes a segfault. I've tried xoring the ebx register with itself, to make sure that it is empty, to make sure, that it doesn't mess with the syscall _start: push 32h call _writeByte ; This just jumps to an exit routine jmp _exit _writeByte:

Problems with getcwd syscall on OSX

坚强是说给别人听的谎言 提交于 2020-06-28 02:56:07
问题 Does anyone have an idea how to get the current working directory in OSX with NASM? The syscall getcwd isn't available on osx and dtruss pwd return lots of stat sys calls. However in the manual I can't find which structure variable of stat returns the current working directory. Thanks. 回答1: That's a bit late answer, but nonetheless this can be achieved using 2 syscalls. open_nocancel 0x2000018e (or open 0x2000005) opening a file descriptor for current dir fcntl_nocancel 0x20000196 (or fcntl

GDB complains No Source Available

让人想犯罪 __ 提交于 2020-06-24 12:04:04
问题 I'm running on Ubuntu 12.10 64bit. I am trying to debug a simple assembly program in GDB. However GDB's gui mode (-tui) seems unable to find the source code of my assembly file. I've rebuilt the project in the currently directory and searched google to no avail, please help me out here. My commands: nasm -f elf64 -g -F dwarf hello.asm gcc -g hello.o -o hello gdb -tui hello Debug information seems to be loaded, I can set a breakpoint at main() but the top half the screen still says ' [ No

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