Skip to content

Instantly share code, notes, and snippets.

@bobrik
Created March 26, 2012 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobrik/2206313 to your computer and use it in GitHub Desktop.
Save bobrik/2206313 to your computer and use it in GitHub Desktop.
lab1 unknown subject
; calculate average of 4 numbers in registers 32-35 and write it to register 8
; ivan bobrov 2012
$MOD52
CSEG
ORG 0016h
MAIN:
; write numbers to data registers
MOV 32,#05
MOV 33,#02
MOV 34,#03
MOV 35,#01
; calculate average of two
MOV A,32
ADDC A,33
; divide by 2
RR A
; remove bit 7
ANL A,#15
; move to resulting register
MOV 8,A
; do the same again with different numbers
MOV A,34
ADDC A,35
RR A
ANL A,#15
; do the same with two results we'we got before
ADDC A,8
RR A
ANL A,#15
; and write it down to register 8
MOV 8,A
; here we go
JMP EXIT
RET
EXIT:
NOP
jmp EXIT
ret
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment