assembly

max/min of an unknown number of inputs in LMC?

倾然丶 夕夏残阳落幕 提交于 2021-01-28 05:14:18
问题 How can I print the maximum/minimum of an unknown number of inputs in LMC? I know that I can SUB INPUT 1 FROM INPUT 2 and see if it is negative or positive but I don't know how to name the inputs so that I can load them. PS: I found this useful link to help me with the ''unknown number of inputs" part How can I store an unknown number of inputs in different addresses in LMC (little-man-computer)? 回答1: You link to code that stores an undetermined number of input values. But in your case that

Confused about pointers and values in Assembly

最后都变了- 提交于 2021-01-28 04:21:52
问题 I'm using the MASM Assembler. Let's look at this short code (from a book I've been reading): .data var1 BYTE 10h .code main proc mov esi,OFFSET byteVal mov al,[esi] ; AL = 10h I didn't exactly understand how byteVal is translated to machine code - I know it's an identifier, a symbolic name. As I understand, at runtime byteVal is the memory address of the value 10h, right? but the book says that these two instructions are the same: mov al var1 mov al,[var1] I don't understand why they do the

x86 explanation, number of function arguments and local variables

*爱你&永不变心* 提交于 2021-01-28 04:15:11
问题 The C ABI for the x86-64 system is as follows: Registers rdi, rsi, rdx, rcx, r8, r9 are used to pass arguments in that order. The stack is used for the 7th argument onward. The return value uses the rax register. The rsp register contains the stack pointer. How many function arguments are defined in the blow function bloop ? I think there is only one function argument, rdi . is this correct? How many local variables (not arguments) are declared in the below function bloop ? I think there is

x86 Assembly two jump instructions with the same target

拜拜、爱过 提交于 2021-01-28 04:00:29
问题 I try to understand an example form the book "Practical Malware Analysis" by Michael Sikorski. There is an example on anti disassembly techniques that i don't comprehend. It says that a common technique is to create two conditional instructions namely jump if zero (JZ) and jump if not zero (JNZ) which considered together are actually just one unconditional instruction (this is clear to me). Here are the graphics of the two possible results created by the disassembler. The following quote

ARM assembly : .LANCHOR0

左心房为你撑大大i 提交于 2021-01-28 03:51:44
问题 I am relatively inexperienced with ARM assembly, and need help understanding a few lines. I have used Godbolt to compile C++ 11 code with the ARM gcc 8.2 compiler and got these lines of assembly: .L10: .word .LANCHOR0 I read that .LANCHOR0 are section anchors, but what does that mean? I understand that .word and .data can be used together to declare variables and assign values to memory spaces like this: .data ! start a group of variable declarations x: .word 23 ! int x = 23; But, what does

What is the value of segment registers in 8086?

时光毁灭记忆、已成空白 提交于 2021-01-28 03:09:14
问题 I have just started to read about intel 8086 and have a question concerning its memory. I read that the address bus is 20-bit wide, which means the address space is 1MB, and this space is divided into segments. the question is: the four segment registers, CS , DS , SS and ES , are they read only or I can set their values, and which are their default values? I saw the following assembly tutorial: ORG 100h MOV AX, 0B800h ; set AX = B800h (VGA memory). MOV DS, AX ; copy value of AX to DS. MOV CL

Can't size instruction

这一生的挚爱 提交于 2021-01-28 02:20:50
问题 I was wondering why some assembly instructions can be inferred, but others cannot. For example, in the following program I have: .globl main main: push %rbp mov %rsp, %rbp mov $8, -8(%rbp) mov -8(%rbp), %rax pop %rbp ret I get the following error: stack.s:5: Error: no instruction mnemonic suffix given and no register operands; can't size instruction However, if I change: the 5th line to: movq $8, -8(%rbp) It runs without error. How can all the other operations infer the size, but that

Where are the OSX (XNU) syscalls actually documented?

ぃ、小莉子 提交于 2021-01-28 02:06:37
问题 I'm looking through the syscalls.master file here but it isn't at all documented. Does documentation for the syscalls exist? If not, why not? By documentation I mean an actual explanation of what each syscall does and the meanings of the arguments it takes. 回答1: Apple's position is that the system libraries are the API and stable ABI, syscalls are not. They discourage their direct use, as they can change from release to release of the OS. So, the best documentation you'll see is the man pages

Invalid character (0xe2) in mnemonic

天大地大妈咪最大 提交于 2021-01-28 02:02:47
问题 I have trouble compiling my assembly code. gcc returns: func_select.s:5: Error: invalid character (0xe2) in mnemonic func_select.s:7: Error: invalid character (0xe2) in mnemonic here is the code (lines 5-7): secondStringLength: ‫‪.string " second pstring length: %d‬‬\n" OldChar: .string "‫‪old char: %c,‬‬" NewChar: ‫‪.string " new char: %c,‬‬" How can I fix this? 回答1: Remove the formatting characters embedded in the text. $ charinfo 'secondStringLength:‫‪.string " second pstring length: %d‬‬

error A2008: syntax error :

不羁岁月 提交于 2021-01-28 01:32:33
问题 I'm trying to write a bootloader for an OS I'm developing. I'm getting a syntax error on the first line. Here is my assembly code: .286 ; CPU Type .model TINY ; memory of model ;---------------------- EXTERNS ----------------------------- extrn _BootMain:near ; prototype of C func ;------------------------------------------------------------ ;------------------------------------------------------------ .code org 07c00h ; for BootSector _main: jmp short _start ; go to main nop ;---------------