Skip to content

Instantly share code, notes, and snippets.

@b-adams
Created October 5, 2012 15:14
Show Gist options
  • Save b-adams/3840415 to your computer and use it in GitHub Desktop.
Save b-adams/3840415 to your computer and use it in GitHub Desktop.
Program 3 test example
BR main,i
prompt: .ASCII "Please enter two number\n\x00"
num1: .equate 0 ;local variable #2d
num2: .equate 2 ;local variable #2d
sum: .equate 4 ;local variable #2d
frame: .equate 6 ;total size of num1,num2,sum
;extra junk here
main: NOP0 ;No-op jump point, for legibility
STRO prompt,d ;explain the pause
SUBSP frame,i ;allocate #sum #num2 #num1
;input two numbers and store in memory
DECI num1,s ;get first number
DECI num2,s ;get second number
;add them
LDA num1,s
ADDA num2,s
;store result in a third location
STA sum,s
;output the two numbers and their sum
DECO num1,s
CHARO '+',i
DECO num2,s
CHARO '=',i
DECO sum,s
ADDSP frame,i ;deallocate #num1 #num2 #sum
STOP
.END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment