Hi. This is my code for creating a calculator gui in assembly language. What I want to do is to click any number from 1-9 and it will show inside the textfield. Unfortunately, I'm still confused on what to do. I hope you can help me with this. Thank you.

.model small

range macro x,y         ;set cursor
    mov ah, 02
    mov bh, 00
    mov cx, 00
    mov dh, x
    mov dl, y
    int 10h
endm

border macro direction
    mov ah, 09
    lea dx, direction
    int 21h      
endm

display macro char
    mov ah, 02
    mov dl, char
    int 21h
endm  

.data

upBorder    db 220, 220, 220, '$'
leftBorder  db 221, '$'    
downBorder  db 223, 223, 223, '$'
rightBorder db 222, '$' 

extraUpBorder   db 220, 220, 220, 220, 220, '$'
extraDownBorder db 223, 223, 223, 223, 223, '$' 

textFieldUp    db 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, '$'
textFieldLeft  db 221, '$'     
textFieldDown  db 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, '$'
textFieldRight db 222, '$'  
textFieldLeft_1 db 221, '$'
textFieldRight_1 db 222, '$'

up    db 220, 220, 220, 220, 220, 220, 220, '$'
left  db 221, '$'
down  db 223, 223, 223, 223, 223, 223, 223, '$'
right db 222, '$'   

del db 'DEL', '$'
ce  db 'CE' , '$'
c   db 'C'  , '$' 

xorLabel db 'XOR', '$'
orLabel  db 'OR' , '$' 
andLabel db 'AND', '$'
modLabel db 'MOD', '$'

.code

.startup  

;----textfield-----------
range 0, 1
  border textFieldUp  
range 1, 1 
  border textFieldLeft   
range 2, 1
  border textFieldDown  
range 1, 23
  border textFieldRight
;--------------------------
;-----backspace------------
range 3, 1
  border up  
range 4, 1
  border left  
range 5, 1
  border down 
range 4, 7
  border right
range 4, 3
  border del  
;--------------------------  
;-----CE-------------------
range 3, 9
  border up  
range 4, 9
  border left  
range 5, 9
  border down  
range 4, 15
  border right
range 4, 12
  border ce  
;--------------------------  

;-----c--------------------
range 3, 17
  border up  
range 4, 17
  border left  
range 5, 17
  border down  
range 4, 23
  border right
range 4, 20
  border c  
;--------------------------  
;-----7--------------------
range 6, 1
  border upBorder  
range 7, 1
  border leftBorder  
range 8, 1
  border downBorder  
range 7, 3
  border rightBorder  
range 7, 2
  display 37h
;--------------------------  
;-----8-------------------- 
range 6, 5
  border upBorder  
range 7, 5
  border leftBorder  
range 8, 5
  border downBorder  
range 7, 7
  border rightBorder   
range 7, 6
  display 38h   
;--------------------------  
;-----9--------------------  
range 6, 9
  border upBorder  
range 7, 9
  border leftBorder  
range 8, 9
  border downBorder  
range 7, 11
  border rightBorder   
range 7, 10
  display 39h 
;--------------------------  
;-----4--------------------  
range 9, 1
  border upBorder  
range 10, 1
  border leftBorder  
range 11, 1
  border downBorder  
range 10, 3
  border rightBorder   
range 10, 2
  display 34h
;--------------------------  
;-----5--------------------  
range 9, 5
  border upBorder  
range 10, 5
  border leftBorder  
range 11, 5
  border downBorder  
range 10, 7
  border rightBorder   
range 10, 6
  display 35h  
;--------------------------  
;-----6--------------------  
range 9, 9
  border upBorder  
range 10, 9
  border leftBorder  
range 11, 9
  border downBorder  
range 10, 11
  border rightBorder   
range 10, 10
  display 36h  
;--------------------------  
;-----1--------------------  
range 12, 1
  border upBorder  
range 13, 1
  border leftBorder  
range 14, 1
  border downBorder  
range 13, 3
  border rightBorder   
range 13, 2
  display 31h  
;--------------------------  
;-----2--------------------  
range 12, 5
  border upBorder  
range 13, 5
  border leftBorder  
range 14, 5
  border downBorder  
range 13, 7
  border rightBorder   
range 13, 6
  display 32h  
;--------------------------  
;-----3--------------------  
range 12, 9
  border upBorder  
range 13, 9
  border leftBorder  
