Skip to content

Instantly share code, notes, and snippets.

@chrisdel101
Last active March 13, 2021 03:13
Show Gist options
  • Save chrisdel101/b4051c36442d0b616ddb29f11a686e58 to your computer and use it in GitHub Desktop.
Save chrisdel101/b4051c36442d0b616ddb29f11a686e58 to your computer and use it in GitHub Desktop.
Converter ARM
;The semicolon is used to lead an inline documentation
;When you write your program, you could have your info at the top document block
;For Example: Your Name, Student Number, what the program is for, and what it does etc.
;
; See if you can figure out what this program does
;
;;; Directives
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
; Linker requires __Vectors to be exported
AREA RESET, DATA, READONLY
EXPORT __Vectors
__Vectors
DCD 0x20001000 ; stack pointer value when stack is empty
DCD Reset_Handler ; reset vector
ALIGN
;Your Data section
;AREA DATA
FSTART DCD 70
CSTART DCD 22
; The DCD directive allocates one or more words of memory,
; aligned on four-byte boundaries,
; and defines the initial runtime contents of the memory.
;
; For example, data1 DCD 1,5,20
; Defines 3 words containing decimal values 1, 5, and 20
AREA MYRAM, DATA, READWRITE
SUM DCD 0
; The program
; Linker requires Reset_Handler
AREA MYCODE, CODE, READONLY
ENTRY
EXPORT Reset_Handler
Reset_Handler
;;;;;;;;;;User Code Start from the next line;;;;;;;;;;;;
LDR R0, CSTART ;load celcuis start ;R0
LDR R2, FSTART ;load farenheit start ;R2
MOV R11, #9 ;load 9 to mul orig val by ;R11
MOV R12, #5 ;load 5 to mul by ;R12
MUL R1, R0, R11 ;mul R0 * 9 ;R1
SDIV R1, R1, R12 ;div prod by 5
ADD R1, R1, #32 ;converted Cel is in R1
SUB R5, R2, #32; ;subtract from Faren
MUL R4, R5, R12 ;mul diff by 5
SDIV R3, R4, R11 ;div prod by 9
ALIGN
STOP
B STOP
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment