-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12.EvenZeroFifty(Proc).asm
More file actions
60 lines (45 loc) · 2.43 KB
/
12.EvenZeroFifty(Proc).asm
File metadata and controls
60 lines (45 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
TITLE EvenZeroFifty
;Program Desctiption: This program displays even numbers between Zero and Fifty
;Author: Liul Alemayehu
include 'emu8086.inc'
.MODEL SMALL ; com program, Memory Descriptor (Tiny | Small | Medium | Large)
.STACK 100 ; stack
.DATA ; Beginning of data segment where data is stored
msg1 db 'Hi,Even numbers(0-50): ',0 ; Declare variable msg1 and assigned it a value
newline db 13,10,'$' ; Creates newline
.CODE ; Beginning of code segment
main PROC
; Start
MOV Ax,@DATA ; Moving address of data (data segment) to Ax register
MOV Ds,Ax ; Initializing of Data segment register (Ds) from Accumilator register (Ax)
; Prompt1
LEA Si,msg1 ; Loading the effective address of our msg to the Source index register (Si)
CALL PRINT_STRING ; Calling the PRINT_STRING procedure
; Newline
LEA Dx,newline
MOV Ah,09
INT 21h
MOV Bx,00 ; Store the value of Zero in the Bx register
MOV Cx,50 ; Store the value of Fifty in the Cx register
L1:
CMP Bx,Cx ; Compares the numbers
JLE L2 ; Jumps to lable 'L2' if conditions met
JMP Exit ; Jumps to exit
L2:
JMP Print ; Jumps to 'Print' label
; Print Result
Print:
MOV Ax,Bx ; Moves current value to Ax
CALL PRINT_NUM ; Prints number stored in Ax
PRINT ' ' ; Prints an empty space
ADD Bx,02 ; Increments the current value by 2
JMP L1 ; Jumps back to 'L1' label
Exit:
MOV Ah,4Ch ; Exit
INT 21h ; Does it!
main ENDP
DEFINE_SCAN_NUM
DEFINE_PRINT_NUM_UNS
DEFINE_PRINT_NUM
DEFINE_PRINT_STRING
END main