Micro Computer Programs
Micro Computer Programs
Micro Computer Programs
COURSE CODE
PROJECT 1
SECTION ONE
NETWORK FIVE
NO GROUP MEMBERS ID NO
1 MEKONEN HAILE RET/01839/08
2 TESFAYE TEKLU RET/05415/08
3 HELEN HAILE RET/01516/08
4 URGESSA FEYISSA RET/02437/08
5 NATNAEL AMBAW RET /0 /08
1
Question Number One
Algorithm
1. Initialize two arrays that have the same size.
2. Declare another array where the results should be stored.
3. Initialize the counter cx.
4. Get the array element pointed by array pointer.
5. Add array elements and store the results in the third result array.
6. Increment array pointer and decrement counter.
7. Repeat the above three steps until counter equals to zero.
8. Then the program ENDS.
Program
DATA SEGMENT
NUM1 DB 27H,62H,57H,33H
NUM2 DB 34H,21H,32H,55H
RESULT DB 5 DUP(0)
ENDS
CODE SEGMENT
START:
MOV AX,DATA
MOV DS,AX
LEA SI,NUM1
LEA DI,NUM2
2
LEA BX,RESULT
MOV CX,5
LOOP1:MOV AL,[SI]
ADD AL,[DI]
MOV [BX],AL
INC BX
INC SI
INC DI
LOOP LOOP1
MOV AH,4CH
INT 21H
ENDS
END START
----------------------------------------------------------------------------------------------------------------------------
Algorithm
1. Display a message.
2. Read an input from user.
3. Check the value entered if it is between the ranges.
4. If the number entered is not in the range, then the second message will be
displayed and another number will be taken from user.
5. Initialize counter.
6. Multiply the value in Ax with the value in Bx.
3
7. The value of the counter will decrease and the multiplied values will be
stored in Ax.
8. Convert the hex value in to decimal and then in to ASCI code.
9. Display the resulting number in ASCI code.
10.End the program.
Program
name "fact"
push ax
int 10h
pop ax
endm
org 100h
jmp start
result dw ?
start:
mov ah, 9
int 21h
jmp n1
n1:
call scan_num
mov ax, 1
4
cmp cx, 0
je print_result
mov bx, cx
mov ax, 1
mov bx, 1
calc_it:
mul bx
cmp dx, 0
jne overflow
inc bx
loop calc_it
mov result, ax
print_result:
mov ah, 9
int 21h
jmp n2
n2:
call print_num_uns
jmp exit
overflow:
mov ah, 9
int 21h
5
jmp n3
msg3 db 0Dh,0Ah, 'the nunber you entered is too big!', 0Dh,0Ah, 'use values from 0 to 8.$'
n3:
jmp start
exit:
mov ah, 0
int 16h
ret
PUSH DX
PUSH AX
PUSH SI
MOV CX, 0
MOV CS:make_minus, 0
next_digit:
INT 16h
INT 10h
JE set_minus
JNE not_cr
JMP stop_input
not_cr:
6
CMP AL, 8
JNE backspace_checked
MOV DX, 0
MOV AX, CX
DIV CS:ten
MOV CX, AX
PUTC 8
JMP next_digit
backspace_checked:
JAE ok_AE_0
JMP remove_not_digit
ok_AE_0:
JBE ok_digit
remove_not_digit:
PUTC 8
PUTC 8
JMP next_digit
ok_digit:
PUSH AX
MOV AX, CX
MUL CS:ten
MOV CX, AX
7
POP AX
CMP DX, 0
JNE too_big
MOV AH, 0
MOV DX, CX
ADD CX, AX
JC too_big2
JMP next_digit
set_minus:
MOV CS:make_minus, 1
JMP next_digit
too_big2:
MOV CX, DX
MOV DX, 0
too_big:
MOV AX, CX
DIV CS:ten
MOV CX, AX
PUTC 8
PUTC 8
JMP next_digit
stop_input:
CMP CS:make_minus, 0
JE not_minus
8
NEG CX
not_minus:
POP SI
POP AX
POP DX
RET
make_minus DB ?
SCAN_NUM ENDP
PUSH DX
PUSH AX
CMP AX, 0
JNZ not_zero
PUTC '0'
JMP printed
not_zero:
CMP AX, 0
JNS positive
NEG AX
PUTC '-'
positive:
CALL PRINT_NUM_UNS
printed:
POP AX
POP DX
RET
9
PRINT_NUM ENDP
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV CX, 1
CMP AX, 0
JZ print_zero
begin_print:
CMP BX,0
JZ end_print
CMP CX, 0
JE calc
CMP AX, BX
JB skip
calc:
MOV CX, 0
MOV DX, 0
DIV BX
PUTC AL
MOV AX, DX
skip:
PUSH AX
10
MOV DX, 0
MOV AX, BX
DIV CS:ten
MOV BX, AX
POP AX
JMP begin_print
print_zero:
PUTC '0'
end_print:
POP DX
POP CX
POP BX
POP AX
RET
PRINT_NUM_UNS ENDP
ten DW 10
------------------------------------------------------------------------------------------------------------------
Algorithm
1. Initialize the two registers, AX &CX.
2. Display 0034 & 0067 to the given port number.
3. Initialize the counter.
4. The counter will decrement and the values of AX will be display to port
number 199.
5. Repeat step 4 until port number 199 displays zero.
11
6. The program will end.
Program
#start=led_display.exe#
#make_bin#
NAME "NETWORK2"
MOV AX,67
MOV BX,AX
MOV AX,34
OUT 199,AX
MOV AX,BX
OUT 199,AX
MOV CX,68
MOV AX,CX
DEC AX
12
NETWORK2:
OUT 199,AX
DEC AX
LOOP NETWORK2
ENDS
Programs of Q#1 and Q#3 are written by the group members they are
not copied from anything.
But the program of Question number two is copied from the example in
the emulator.
13