range 14, 9
  border downBorder  
range 13, 11
  border rightBorder   
range 13, 10
  display 33h  
;--------------------------  
;------0-------------------
range 15, 1
  border up  
range 16, 1
  border left  
range 17, 1
  border down  
range 16, 7
  border right
range 16, 4
  display 30h 
;-------------------------- 
;-----.--------------------  
range 15, 9
  border upBorder  
range 16, 9
  border leftBorder  
range 17, 9
  border downBorder
range 16, 11
  border rightBorder   
range 16, 10
  display 2Eh  
;--------------------------
;-----/--------------------  
range 6, 13
  border upBorder  
range 7, 13
  border leftBorder  
range 8, 13
  border downBorder  
range 7, 15
  border rightBorder   
range 7, 14
  display 2fh  
;-------------------------- 
;-----*--------------------  
range 9, 13
  border upBorder  
range 10, 13
  border leftBorder  
range 11, 13
  border downBorder  
range 10, 15
  border rightBorder   
range 10, 14
  display 2ah  
;--------------------------
;-----(-)------------------  
range 12, 13
  border upBorder  
range 13, 13
  border leftBorder  
range 14, 13
  border downBorder  
range 13, 15
  border rightBorder   
range 13, 14
  display 2dh  
;--------------------------
;-----+--------------------  
range 15, 13
  border upBorder  
range 16, 13
  border leftBorder  
range 17, 13
  border downBorder  
range 16, 15
  border rightBorder   
range 16, 14
  display 2bh 
;---------------------------- 
;-----XOR--------------------  
range 6, 17
  border up  
range 7, 17
  border left  
range 8, 17
  border down  
range 7, 23
  border right   
range 7, 19
  border xorLabel    
;--------------------------
;-----OR--------------------
range 9, 17
  border up  
range 10, 17
  border left
range 11, 17
  border down  
range 10, 23
  border right   
range 10, 19
  border orLabel  
;--------------------------  
;-----AND--------------------  
range 12, 17
  border up  
range 13, 17
  border left  
range 14, 17
  border down  
range 13, 23
  border right   
range 13, 19
  border andLabel 
;-------------------------- 
;-----MOD--------------------  
range 15, 17
  border up  
range 16, 17
  border left  
range 17, 17
  border down  
range 16, 23
  border right   
range 16, 19
  border modLabel
;--------------------------
;-----A--------------------

range 18, 1
  border upBorder  
range 19, 1
  border leftBorder  
range 20, 1
  border downBorder  
range 19, 3
  border rightBorder   
range 19, 2
  display 41h  
;-------------------------- 
;-----B--------------------  
range 18, 5
  border upBorder  
range 19, 5
  border leftBorder  
range 20, 5
  border downBorder  
range 19, 7
  border rightBorder  
range 19, 6
  display 42h  
;-------------------------- 
;-----C--------------------  
range 18, 9
  border upBorder  
range 19, 9
  border leftBorder  
range 20, 9
  border downBorder  
range 19, 11
  border rightBorder   
range 19, 10
  display 43h
;--------------------------  
;-----D--------------------
range 18, 13
  border upBorder  
range 19, 13
  border leftBorder  
range 20, 13
  border downBorder  
range 19, 15
  border rightBorder   
range 19, 14
  display 44h  
;--------------------------  
;-----E--------------------  
range 18, 17
  border upBorder  
range 19, 17
  border leftBorder
range 20, 17
  border downBorder  
range 19, 19
  border rightBorder   
range 19, 18
  display 45h  
;--------------------------
;-----F--------------------  
range 18, 21
  border upBorder  
range 19, 21
  border leftBorder  
range 20, 21
  border downBorder
range 19, 23
  border rightBorder   
range 19, 22
  display 46h  
;-------------------------- 

mouse_pointer:
  mov ax, 00h
  int 33h 

  mov ax, 01h
  int 33h

.exit
end

Hi,
1. If you like, you could use a macro to call range and border. Something like:
macro mymacro x, y, b
range x, y
border b
endm
Saving a lot of writing. But I think that your code can be shorter with some loops.
2.You have started the calculator. Now you may enter in a loop that checks if an apropiate key have been pressed or if the apropiate mouse button have been pressed in the correct place. Your loop ends with the apropiate action, may be the esc key.
If you need reading about interrupts, try this link:
Click Here
Best regards.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.