Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code explaining

Status
Not open for further replies.

TheNewbieOnASM

Programmer
Jul 27, 2003
4
US
#MAKE_COM#
ORG 100h
MOV AX, 0B800h
MOV DS, AX
MOV CL, 'A'
MOV CH, 01011111b
MOV BX, 15Eh
MOV [BX], CX

Please can you help me explain this code to me so that I can understand it because I'm just a newbie at assembly or ASM. What are the variables in this program. Also why suddenly the [BX] and CX suddenly appear and what is CX.

Your help will be appreciate.

 
I think the code doesn't mean anything. I just try to explain base on instruction you have posted.
The code doesn't contain any variable. It's all just Value, Register and Address/Pointer
Code:
#MAKE_COM# 
ORG 100h   ; COM file start at origin 100h

MOV AX, 0B800h
; move 0B800h into ax
; 0B800h is the address of VGA card for text mode
MOV DS, AX 
; move AX into DS, so DS hold the address of VGA card

MOV CL, 'A'
; move char 'A' into CL
MOV CH, 01011111b 
; move 01011111b (= 05Fh) into CH

MOV BX, 15Eh
; move 015Eh into BX

MOV [BX], CX
; move a word value from CX into the address pointed by BX
; BX pointing at address 015Eh

Hope it helps
Regards

-- AirCon --
 
Oops!! sorry I made a big mistake [3eyes]

Let me try again.

Code:
#MAKE_COM# 
ORG 100h   ; COM file start at origin 100h

MOV AX, 0B800h
; move 0B800h into ax
; 0B800h is the address of VGA card for text mode
MOV DS, AX 
; move AX into DS, so DS hold the address of VGA card

MOV CL, 'A'
; move char 'A' into CL
MOV CH, 01011111b 
; move 01011111b (= 05Fh) into CH

MOV BX, 15Eh
; move 015Eh into BX

MOV [BX], CX
; move the value from CX (one word) into the address pointed by DS:BX

Since DS hold the address of VGA card, the value of CX will be put directly into the address of VGA card, in other words it will display into the monitor. The display is character 'A' (from CL) and it will be display in colored (from CH).

Hope that helps

-- AirCon --
 
To add to aircon's second reply, in case you aren't aware, cx has appeared because cx is the 16-bit, one-word register whose high half is called ch, and whose low half is called cl.
bx has appeared in brackets because it is being used as an offset. Mov [bx], cx means move cx into the word whose address is held by bx (using ds as the default segment).
Contrast with mov bx, cx, which simply moves cx into the bx register itself.
You can write mov ds:[bx], cx if you find that makes things clearer to you.
Hope that helps.
 
:)

Thank you AirCon and lionelhill for your help and your time. It very helped me and I can understand the code, but not that much. Sorry about my bad english because english is not my mother tongue.

[thumbsup] [thumbsup2] [2thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top