Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Test file for llvm-m6502
; Generates ADD #123
define i8 @testAdd(i8 %x) {
entry:
%result = add i8 %x, 123
ret i8 %result
}
; Generates ADD 123
define i8 @testLoadAndAdd(i8 %addend) {
entry:
%ptr = inttoptr i16 123 to i8*
%loaded = load volatile i8, i8* %ptr
%result = add i8 %loaded, %addend
ret i8 %result
}
; Generates LDA #123
define i8 @testConst() {
entry:
ret i8 123
}
; Generates LDA 123
define i8 @testLoad() {
entry:
%ptr = inttoptr i16 123 to i8*
%result = load volatile i8, i8* %ptr
ret i8 %result
}
; Generates STX 60
; ADD 60
; (60 is an arbitrary address to store the addend)
define i8 @testSum(i8 %a, i8 %b) {
entry:
; Try switching a and b around!
%result = add i8 %a, %b
ret i8 %result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.