Bus error

  • 2 Replies
  • 1253 Views
*

FlatEarthDenial

  • 303
  • FE is anti-science.
Bus error
« on: July 22, 2016, 07:53:26 AM »
So, what do you think exactly causes bus errors on modern computers? Let me give you some examples as short programs in Assembly language. The first four programs can be compiled using Clang, and the fifth one can be compiled using Flat Assembler.

Program #1:
Code: [Select]
.intel_syntax
.global _main
_main:
push rbp
mov rbp,rsp
.rept 2
lea rdi,[rip+helloWorld]
call _printf
.endr
mov rax,0
pop rbp
ret
helloWorld:
.string "Hello world!\n"
Output #1:
Code: [Select]
Hello world!
Hello world!

Program #2:
Code: [Select]
.intel_syntax
.global _main
_main:
push rbp
mov rbp,rsp
lea rdi,[rip+helloWorld]
call _printf
mov al,'_'
mov [rip+helloWorld+5],al
lea rdi,[rip+helloWorld]
call _printf
mov rax,0
pop rbp
ret
helloWorld:
.string "Hello world!\n"
Output #2:
Code: [Select]
Hello world!
Bus error: 10

Program #3:
Code: [Select]
.intel_syntax
.global _main
_main:
push rbp
mov rbp,rsp
sub rsp,16
mov rcx,0
lea rbx,[rip+helloWorld]
l1:
mov al,[rbx]
mov [rsp+rcx],al
inc rbx
inc rcx
cmp al,0
jnz l1
mov rdi,rsp
call _printf
mov al,'_'
mov [rsp+5],al
mov rdi,rsp
call _printf
mov rax,0
add rsp,16
pop rbp
ret
helloWorld:
.string "Hello world!\n"
Output #3:
Code: [Select]
Hello world!
Hello_world!

Program #4:
Code: [Select]
.intel_syntax
.global _main
_main:
push rbp
mov rbp,rsp
call printNumber
lea rdi,[str3+rip]
call _printf
mov esi,[rip+number]
dec esi
mov [rip+number],esi
call printNumber
mov rax,0
pop rbp
ret
str1:
.string "%d\n"
str2:
.string "Printing the number!\n"
str3:
.string "Back to main!\n"
number:
.int 100+30-2
printNumber:
push rbp
mov rbp,rsp
lea rdi,[rip+str2]
call _printf
lea rdi,[str1+rip]
mov esi,[rip+number]
call _printf
pop rbp
ret
Output #4:
Code: [Select]
Printing the number!
128
Back to main!
Bus error: 10

Program #5:
Code: [Select]
format binary as 'COM'
org 100h

mov ah,9
lea dx,[hello]
int 21h

mov al,'_'
mov [hello+5],al

mov ah,9
lea dx,[hello]
int 21h

int 20h

hello:
db "Hello world!",10,13,24h
Output #5:
Code: [Select]
Hello world!
Hello_world!
A former Flat Earther.
This is my story, which I'd encourage every Flat Earther to read:
https://www.theflatearthsociety.org/forum/index.php?topic=67051.0

*

FlatAssembler

  • 609
  • Not a FE-er
Re: Bus error
« Reply #1 on: November 11, 2016, 01:20:12 PM »
Here is a thread on that on a forum about Assemblers:
https://board.flatassembler.net/topic.php?t=19453
Fan of Stephen Wolfram.
This is my parody of the conspiracy theorists:
https://www.theflatearthsociety.org/forum/index.php?topic=71184.0

*

Son of Orospu

  • Jura's b*tch and proud of it!
  • Planar Moderator
  • 37834
  • I have artificial intelligence
Re: Bus error
« Reply #2 on: November 11, 2016, 01:40:35 PM »
Are you a bot?  Answer truthfully and give me your papers!