Skip to content

Instantly share code, notes, and snippets.

View Warunajith's full-sized avatar

Warunajith Bandara Warunajith

  • University of Kelaniya
View GitHub Profile
// create class
class Bike {
var name = ""
var gears = 0
}
// create object of class
var bike1 = Bike()
class Bike {
var name = ""
var gear = 0
}
protocol Greet {
// blueprint of a property
var name: String { get }
// blueprint of a method
func message()
}
print(taylor.clothes)
print(other.shoes)
let taylor = Person(clothes: "T-shirts", shoes: "sneakers")
let other = Person(clothes: "short skirts", shoes: "high heels")
struct Person {
var clothes: String
var shoes: String
}
-T link.ld -melf_i386 # emulate 32 bits ELF, the binary output is specified
# in the linker script
-m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles
-nodefaultlibs
OUTPUT_FORMAT("binary") /* output flat binary */
SECTIONS
{
. = 0; /* relocate to address 0 */
.text ALIGN(4):
{
start.o(.text) /* include the .text section of start.o */
*(.text) /* include all other .text sections */
extern kmain
section .text
; push argv
; push argc
call kmain
; main has returned, eax is return value
jmp $ ; loop forever