assembly

NES(6502 assembly) Sprites movement

本秂侑毒 提交于 2020-04-07 05:42:07
问题 I am currently working on a NES(6502) assembly game but I dont understand how to make a sprite move.Heres how I think its supposed to works: (loop) LDA $200 ;will load into the A register the content of address $200,wich contain the Y postion of my sprite INA ;Increment the A register wich would increment the content of A wich is the Y position of my sprite..? However it seems that you cannot increment the A register accumulator because I get an error when trying to assemble with the INA

Why can't I make a char array longer than 61 characters in C? [duplicate]

限于喜欢 提交于 2020-04-07 05:27:14
问题 This question already has an answer here : Error 13: Invalid or unsupported executable while booting simple kernel in grub with string literal (1 answer) Closed 2 years ago . I'm following this tutorial to make a simple bare bones 32-bit operating system. I have gotten as far as section 4 where i'm writing to the frame buffer. Basically i'm attempting to create my own println function. Here is the code for my function: /** fb_write_cell: * Writes a character with the given foreground and

Why this code run into infinite loop in ARM

大憨熊 提交于 2020-04-07 05:17:25
问题 I am learning ARM assembly and compiled a code which simply ran a loop 5 times but when ran it goes to infinite loop .global main main: push {ip.lr} sub r1,r1,r1 well: ldr r0,=message bl printf add r1,r1,#1 cmp r1,#6 bne well pop {ip,pc} message: .ascii "Amit Singh Tomar\n" Why this code runs in to infinite Loop? 回答1: printf call destroys your r1 . Save your loop invariant in non-scratch register. 回答2: R1 gets trashed by the call to printf - use a non-volatile register instead or save/restore

MUL function in assembly

这一生的挚爱 提交于 2020-04-05 08:20:30
问题 I am trying to make a simple multiply action in assembly but for some reason i do not see the registers change when the MUL function is marked. mov bx, 5 mov cx, 10 mul cx 回答1: These are called instructions , and they specify operations that are to be performed by the processor. mov is a mnemonic for mov e, while mul is a mnemonic for mul tiply. Other common instructions include add , sub , and div . I trust you can figure out what operation these specify! Most instructions take two

NASM Segmentation fault when modifying a variable that should be in the read-write .data section (section .data doesn't work without a space?)

核能气质少年 提交于 2020-04-05 06:41:45
问题 I'm having an issue with a program I'm writing in NASM using SASM, I'm using a variable as a counter and once I modified it and try to to save the new value at the used address in memory I get a segmentation fault. Here are the bits of code concerning the variable: section.data p_count DW 0 section.text global CMAIN CMAIN: mov ebp, esp; for correct debugging mov bx, [p_count] inc bx mov [p_count], bx ret The program stops running when it arrives at the last line here. Anyone has an idea what

Errors on assembling ARM asm on an x86 PC with GCC or `as`

无人久伴 提交于 2020-04-05 06:13:09
问题 So I have been doing an assembly tutorial, and I got stuck in the very beginning. Project name: asmtut.s The Code: .text .global _start start: MOV R0, #65 MOV R7, #1 SWI 0 Right off the beginning I'm welcomed by 3 error messages after I try this line: as -o asmtut.o asmtut.s asmtut.s:6: Error: expecting operand after ','; got nothing asmtut.s:7: Error: expecting operand after ','; got nothing asmtut.s:9: Error: no such instruction: 'swi 0' I'm confused, because this is the exact code in the

Errors on assembling ARM asm on an x86 PC with GCC or `as`

心不动则不痛 提交于 2020-04-05 06:12:12
问题 So I have been doing an assembly tutorial, and I got stuck in the very beginning. Project name: asmtut.s The Code: .text .global _start start: MOV R0, #65 MOV R7, #1 SWI 0 Right off the beginning I'm welcomed by 3 error messages after I try this line: as -o asmtut.o asmtut.s asmtut.s:6: Error: expecting operand after ','; got nothing asmtut.s:7: Error: expecting operand after ','; got nothing asmtut.s:9: Error: no such instruction: 'swi 0' I'm confused, because this is the exact code in the

How can I call printf normally in assembly without @PLT but just call printf with -l option in gcc with standard library,

巧了我就是萌 提交于 2020-03-26 06:48:09
问题 I want to call printf in assembly and link it using gcc -l option with standard library, But it says: Symbol `printf' causes overflow in R_X86_64_PC32 relocation Segmentation fault (core dumped) this is How i compile: gcc mod.s -l:libc.so -o mod when I replace libc.so with libc.a, It still shows Sementation fault .file "mod.c" .text .section .rodata .LC0: .string "%d" .text .globl main .type main, @function main: pushq %rbp movq %rsp, %rbp subq $16, %rsp movl $3, -8(%rbp) movl $2, -4(%rbp)

Confusing brackets in MASM32

北慕城南 提交于 2020-03-23 08:18:12
问题 I am trying to get to grips with MASM32 and am confused by the following: I thought that brackets were used for indirection so if I have the a pre-defined variable .data item dd 42 then mov ebx, item would put the contents of 'item', i.e. the number 42, into ebx and mov ebx, [item] would put the address of 'item', i.e. where the 42 is stored, into ebx. But the following code in a console app: mov ebx, item invoke dwtoa, ebx, ADDR valuestr invoke StdOut, ADDR valuestr mov ebx, [item] invoke

Using variable vs. using number

∥☆過路亽.° 提交于 2020-03-23 04:11:25
问题 Imagine a function in those versions: int faculty(const unsigned int n) { return n == 1 ? n : n * faculty(n - 1); } int faculty(const unsigned int n) { return n == 1 ? 1 : n * faculty(n - 1); } The only difference is that I return n in the first and 1 in the second one, depending on n . The result is the same but is there any other difference you could be aware of while ignoring the significance? I know there is a high chance the compiler will make the same assembly instructions out of it,