diff options
author | daniel-Jones <daniel@danieljon.es> | 2018-01-09 19:43:55 +1030 |
---|---|---|
committer | daniel-Jones <daniel@danieljon.es> | 2018-01-09 19:43:55 +1030 |
commit | e4f040f94e27d1dbb4af3baef99b336da188938d (patch) | |
tree | 216304b8dfbf29adb6cafc8bd74f467e1a41fcd7 | |
download | 8085-assembly-tasks-e4f040f94e27d1dbb4af3baef99b336da188938d.tar.gz 8085-assembly-tasks-e4f040f94e27d1dbb4af3baef99b336da188938d.zip |
first code push
-rw-r--r-- | TASK1.asm | 20 | ||||
-rw-r--r-- | TASK2.asm | 22 | ||||
-rw-r--r-- | TASK2_VER2.asm | 16 | ||||
-rw-r--r-- | TASK3.asm | 15 |
4 files changed, 73 insertions, 0 deletions
diff --git a/TASK1.asm b/TASK1.asm new file mode 100644 index 0000000..164e0db --- /dev/null +++ b/TASK1.asm @@ -0,0 +1,20 @@ +; ADD NUMBERS IN MEMORY 00H -> NEXT 00H BYTE, STORE RESULT IN C + +JMP START +START: LXI H,00H ; HL AS MEMORY POINTER + MVI C,00H ; CLEAR C + MOV B,C ; CLEAR B +NEXT: MOV A,M ; SET ACCUMULATOR TO VALUE AT MEMORY ADDRESS + CPI 00H ; COMPARE ACCUMULATOR WITH 00H + JZ END ; JUMP IF ZERO + INX H ; INCREASE POINTER + JMP SAVE ; JUMP TO SAVE +SAVE: MOV B,A ; STORE ACCUMULATOR IN B + MOV A,C ; MOVE C INTO ACCUMULATOR + ADD B ; ADD B + MOV C,A ; STORE NEW ADDED VALUED IN B + MVI A,00H ; CLEAR ACCUMULATOR + MOV B,A ; CLEAR B + JMP NEXT ; NEXT BYTE + END: HLT ; HALT + diff --git a/TASK2.asm b/TASK2.asm new file mode 100644 index 0000000..7ebd238 --- /dev/null +++ b/TASK2.asm @@ -0,0 +1,22 @@ +; MULTIPLY TWO NUMBERS TOGETHER, STORE IN MEMORY AT 00H +; MULTIPLICATION IS NOTHING MORE THAN REPEATED ADDITION + +JMP START +N1: EQU 05H ; MULTIPLICAND +N2: EQU 03H ; MULTIPLIER +N3: EQU 00H ; MEMORY LOCATION TO STORE RESULT +START: LXI H,N3 ; H AS MEMORY POINTER TO OUTPUT LOCATION 00H + MVI C,0 ; CLEAR C + MOV B,C ; CLEAR B + MOV A,B ; CLEAR A + MVI C,N2 ; MOVE N2 INTO C, THIS IS OUR COUNTER +ADD: MOV B,A ; STORE A IN B + MVI A,00H ; STORE 00H IN A + CMP C ; COMPARE C TO A + MOV A,B ; PUT B BACK INTO A + JZ END ; IF C == 0 JUMP TO END + ADI N1 ; ADD N1 TO A + DCR C ; DECREMENT C + JMP ADD ; JUMP TO ADD +END: STA N3 ; STORE A + HLT ; HALT
\ No newline at end of file diff --git a/TASK2_VER2.asm b/TASK2_VER2.asm new file mode 100644 index 0000000..d83a1eb --- /dev/null +++ b/TASK2_VER2.asm @@ -0,0 +1,16 @@ +; MULTIPLY TWO NUMBERS TOGETHER, STORE IN MEMORY AT 00H +; MULTIPLICATION IS NOTHING MORE THAN REPEATED ADDITION + +JMP START +N1: EQU 05H ; MULTIPLICAND +N2: EQU 03H ; MULTIPLIER +N3: EQU 00H ; MEMORY LOCATION TO STORE RESULT +START: LXI H,N3 ; H AS MEMORY POINTER TO OUTPUT LOCATION 00H + MVI C,0 ; CLEAR C + MOV A,C ; CLEAR A + MVI C,N2 ; MOVE N2 INTO C, THIS IS OUR COUNTER +ADD: ADI N1 ; ADD N1 TO A + DCR C ; DECREMENT C + JNZ ADD ; IF C == 0 JUMP TO END + STA N3 ; STORE A IN MEMORY AT N3 + HLT ; HALT
\ No newline at end of file diff --git a/TASK3.asm b/TASK3.asm new file mode 100644 index 0000000..e7fea45 --- /dev/null +++ b/TASK3.asm @@ -0,0 +1,15 @@ +; CALL ACTS LIKE A FUNCTION CALL IN C, A SUBROUTINE +; CALL COUNT AND COUNT TO C FROM B +JMP START + +START: MVI B,00H ; COUNT FROM 0 + MVI C,05H ; COUNT TO 5 + MOV A,B ; COUNT FROM B + CALL CNT ; CALL COUNT SUBROUTINE + HLT ; HALT +CNT: CMP C ; COMPARE C TO A + RZ ; RETURN IF C==A + INR A ; A++ + JMP CNT ; LOOP + +
\ No newline at end of file |